| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.springframework.jdbc.datasource.AbstractDataSource | +--org.springframework.jdbc.datasource.DriverManagerDataSource
Implementation of SmartDataSource that configures a plain old JDBC Driver via bean properties, and returns a new connection every time.
Useful for test or standalone environments outside of a J2EE container, either as a DataSource bean in a respective 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 exported as a DataSource bean in an ApplicationContext via JndiObjectFactoryBean, for seamless switching to and from a local DataSource bean like this class.
If you need a "real" connection pool outside of a container, consider Apache's Jakarta Commons DBCP. Its BasicDataSource is a full connection pool bean, supporting the same basic properties as this class + specific settings. It can be used as a replacement for an instance of this class just by exchanging the class name of the bean definition to "org.apache.commons.dbcp.BasicDataSource".
| Constructor Summary | |
DriverManagerDataSource()Constructor for bean-style configuration. | |
DriverManagerDataSource(String driverClassName, String url, String username, String password)Create a new SingleConnectionDataSource with the given standard DriverManager parameters. | |
| Method Summary | |
Connection | getConnection() |
Connection | getConnection(String username, String password) |
String | getDriverClassName() |
String | getPassword() |
String | getUrl() |
String | getUsername() |
void | setDriverClassName(String driverClassName) |
void | setPassword(String password) |
void | setUrl(String url) |
void | setUsername(String username) |
boolean | shouldClose(Connection conn)This DataSource returns a new connection every time: Close it when returning one to the "pool". |
| Methods inherited from class org.springframework.jdbc.datasource.AbstractDataSource |
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter |
| Constructor Detail |
public DriverManagerDataSource()
public DriverManagerDataSource(String driverClassName, String url, String username, String password)
throws CannotGetJdbcConnectionException
| Method Detail |
public Connection getConnection()
throws java.sql.SQLException
public Connection getConnection(String username, String password)
throws java.sql.SQLException
public String getDriverClassName()
public String getPassword()
public String getUrl()
public String getUsername()
public void setDriverClassName(String driverClassName)
throws CannotGetJdbcConnectionException
public void setPassword(String password)
public void setUrl(String url)
public void setUsername(String username)
public boolean shouldClose(Connection conn)
| Association Links |
to Class java.lang.String
to Class java.lang.String
to Class java.lang.String
| |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||