Java Doc for JdbcUtils.java in  » J2EE » spring-framework-2.5 » org » springframework » jdbc » support » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.5 » org.springframework.jdbc.support 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.jdbc.support.JdbcUtils

JdbcUtils
abstract public class JdbcUtils (Code)
Generic utility methods for working with JDBC. Mainly for internal use within the framework, but also useful for custom JDBC access code.
author:
   Thomas Risberg
author:
   Juergen Hoeller


Field Summary
final public static  intTYPE_UNKNOWN
     Constant that indicates an unknown (or unspecified) SQL type.


Method Summary
public static  voidcloseConnection(Connection con)
     Close the given JDBC Connection and ignore any thrown exception.
public static  voidcloseResultSet(ResultSet rs)
     Close the given JDBC ResultSet and ignore any thrown exception.
public static  voidcloseStatement(Statement stmt)
     Close the given JDBC Statement and ignore any thrown exception.
public static  StringcommonDatabaseName(String source)
     Extract a common name for the database in use even if various drivers/platforms provide varying names.
public static  StringconvertUnderscoreNameToPropertyName(String name)
     Convert a column name with underscores to the corresponding property name using "camel case".
public static  ObjectextractDatabaseMetaData(DataSource dataSource, DatabaseMetaDataCallback action)
     Extract database meta data via the given DatabaseMetaDataCallback.

This method will open a connection to the database and retrieve the database metadata. Since this method is called before the exception translation feature is configured for a datasource, this method can not rely on the SQLException translation functionality.

Any exceptions will be wrapped in a MetaDataAccessException.

public static  ObjectextractDatabaseMetaData(DataSource dataSource, String metaDataMethodName)
     Call the specified method on DatabaseMetaData for the given DataSource, and extract the invocation result.
public static  ObjectgetResultSetValue(ResultSet rs, int index)
     Retrieve a JDBC column value from a ResultSet, using the most appropriate value type.
public static  booleanisNumeric(int sqlType)
     Check whether the given SQL type is numeric.
public static  StringlookupColumnName(ResultSetMetaData resultSetMetaData, int columnIndex)
     Determine the column name to use.
public static  booleansupportsBatchUpdates(Connection con)
     Return whether the given JDBC driver supports JDBC 2.0 batch updates.

Field Detail
TYPE_UNKNOWN
final public static int TYPE_UNKNOWN(Code)
Constant that indicates an unknown (or unspecified) SQL type.
See Also:   java.sql.Types





Method Detail
closeConnection
public static void closeConnection(Connection con)(Code)
Close the given JDBC Connection and ignore any thrown exception. This is useful for typical finally blocks in manual JDBC code.
Parameters:
  con - the JDBC Connection to close (may be null)



closeResultSet
public static void closeResultSet(ResultSet rs)(Code)
Close the given JDBC ResultSet and ignore any thrown exception. This is useful for typical finally blocks in manual JDBC code.
Parameters:
  rs - the JDBC ResultSet to close (may be null)



closeStatement
public static void closeStatement(Statement stmt)(Code)
Close the given JDBC Statement and ignore any thrown exception. This is useful for typical finally blocks in manual JDBC code.
Parameters:
  stmt - the JDBC Statement to close (may be null)



commonDatabaseName
public static String commonDatabaseName(String source)(Code)
Extract a common name for the database in use even if various drivers/platforms provide varying names.
Parameters:
  source - the name as provided in database metedata the common name to be used



convertUnderscoreNameToPropertyName
public static String convertUnderscoreNameToPropertyName(String name)(Code)
Convert a column name with underscores to the corresponding property name using "camel case". A name like "customer_number" would match a "customerNumber" property name.
Parameters:
  name - the column name to be converted the name using "camel case"



extractDatabaseMetaData
public static Object extractDatabaseMetaData(DataSource dataSource, DatabaseMetaDataCallback action) throws MetaDataAccessException(Code)
Extract database meta data via the given DatabaseMetaDataCallback.

This method will open a connection to the database and retrieve the database metadata. Since this method is called before the exception translation feature is configured for a datasource, this method can not rely on the SQLException translation functionality.

Any exceptions will be wrapped in a MetaDataAccessException. This is a checked exception and any calling code should catch and handle this exception. You can just log the error and hope for the best, but there is probably a more serious error that will reappear when you try to access the database again.
Parameters:
  dataSource - the DataSource to extract metadata for
Parameters:
  action - callback that will do the actual work object containing the extracted information, as returned bythe DatabaseMetaDataCallback's processMetaData method
throws:
  MetaDataAccessException - if meta data access failed




extractDatabaseMetaData
public static Object extractDatabaseMetaData(DataSource dataSource, String metaDataMethodName) throws MetaDataAccessException(Code)
Call the specified method on DatabaseMetaData for the given DataSource, and extract the invocation result.
Parameters:
  dataSource - the DataSource to extract meta data for
Parameters:
  metaDataMethodName - the name of the DatabaseMetaData method to call the object returned by the specified DatabaseMetaData method
throws:
  MetaDataAccessException - if we couldn't access the DatabaseMetaDataor failed to invoke the specified method
See Also:   java.sql.DatabaseMetaData



getResultSetValue
public static Object getResultSetValue(ResultSet rs, int index) throws SQLException(Code)
Retrieve a JDBC column value from a ResultSet, using the most appropriate value type. The returned value should be a detached value object, not having any ties to the active ResultSet: in particular, it should not be a Blob or Clob object but rather a byte array respectively String representation.

Uses the getObject(index) method, but includes additional "hacks" to get around Oracle 10g returning a non-standard object for its TIMESTAMP datatype and a java.sql.Date for DATE columns leaving out the time portion: These columns will explicitly be extracted as standard java.sql.Timestamp object.
Parameters:
  rs - is the ResultSet holding the data
Parameters:
  index - is the column index the value object
throws:
  SQLException - if thrown by the JDBC API
See Also:   java.sql.Blob
See Also:   java.sql.Clob
See Also:   java.sql.Timestamp




isNumeric
public static boolean isNumeric(int sqlType)(Code)
Check whether the given SQL type is numeric.
Parameters:
  sqlType - the SQL type to be checked whether the type is numeric



lookupColumnName
public static String lookupColumnName(ResultSetMetaData resultSetMetaData, int columnIndex) throws SQLException(Code)
Determine the column name to use. The column name is determined based on a lookup using ResultSetMetaData.

This method implementation takes into account recent clarifications expressed in the JDBC 4.0 specification:

columnLabel - the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column. the column name to use
Parameters:
  resultSetMetaData - the current meta data to use
Parameters:
  columnIndex - the index of the column for the look up
throws:
  SQLException - in case of lookup failure




supportsBatchUpdates
public static boolean supportsBatchUpdates(Connection con)(Code)
Return whether the given JDBC driver supports JDBC 2.0 batch updates.

Typically invoked right before execution of a given set of statements: to decide whether the set of SQL statements should be executed through the JDBC 2.0 batch mechanism or simply in a traditional one-by-one fashion.

Logs a warning if the "supportsBatchUpdates" methods throws an exception and simply returns false in that case.
Parameters:
  con - the Connection to check whether JDBC 2.0 batch updates are supported
See Also:   java.sql.DatabaseMetaData.supportsBatchUpdates




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.