|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javagen.agile.db.util.DriverManagerDataSource
public class DriverManagerDataSource
A generic way to access database drivers given the driver class name, url, username and password.
Compiled from code found in the Spring Framework.
| Constructor Summary | |
|---|---|
DriverManagerDataSource()
Constructor for bean-style configuration. |
|
DriverManagerDataSource(String url)
Create a new DriverManagerDataSource with the given JDBC URL, not specifying a username or password for JDBC access. |
|
DriverManagerDataSource(String url,
String username,
String password)
Create a new DriverManagerDataSource with the given standard DriverManager parameters. |
|
DriverManagerDataSource(String driverClassName,
String url,
String username,
String password)
Create a new DriverManagerDataSource with the given standard DriverManager parameters. |
|
| Method Summary | |
|---|---|
Connection |
getConnection()
This implementation delegates to getConnectionFromDriverManager,
using the default username and password of this DataSource. |
Connection |
getConnection(String username,
String password)
This implementation delegates to getConnectionFromDriverManager,
using the given username and password. |
protected Connection |
getConnectionFromDriverManager()
Get a Connection from the DriverManager, using the default username and password of this DataSource. |
protected Connection |
getConnectionFromDriverManager(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. |
protected Connection |
getConnectionFromDriverManager(String username,
String password)
Build properties for the DriverManager, including the given username and password (if any). |
Properties |
getConnectionProperties()
Return the connection properties to be passed to the DriverManager, if any. |
static ClassLoader |
getDefaultClassLoader()
|
String |
getDriverClassName()
Return the JDBC driver class name, if any. |
int |
getLoginTimeout()
Returns 0: means use default system timeout. |
PrintWriter |
getLogWriter()
LogWriter methods are unsupported. |
String |
getPassword()
Return the JDBC password to use for accessing the DriverManager. |
String |
getUrl()
Return the JDBC URL to use for accessing the DriverManager. |
String |
getUsername()
Return the JDBC username to use for accessing the DriverManager. |
void |
setConnectionProperties(Properties connectionProperties)
Specify arbitrary connection properties as key/value pairs, to be passed to the DriverManager. |
void |
setDriverClassName(String driverClassName)
Set the JDBC driver class name. |
void |
setLoginTimeout(int timeout)
|
void |
setLogWriter(PrintWriter pw)
LogWriter methods are unsupported. |
void |
setPassword(String password)
Set the JDBC password to use for accessing the DriverManager. |
void |
setUrl(String url)
Set the JDBC URL to use for accessing the DriverManager. |
void |
setUsername(String username)
Set the JDBC username to use for accessing the DriverManager. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DriverManagerDataSource()
public DriverManagerDataSource(String driverClassName,
String url,
String username,
String password)
throws SQLException
driverClassName - the JDBC driver class nameurl - the JDBC URL to use for accessing the DriverManagerusername - the JDBC username to use for accessing the DriverManagerpassword - the JDBC password to use for accessing the DriverManager
SQLExceptionDriverManager.getConnection(String, String, String)
public DriverManagerDataSource(String url,
String username,
String password)
throws SQLException
url - the JDBC URL to use for accessing the DriverManagerusername - the JDBC username to use for accessing the DriverManagerpassword - the JDBC password to use for accessing the DriverManager
SQLExceptionDriverManager.getConnection(String, String, String)
public DriverManagerDataSource(String url)
throws SQLException
url - the JDBC URL to use for accessing the DriverManager
SQLExceptionDriverManager.getConnection(String)| Method Detail |
|---|
public void setDriverClassName(String driverClassName)
throws SQLException
Alternatively, consider initializing the JDBC driver yourself before instantiating this DataSource.
SQLExceptionClass.forName(String),
DriverManager.registerDriver(java.sql.Driver)public String getDriverClassName()
public void setUrl(String url)
DriverManager.getConnection(String, String, String)public String getUrl()
public void setUsername(String username)
DriverManager.getConnection(String, String, String)public String getUsername()
public void setPassword(String password)
DriverManager.getConnection(String, String, String)public String getPassword()
public void setConnectionProperties(Properties connectionProperties)
Can also contain "user" and "password" properties. However, any "username" and "password" bean properties specified on this DataSource will override the respective connection properties.
DriverManager.getConnection(String, java.util.Properties)public Properties getConnectionProperties()
public Connection getConnection()
throws SQLException
getConnectionFromDriverManager,
using the default username and password of this DataSource.
getConnection in interface DataSourceSQLExceptiongetConnectionFromDriverManager()
public Connection getConnection(String username,
String password)
throws SQLException
getConnectionFromDriverManager,
using the given username and password.
getConnection in interface DataSourceSQLExceptiongetConnectionFromDriverManager(String, String)
protected Connection getConnectionFromDriverManager()
throws SQLException
SQLExceptiongetConnectionFromDriverManager(String, String)
protected Connection getConnectionFromDriverManager(String username,
String password)
throws SQLException
SQLExceptiongetConnectionFromDriverManager(String, java.util.Properties)
protected Connection getConnectionFromDriverManager(String url,
Properties props)
throws SQLException
SQLExceptionDriverManager.getConnection(String, java.util.Properties)
public int getLoginTimeout()
throws SQLException
getLoginTimeout in interface DataSourceSQLException
public void setLoginTimeout(int timeout)
throws SQLException
setLoginTimeout in interface DataSourceSQLExceptionpublic PrintWriter getLogWriter()
getLogWriter in interface DataSource
public void setLogWriter(PrintWriter pw)
throws SQLException
setLogWriter in interface DataSourceSQLExceptionpublic static ClassLoader getDefaultClassLoader()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||