public abstract class AbstractDriverBasedDataSource extends AbstractDataSource
DataSource
implementations
that operate on a JDBC Driver
.SimpleDriverDataSource
,
DriverManagerDataSource
logger
Constructor and Description |
---|
AbstractDriverBasedDataSource() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCatalog()
Return the database catalog to be applied to each Connection, if any.
|
java.sql.Connection |
getConnection()
This implementation delegates to
getConnectionFromDriver ,
using the default username and password of this DataSource. |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password)
This implementation delegates to
getConnectionFromDriver ,
using the given username and password. |
protected abstract java.sql.Connection |
getConnectionFromDriver(java.util.Properties props)
Obtain a Connection using the given properties.
|
protected java.sql.Connection |
getConnectionFromDriver(java.lang.String username,
java.lang.String password)
Build properties for the Driver, including the given username and password (if any),
and obtain a corresponding Connection.
|
java.util.Properties |
getConnectionProperties()
Return the connection properties to be passed to the Driver, if any.
|
java.lang.String |
getPassword()
Return the JDBC password to use for connecting through the Driver.
|
java.lang.String |
getSchema()
Return the database schema to be applied to each Connection, if any.
|
java.lang.String |
getUrl()
Return the JDBC URL to use for connecting through the Driver.
|
java.lang.String |
getUsername()
Return the JDBC username to use for connecting through the Driver.
|
void |
setCatalog(java.lang.String catalog)
Specify a database catalog to be applied to each Connection.
|
void |
setConnectionProperties(java.util.Properties connectionProperties)
Specify arbitrary connection properties as key/value pairs,
to be passed to the Driver.
|
void |
setPassword(java.lang.String password)
Set the JDBC password to use for connecting through the Driver.
|
void |
setSchema(java.lang.String schema)
Specify a database schema to be applied to each Connection.
|
void |
setUrl(java.lang.String url)
Set the JDBC URL to use for connecting through the Driver.
|
void |
setUsername(java.lang.String username)
Set the JDBC username to use for connecting through the Driver.
|
getLoginTimeout, getLogWriter, getParentLogger, isWrapperFor, setLoginTimeout, setLogWriter, unwrap
public void setUrl(@Nullable java.lang.String url)
Driver.connect(String, java.util.Properties)
@Nullable public java.lang.String getUrl()
public void setUsername(@Nullable java.lang.String username)
Driver.connect(String, java.util.Properties)
@Nullable public java.lang.String getUsername()
public void setPassword(@Nullable java.lang.String password)
Driver.connect(String, java.util.Properties)
@Nullable public java.lang.String getPassword()
public void setCatalog(@Nullable java.lang.String catalog)
Connection.setCatalog(java.lang.String)
@Nullable public java.lang.String getCatalog()
public void setSchema(@Nullable java.lang.String schema)
Connection.setSchema(java.lang.String)
@Nullable public java.lang.String getSchema()
public void setConnectionProperties(@Nullable java.util.Properties connectionProperties)
Can also contain "user" and "password" properties. However, any "username" and "password" bean properties specified on this DataSource will override the corresponding connection properties.
Driver.connect(String, java.util.Properties)
@Nullable public java.util.Properties getConnectionProperties()
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnectionFromDriver
,
using the default username and password of this DataSource.java.sql.SQLException
getConnectionFromDriver(String, String)
,
setUsername(java.lang.String)
,
setPassword(java.lang.String)
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnectionFromDriver
,
using the given username and password.java.sql.SQLException
getConnectionFromDriver(String, String)
protected java.sql.Connection getConnectionFromDriver(@Nullable java.lang.String username, @Nullable java.lang.String password) throws java.sql.SQLException
username
- the name of the userpassword
- the password to usejava.sql.SQLException
- in case of failureDriver.connect(String, java.util.Properties)
protected abstract java.sql.Connection getConnectionFromDriver(java.util.Properties props) throws java.sql.SQLException
Template method to be implemented by subclasses.
props
- the merged connection propertiesjava.sql.SQLException
- in case of failure