Java Doc for DataSourceUtils.java in  » J2EE » spring-framework-2.5 » org » springframework » jdbc » datasource » 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.datasource 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.jdbc.datasource.DataSourceUtils

DataSourceUtils
abstract public class DataSourceUtils (Code)
Helper class that provides static methods for obtaining JDBC Connections from a javax.sql.DataSource . Includes special support for Spring-managed transactional Connections, e.g. managed by DataSourceTransactionManager or org.springframework.transaction.jta.JtaTransactionManager .

Used internally by Spring's org.springframework.jdbc.core.JdbcTemplate , Spring's JDBC operation objects and the JDBC DataSourceTransactionManager . Can also be used directly in application code.
author:
   Rod Johnson
author:
   Juergen Hoeller
See Also:   DataSourceUtils.getConnection
See Also:   DataSourceUtils.releaseConnection
See Also:   DataSourceTransactionManager
See Also:   org.springframework.transaction.jta.JtaTransactionManager
See Also:   org.springframework.transaction.support.TransactionSynchronizationManager



Field Summary
final public static  intCONNECTION_SYNCHRONIZATION_ORDER
     Order value for TransactionSynchronization objects that clean up JDBC Connections.


Method Summary
public static  voidapplyTimeout(Statement stmt, DataSource dataSource, int timeout)
     Apply the specified timeout - overridden by the current transaction timeout, if any - to the given JDBC Statement object.
public static  voidapplyTransactionTimeout(Statement stmt, DataSource dataSource)
     Apply the current transaction timeout, if any, to the given JDBC Statement object.
public static  ConnectiondoGetConnection(DataSource dataSource)
     Actually obtain a JDBC Connection from the given DataSource. Same as DataSourceUtils.getConnection , but throwing the original SQLException.

Is aware of a corresponding Connection bound to the current thread, for example when using DataSourceTransactionManager .

public static  voiddoReleaseConnection(Connection con, DataSource dataSource)
     Actually close the given Connection, obtained from the given DataSource.
public static  ConnectiongetConnection(DataSource dataSource)
     Obtain a Connection from the given DataSource.
public static  ConnectiongetTargetConnection(Connection con)
     Return the innermost target Connection of the given Connection.
public static  booleanisConnectionTransactional(Connection con, DataSource dataSource)
     Determine whether the given JDBC Connection is transactional, that is, bound to the current thread by Spring's transaction facilities.
public static  IntegerprepareConnectionForTransaction(Connection con, TransactionDefinition definition)
     Prepare the given Connection with the given transaction semantics.
public static  voidreleaseConnection(Connection con, DataSource dataSource)
     Close the given Connection, obtained from the given DataSource, if it is not managed externally (that is, not bound to the thread).
public static  voidresetConnectionAfterTransaction(Connection con, Integer previousIsolationLevel)
     Reset the given Connection after a transaction, regarding read-only flag and isolation level.

Field Detail
CONNECTION_SYNCHRONIZATION_ORDER
final public static int CONNECTION_SYNCHRONIZATION_ORDER(Code)
Order value for TransactionSynchronization objects that clean up JDBC Connections.





Method Detail
applyTimeout
public static void applyTimeout(Statement stmt, DataSource dataSource, int timeout) throws SQLException(Code)
Apply the specified timeout - overridden by the current transaction timeout, if any - to the given JDBC Statement object.
Parameters:
  stmt - the JDBC Statement object
Parameters:
  dataSource - the DataSource that the Connection was obtained from
Parameters:
  timeout - the timeout to apply (or 0 for no timeout outside of a transaction)
throws:
  SQLException - if thrown by JDBC methods
See Also:   java.sql.Statement.setQueryTimeout



applyTransactionTimeout
public static void applyTransactionTimeout(Statement stmt, DataSource dataSource) throws SQLException(Code)
Apply the current transaction timeout, if any, to the given JDBC Statement object.
Parameters:
  stmt - the JDBC Statement object
Parameters:
  dataSource - the DataSource that the Connection was obtained from
throws:
  SQLException - if thrown by JDBC methods
See Also:   java.sql.Statement.setQueryTimeout



doGetConnection
public static Connection doGetConnection(DataSource dataSource) throws SQLException(Code)
Actually obtain a JDBC Connection from the given DataSource. Same as DataSourceUtils.getConnection , but throwing the original SQLException.

Is aware of a corresponding Connection bound to the current thread, for example when using DataSourceTransactionManager . Will bind a Connection to the thread if transaction synchronization is active (e.g. if in a JTA transaction).

Directly accessed by TransactionAwareDataSourceProxy .
Parameters:
  dataSource - the DataSource to obtain Connections from a JDBC Connection from the given DataSource
throws:
  SQLException - if thrown by JDBC methods
See Also:   DataSourceUtils.doReleaseConnection




doReleaseConnection
public static void doReleaseConnection(Connection con, DataSource dataSource) throws SQLException(Code)
Actually close the given Connection, obtained from the given DataSource. Same as DataSourceUtils.releaseConnection , but throwing the original SQLException.

Directly accessed by TransactionAwareDataSourceProxy .
Parameters:
  con - the Connection to close if necessary(if this is null, the call will be ignored)
Parameters:
  dataSource - the DataSource that the Connection was obtained from(may be null)
throws:
  SQLException - if thrown by JDBC methods
See Also:   DataSourceUtils.doGetConnection




getConnection
public static Connection getConnection(DataSource dataSource) throws CannotGetJdbcConnectionException(Code)
Obtain a Connection from the given DataSource. Translates SQLExceptions into the Spring hierarchy of unchecked generic data access exceptions, simplifying calling code and making any exception that is thrown more meaningful.

Is aware of a corresponding Connection bound to the current thread, for example when using DataSourceTransactionManager . Will bind a Connection to the thread if transaction synchronization is active, e.g. when running within a org.springframework.transaction.jta.JtaTransactionManager JTA transaction).
Parameters:
  dataSource - the DataSource to obtain Connections from a JDBC Connection from the given DataSource
throws:
  org.springframework.jdbc.CannotGetJdbcConnectionException - if the attempt to get a Connection failed
See Also:   DataSourceUtils.releaseConnection




getTargetConnection
public static Connection getTargetConnection(Connection con)(Code)
Return the innermost target Connection of the given Connection. If the given Connection is a proxy, it will be unwrapped until a non-proxy Connection is found. Else, the passed-in Connection will be returned as-is.
Parameters:
  con - the Connection proxy to unwrap the innermost target Connection, or the passed-in one if no proxy
See Also:   ConnectionProxy.getTargetConnection



isConnectionTransactional
public static boolean isConnectionTransactional(Connection con, DataSource dataSource)(Code)
Determine whether the given JDBC Connection is transactional, that is, bound to the current thread by Spring's transaction facilities.
Parameters:
  con - the Connection to check
Parameters:
  dataSource - the DataSource that the Connection was obtained from(may be null) whether the Connection is transactional



prepareConnectionForTransaction
public static Integer prepareConnectionForTransaction(Connection con, TransactionDefinition definition) throws SQLException(Code)
Prepare the given Connection with the given transaction semantics.
Parameters:
  con - the Connection to prepare
Parameters:
  definition - the transaction definition to apply the previous isolation level, if any
throws:
  SQLException - if thrown by JDBC methods
See Also:   DataSourceUtils.resetConnectionAfterTransaction



releaseConnection
public static void releaseConnection(Connection con, DataSource dataSource)(Code)
Close the given Connection, obtained from the given DataSource, if it is not managed externally (that is, not bound to the thread).
Parameters:
  con - the Connection to close if necessary(if this is null, the call will be ignored)
Parameters:
  dataSource - the DataSource that the Connection was obtained from(may be null)
See Also:   DataSourceUtils.getConnection



resetConnectionAfterTransaction
public static void resetConnectionAfterTransaction(Connection con, Integer previousIsolationLevel)(Code)
Reset the given Connection after a transaction, regarding read-only flag and isolation level.
Parameters:
  con - the Connection to reset
Parameters:
  previousIsolationLevel - the isolation level to restore, if any
See Also:   DataSourceUtils.prepareConnectionForTransaction



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.