Java Doc for DriverManagerDataSource.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.AbstractDataSource
      org.springframework.jdbc.datasource.DriverManagerDataSource

All known Subclasses:   org.springframework.jdbc.datasource.SingleConnectionDataSource,
DriverManagerDataSource
public class DriverManagerDataSource extends AbstractDataSource (Code)
Simple implementation of the standard JDBC DataSource interface, configuring a plain old JDBC Driver via bean properties, and returning a new Connection for every getConnection call.

NOTE: This class is not an actual connection pool; it does not actually pool Connections. It just serves as simple replacement for a full-blown connection pool, implementing the same standard interface, but creating new Connections on every call.

Useful for test or standalone environments outside of a J2EE container, either as a DataSource bean in a corresponding ApplicationContext or in conjunction with a simple JNDI environment. Pool-assuming Connection.close() calls will simply close the Connection, so any DataSource-aware persistence code should work.

In a J2EE container, it is recommended to use a JNDI DataSource provided by the container. Such a DataSource can be exposed as a DataSource bean in a Spring ApplicationContext via JndiObjectFactoryBean, for seamless switching to and from a local DataSource bean like this class. For tests, you can then either set up a mock JNDI environment through Spring's SimpleNamingContextBuilder, or switch the bean definition to a local DataSource (which is simpler and thus recommended).

If you need a "real" connection pool outside of a J2EE container, consider Apache's Jakarta Commons DBCP or C3P0. Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full connection pool beans, supporting the same basic properties as this class plus specific settings (such as minimal/maximal pool size etc).

Commons DBCP's BasicDataSource can even be used as a direct replacement for an instance of this class just by changing the class name of the bean definition to "org.apache.commons.dbcp.BasicDataSource", because the names of all common properties match exactly. Note that both BasicDataSource and ComboPooledDataSource should be defined with destroy-method="close", for immediate shutdown when the Spring ApplicationContext shuts down.
author:
   Juergen Hoeller
since:
   14.03.2003
See Also:   org.springframework.jndi.JndiObjectFactoryBean
See Also:   org.springframework.mock.jndi.SimpleNamingContextBuilder
See Also:   org.apache.commons.dbcp.BasicDataSource
See Also:   com.mchange.v2.c3p0.ComboPooledDataSource




Constructor Summary
public  DriverManagerDataSource()
     Constructor for bean-style configuration.
public  DriverManagerDataSource(String driverClassName, String url, String username, String password)
     Create a new DriverManagerDataSource with the given standard DriverManager parameters.
public  DriverManagerDataSource(String url, String username, String password)
     Create a new DriverManagerDataSource with the given standard DriverManager parameters.
public  DriverManagerDataSource(String url)
     Create a new DriverManagerDataSource with the given JDBC URL, not specifying a username or password for JDBC access.

Method Summary
public  ConnectiongetConnection()
     This implementation delegates to getConnectionFromDriverManager, using the default username and password of this DataSource.
public  ConnectiongetConnection(String username, String password)
     This implementation delegates to getConnectionFromDriverManager, using the given username and password.
protected  ConnectiongetConnectionFromDriverManager()
     Get a Connection from the DriverManager, using the default username and password of this DataSource.
protected  ConnectiongetConnectionFromDriverManager(String username, String password)
     Build properties for the DriverManager, including the given username and password (if any).
protected  ConnectiongetConnectionFromDriverManager(String url, Properties props)
     Getting a connection using the nasty static from DriverManager is extracted into a protected method to allow for easy unit testing.
public  PropertiesgetConnectionProperties()
     Return the connection properties to be passed to the DriverManager, if any.
public  StringgetDriverClassName()
     Return the JDBC driver class name, if any.
public  StringgetPassword()
     Return the JDBC password to use for accessing the DriverManager.
public  StringgetUrl()
     Return the JDBC URL to use for accessing the DriverManager.
public  StringgetUsername()
     Return the JDBC username to use for accessing the DriverManager.
public  voidsetConnectionProperties(Properties connectionProperties)
     Specify arbitrary connection properties as key/value pairs, to be passed to the DriverManager.

Can also contain "user" and "password" properties.

public  voidsetDriverClassName(String driverClassName)
     Set the JDBC driver class name.
public  voidsetPassword(String password)
     Set the JDBC password to use for accessing the DriverManager.
public  voidsetUrl(String url)
     Set the JDBC URL to use for accessing the DriverManager.
public  voidsetUsername(String username)
     Set the JDBC username to use for accessing the DriverManager.


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



DriverManagerDataSource
public DriverManagerDataSource(String driverClassName, String url, String username, String password) throws CannotGetJdbcConnectionException(Code)
Create a new DriverManagerDataSource 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
See Also:   java.sql.DriverManager.getConnection(StringStringString)



DriverManagerDataSource
public DriverManagerDataSource(String url, String username, String password) throws CannotGetJdbcConnectionException(Code)
Create a new DriverManagerDataSource 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
See Also:   java.sql.DriverManager.getConnection(StringStringString)



DriverManagerDataSource
public DriverManagerDataSource(String url) throws CannotGetJdbcConnectionException(Code)
Create a new DriverManagerDataSource with the given JDBC URL, not specifying a username or password for JDBC access.
Parameters:
  url - the JDBC URL to use for accessing the DriverManager
See Also:   java.sql.DriverManager.getConnection(String)




Method Detail
getConnection
public Connection getConnection() throws SQLException(Code)
This implementation delegates to getConnectionFromDriverManager, using the default username and password of this DataSource.
See Also:   DriverManagerDataSource.getConnectionFromDriverManager()



getConnection
public Connection getConnection(String username, String password) throws SQLException(Code)
This implementation delegates to getConnectionFromDriverManager, using the given username and password.
See Also:   DriverManagerDataSource.getConnectionFromDriverManager(String,String)



getConnectionFromDriverManager
protected Connection getConnectionFromDriverManager() throws SQLException(Code)
Get a Connection from the DriverManager, using the default username and password of this DataSource.
See Also:   DriverManagerDataSource.getConnectionFromDriverManager(String,String)



getConnectionFromDriverManager
protected Connection getConnectionFromDriverManager(String username, String password) throws SQLException(Code)
Build properties for the DriverManager, including the given username and password (if any).
See Also:   DriverManagerDataSource.getConnectionFromDriverManager(String,java.util.Properties)



getConnectionFromDriverManager
protected Connection getConnectionFromDriverManager(String url, Properties props) throws SQLException(Code)
Getting a connection using the nasty static from DriverManager is extracted into a protected method to allow for easy unit testing.
See Also:   java.sql.DriverManager.getConnection(Stringjava.util.Properties)



getConnectionProperties
public Properties getConnectionProperties()(Code)
Return the connection properties to be passed to the DriverManager, if any.



getDriverClassName
public String getDriverClassName()(Code)
Return the JDBC driver class name, if any.



getPassword
public String getPassword()(Code)
Return the JDBC password to use for accessing the DriverManager.



getUrl
public String getUrl()(Code)
Return the JDBC URL to use for accessing the DriverManager.



getUsername
public String getUsername()(Code)
Return the JDBC username to use for accessing the DriverManager.



setConnectionProperties
public void setConnectionProperties(Properties connectionProperties)(Code)
Specify arbitrary connection properties as key/value pairs, to be passed to the DriverManager.

Can also contain "user" and "password" properties. However, any "username" and "password" bean properties specified on this DataSource will override the corresponding connection properties.
See Also:   java.sql.DriverManager.getConnection(Stringjava.util.Properties)




setDriverClassName
public void setDriverClassName(String driverClassName) throws CannotGetJdbcConnectionException(Code)
Set the JDBC driver class name. This driver will get initialized on startup, registering itself with the JDK's DriverManager.

Alternatively, consider initializing the JDBC driver yourself before instantiating this DataSource.
See Also:   Class.forName(String)
See Also:   java.sql.DriverManager.registerDriver(java.sql.Driver)




setPassword
public void setPassword(String password)(Code)
Set the JDBC password to use for accessing the DriverManager.
See Also:   java.sql.DriverManager.getConnection(StringStringString)



setUrl
public void setUrl(String url)(Code)
Set the JDBC URL to use for accessing the DriverManager.
See Also:   java.sql.DriverManager.getConnection(StringStringString)



setUsername
public void setUsername(String username)(Code)
Set the JDBC username to use for accessing the DriverManager.
See Also:   java.sql.DriverManager.getConnection(StringStringString)



Fields inherited from org.springframework.jdbc.datasource.AbstractDataSource
final protected Log logger(Code)(Java Doc)

Methods inherited from org.springframework.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.