类 AbstractDriverBasedDataSource
- java.lang.Object
- org.springframework.jdbc.datasource.AbstractDataSource
- org.springframework.jdbc.datasource.AbstractDriverBasedDataSource
- 所有已实现的接口:
Wrapper
,CommonDataSource
,DataSource
public abstract class AbstractDriverBasedDataSource extends AbstractDataSource
Abstract base class for JDBCDataSource
implementations that operate on a JDBCDriver
.- 从以下版本开始:
- 2.5.5
- 作者:
- Juergen Hoeller
- 另请参阅:
SimpleDriverDataSource
,DriverManagerDataSource
字段概要
从类继承的字段 org.springframework.jdbc.datasource.AbstractDataSource
logger
构造器概要
构造器 构造器 说明 AbstractDriverBasedDataSource()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 String
getCatalog()
Return the database catalog to be applied to each Connection, if any.Connection
getConnection()
This implementation delegates togetConnectionFromDriver
, using the default username and password of this DataSource.Connection
getConnection(String username, String password)
This implementation delegates togetConnectionFromDriver
, using the given username and password.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.protected abstract Connection
getConnectionFromDriver(Properties props)
Obtain a Connection using the given properties.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.从类继承的方法 org.springframework.jdbc.datasource.AbstractDataSource
getLoginTimeout, getLogWriter, getParentLogger, isWrapperFor, setLoginTimeout, setLogWriter, unwrap
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 javax.sql.CommonDataSource
createShardingKeyBuilder
从接口继承的方法 javax.sql.DataSource
createConnectionBuilder
构造器详细资料
AbstractDriverBasedDataSource
public AbstractDriverBasedDataSource()
方法详细资料
setUsername
public void setUsername(String username)
Set the JDBC username to use for connecting through the Driver.
getUsername
public String getUsername()
Return the JDBC username to use for connecting through the Driver.
setPassword
public void setPassword(String password)
Set the JDBC password to use for connecting through the Driver.
getPassword
public String getPassword()
Return the JDBC password to use for connecting through the Driver.
setCatalog
public void setCatalog(String catalog)
Specify a database catalog to be applied to each Connection.- 从以下版本开始:
- 4.3.2
- 另请参阅:
Connection.setCatalog(java.lang.String)
getCatalog
public String getCatalog()
Return the database catalog to be applied to each Connection, if any.- 从以下版本开始:
- 4.3.2
setSchema
public void setSchema(String schema)
Specify a database schema to be applied to each Connection.- 从以下版本开始:
- 4.3.2
- 另请参阅:
Connection.setSchema(java.lang.String)
getSchema
public String getSchema()
Return the database schema to be applied to each Connection, if any.- 从以下版本开始:
- 4.3.2
setConnectionProperties
public void setConnectionProperties(Properties connectionProperties)
Specify arbitrary connection properties as key/value pairs, to be passed to the Driver.Can also contain "user" and "password" properties. However, any "username" and "password" bean properties specified on this DataSource will override the corresponding connection properties.
getConnectionProperties
public Properties getConnectionProperties()
Return the connection properties to be passed to the Driver, if any.
getConnection
public Connection getConnection() throws SQLException
This implementation delegates togetConnectionFromDriver
, using the default username and password of this DataSource.
getConnection
public Connection getConnection(String username, String password) throws SQLException
This implementation delegates togetConnectionFromDriver
, using the given username and password.
getConnectionFromDriver
@UsesJava7 protected Connection getConnectionFromDriver(String username, String password) throws SQLException
Build properties for the Driver, including the given username and password (if any), and obtain a corresponding Connection.- 参数:
username
- the name of the userpassword
- the password to use- 返回:
- the obtained Connection
- 抛出:
SQLException
- in case of failure- 另请参阅:
Driver.connect(String, java.util.Properties)
getConnectionFromDriver
protected abstract Connection getConnectionFromDriver(Properties props) throws SQLException
Obtain a Connection using the given properties.Template method to be implemented by subclasses.
- 参数:
props
- the merged connection properties- 返回:
- the obtained Connection
- 抛出:
SQLException
- in case of failure