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 |
---|---|
String |
getCatalog()
Return the database catalog to be applied to each Connection, if any.
|
Connection |
getConnection()
This implementation delegates to
getConnectionFromDriver ,
using the default username and password of this DataSource. |
Connection |
getConnection(String username,
String password)
This implementation delegates to
getConnectionFromDriver ,
using the given username and password. |
protected abstract Connection |
getConnectionFromDriver(Properties props)
Obtain a Connection using the given properties.
|
protected Connection |
getConnectionFromDriver(String username,
String password)
Build properties for the Driver, including the given username and password (if any),
and obtain a corresponding Connection.
|
Properties |
getConnectionProperties()
Return the connection properties to be passed to the Driver, if any.
|
String |
getPassword()
Return the JDBC password to use for connecting through the Driver.
|
String |
getSchema()
Return the database schema to be applied to each Connection, if any.
|
String |
getUrl()
Return the JDBC URL to use for connecting through the Driver.
|
String |
getUsername()
Return the JDBC username to use for connecting through the Driver.
|
void |
setCatalog(String catalog)
Specify a database catalog to be applied to each Connection.
|
void |
setConnectionProperties(Properties connectionProperties)
Specify arbitrary connection properties as key/value pairs,
to be passed to the Driver.
|
void |
setPassword(String password)
Set the JDBC password to use for connecting through the Driver.
|
void |
setSchema(String schema)
Specify a database schema to be applied to each Connection.
|
void |
setUrl(String url)
Set the JDBC URL to use for connecting through the Driver.
|
void |
setUsername(String username)
Set the JDBC username to use for connecting through the Driver.
|
getLoginTimeout, getLogWriter, getParentLogger, isWrapperFor, setLoginTimeout, setLogWriter, unwrap
public void setUrl(@Nullable String url)
@Nullable public String getUrl()
public void setUsername(@Nullable String username)
@Nullable public String getUsername()
public void setPassword(@Nullable String password)
@Nullable public String getPassword()
public void setCatalog(@Nullable String catalog)
Connection.setCatalog(java.lang.String)
@Nullable public String getCatalog()
public void setSchema(@Nullable String schema)
Connection.setSchema(java.lang.String)
@Nullable public String getSchema()
public void setConnectionProperties(@Nullable 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.
@Nullable public Properties getConnectionProperties()
public Connection getConnection() throws SQLException
getConnectionFromDriver
,
using the default username and password of this DataSource.public Connection getConnection(String username, String password) throws SQLException
getConnectionFromDriver
,
using the given username and password.SQLException
getConnectionFromDriver(String, String)
protected Connection getConnectionFromDriver(@Nullable String username, @Nullable String password) throws SQLException
username
- the name of the userpassword
- the password to useSQLException
- in case of failureDriver.connect(String, java.util.Properties)
protected abstract Connection getConnectionFromDriver(Properties props) throws SQLException
Template method to be implemented by subclasses.
props
- the merged connection propertiesSQLException
- in case of failure