Java Doc for SingleConnectionDataSource.java in  » Search-Engine » compass-2.0 » org » compass » gps » device » 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 » Search Engine » compass 2.0 » org.compass.gps.device.jdbc.datasource 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.compass.gps.device.jdbc.datasource.AbstractDataSource
      org.compass.gps.device.jdbc.datasource.DriverManagerDataSource
         org.compass.gps.device.jdbc.datasource.SingleConnectionDataSource

SingleConnectionDataSource
public class SingleConnectionDataSource extends DriverManagerDataSource (Code)
Implementation of SmartDataSource that wraps a single Connection which is not closed after use. Obviously, this is not multi-threading capable.

Note that at shutdown, someone should close the underlying connection via the close() method. Client code will never call close on the Connection handle if it is SmartDataSource-aware (e.g. uses DataSourceUtils.releaseConnection).

If client code will call close() in the assumption of a pooled Connection, like when using persistence tools, set "suppressClose" to "true". This will return a close-suppressing proxy instead of the physical Connection. Be aware that you will not be able to cast this to a native OracleConnection or the like anymore (you need to use a NativeJdbcExtractor for this then).

This is primarily intended for testing. For example, it enables easy testing outside an application server, for code that expects to work on a DataSource. In contrast to DriverManagerDataSource, it reuses the same Connection all the time, avoiding excessive creation of physical Connections.

Taken from Spring
author:
   kimchy
See Also:   java.sql.Connection.close




Constructor Summary
public  SingleConnectionDataSource()
     Constructor for bean-style configuration.
public  SingleConnectionDataSource(String driverClassName, String url, String username, String password, boolean suppressClose)
     Create a new SingleConnectionDataSource with the given standard DriverManager parameters.
public  SingleConnectionDataSource(String url, String username, String password, boolean suppressClose)
     Create a new SingleConnectionDataSource with the given standard DriverManager parameters.
public  SingleConnectionDataSource(String url, boolean suppressClose)
     Create a new SingleConnectionDataSource with the given standard DriverManager parameters.
public  SingleConnectionDataSource(Connection target, boolean suppressClose)
     Create a new SingleConnectionDataSource with a given connection.

Method Summary
public  voiddestroy()
     Close the underlying connection.
protected  ConnectiongetCloseSuppressingConnectionProxy(Connection target)
     Wrap the given Connection with a proxy that delegates every method call to it but suppresses close calls.
public  ConnectiongetConnection()
    
public  ConnectiongetConnection(String username, String password)
     Specifying a custom username and password doesn't make sense with a single connection.
protected  voidinit()
     Initialize the underlying connection via DriverManager.
protected  voidinit(Connection target)
     Initialize the underlying connection.
public  booleanisSuppressClose()
     Return if the returned connection will be a close-suppressing proxy or the physical connection.
public  voidsetSuppressClose(boolean suppressClose)
     Set if the returned connection should be a close-suppressing proxy or the physical connection.
public  booleanshouldClose(Connection con)
     This is a single connection: Do not close it when returning to the "pool".


Constructor Detail
SingleConnectionDataSource
public SingleConnectionDataSource()(Code)
Constructor for bean-style configuration.



SingleConnectionDataSource
public SingleConnectionDataSource(String driverClassName, String url, String username, String password, boolean suppressClose) throws CannotGetJdbcConnectionException(Code)
Create a new SingleConnectionDataSource with the given standard DriverManager parameters.
Parameters:
  driverClassName - the JDBC driver class name
Parameters:
  url - the JDBC URL to use for accessing the DriverManager
Parameters:
  username - the JDBC username to use for accessing the DriverManager
Parameters:
  password - the JDBC password to use for accessing the DriverManager
Parameters:
  suppressClose - if the returned connection should be a close-suppressing proxyor the physical connection.
See Also:   java.sql.DriverManager.getConnection(StringStringString)



SingleConnectionDataSource
public SingleConnectionDataSource(String url, String username, String password, boolean suppressClose) throws CannotGetJdbcConnectionException(Code)
Create a new SingleConnectionDataSource with the given standard DriverManager parameters.
Parameters:
  url - the JDBC URL to use for accessing the DriverManager
Parameters:
  username - the JDBC username to use for accessing the DriverManager
Parameters:
  password - the JDBC password to use for accessing the DriverManager
Parameters:
  suppressClose - if the returned connection should be a close-suppressing proxyor the physical connection.
See Also:   java.sql.DriverManager.getConnection(StringStringString)



SingleConnectionDataSource
public SingleConnectionDataSource(String url, boolean suppressClose) throws CannotGetJdbcConnectionException(Code)
Create a new SingleConnectionDataSource with the given standard DriverManager parameters.
Parameters:
  url - the JDBC URL to use for accessing the DriverManager
Parameters:
  suppressClose - if the returned connection should be a close-suppressing proxyor the physical connection.
See Also:   java.sql.DriverManager.getConnection(StringStringString)



SingleConnectionDataSource
public SingleConnectionDataSource(Connection target, boolean suppressClose)(Code)
Create a new SingleConnectionDataSource with a given connection.
Parameters:
  target - underlying target connection
Parameters:
  suppressClose - if the connection should be wrapped with a* connection thatsuppresses close() calls (to allow for normal close() usage inapplications that expect a pooled connection but do not knowour SmartDataSource interface).




Method Detail
destroy
public void destroy() throws SQLException(Code)
Close the underlying connection. The provider of this DataSource needs to care for proper shutdown.

As this bean implements DisposableBean, a bean factory will automatically invoke this on destruction of its cached singletons.




getCloseSuppressingConnectionProxy
protected Connection getCloseSuppressingConnectionProxy(Connection target)(Code)
Wrap the given Connection with a proxy that delegates every method call to it but suppresses close calls.
Parameters:
  target - the original Connection to wrap the wrapped Connection



getConnection
public Connection getConnection() throws SQLException(Code)



getConnection
public Connection getConnection(String username, String password) throws SQLException(Code)
Specifying a custom username and password doesn't make sense with a single connection. Returns the single connection if given the same username and password, though.



init
protected void init() throws SQLException(Code)
Initialize the underlying connection via DriverManager.



init
protected void init(Connection target)(Code)
Initialize the underlying connection. Wraps the connection with a close-suppressing proxy if necessary.
Parameters:
  target - the JDBC Connection to use



isSuppressClose
public boolean isSuppressClose()(Code)
Return if the returned connection will be a close-suppressing proxy or the physical connection.



setSuppressClose
public void setSuppressClose(boolean suppressClose)(Code)
Set if the returned connection should be a close-suppressing proxy or the physical connection.



shouldClose
public boolean shouldClose(Connection con)(Code)
This is a single connection: Do not close it when returning to the "pool".



Methods inherited from org.compass.gps.device.jdbc.datasource.DriverManagerDataSource
public Connection getConnection() throws SQLException(Code)(Java Doc)
public Connection getConnection(String username, String password) throws SQLException(Code)(Java Doc)
protected Connection getConnectionFromDriverManager() throws SQLException(Code)(Java Doc)
protected Connection getConnectionFromDriverManager(String url, String username, String password) throws SQLException(Code)(Java Doc)
public String getDriverClassName()(Code)(Java Doc)
public String getPassword()(Code)(Java Doc)
public String getUrl()(Code)(Java Doc)
public String getUsername()(Code)(Java Doc)
public void setDriverClassName(String driverClassName) throws CannotGetJdbcConnectionException(Code)(Java Doc)
public void setPassword(String password)(Code)(Java Doc)
public void setUrl(String url)(Code)(Java Doc)
public void setUsername(String username)(Code)(Java Doc)

Fields inherited from org.compass.gps.device.jdbc.datasource.AbstractDataSource
final protected Log log(Code)(Java Doc)

Methods inherited from org.compass.gps.device.jdbc.datasource.AbstractDataSource
public PrintWriter getLogWriter()(Code)(Java Doc)
public int getLoginTimeout() throws SQLException(Code)(Java Doc)
public boolean isWrapperFor(Class iface) throws SQLException(Code)(Java Doc)
public void setLogWriter(PrintWriter pw) throws SQLException(Code)(Java Doc)
public void setLoginTimeout(int timeout) throws SQLException(Code)(Java Doc)
public Object unwrap(Class iface) throws SQLException(Code)(Java Doc)

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.