Class AbstractDriverBasedDataSource
java.lang.Object
org.springframework.jdbc.datasource.AbstractDataSource
org.springframework.jdbc.datasource.AbstractDriverBasedDataSource
- All Implemented Interfaces:
- Wrapper,- CommonDataSource,- DataSource
- Direct Known Subclasses:
- DriverManagerDataSource,- SimpleDriverDataSource
Abstract base class for JDBC 
DataSource implementations
 that operate on a JDBC Driver.- Since:
- 2.5.5
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class org.springframework.jdbc.datasource.AbstractDataSourcelogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturn the database catalog to be applied to each Connection, if any.This implementation delegates togetConnectionFromDriver, using the default username and password of this DataSource.getConnection(String username, String password) This implementation delegates togetConnectionFromDriver, using the given username and password.protected ConnectiongetConnectionFromDriver(@Nullable String username, @Nullable String password) Build properties for the Driver, including the given username and password (if any), and obtain a corresponding Connection.protected abstract ConnectionObtain a Connection using the given properties.Return the connection properties to be passed to the Driver, if any.Return the JDBC password to use for connecting through the Driver.Return the database schema to be applied to each Connection, if any.getUrl()Return the JDBC URL to use for connecting through the Driver.Return the JDBC username to use for connecting through the Driver.voidsetCatalog(@Nullable String catalog) Specify a database catalog to be applied to each Connection.voidsetConnectionProperties(@Nullable Properties connectionProperties) Specify arbitrary connection properties as key/value pairs, to be passed to the Driver.voidsetPassword(@Nullable String password) Set the JDBC password to use for connecting through the Driver.voidSpecify a database schema to be applied to each Connection.voidSet the JDBC URL to use for connecting through the Driver.voidsetUsername(@Nullable String username) Set the JDBC username to use for connecting through the Driver.Methods inherited from class org.springframework.jdbc.datasource.AbstractDataSourcegetLoginTimeout, getLogWriter, getParentLogger, isWrapperFor, setLoginTimeout, setLogWriter, unwrapMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSourcecreateShardingKeyBuilderMethods inherited from interface javax.sql.DataSourcecreateConnectionBuilder
- 
Constructor Details- 
AbstractDriverBasedDataSourcepublic AbstractDriverBasedDataSource()
 
- 
- 
Method Details- 
setUrl
- 
getUrl
- 
setUsername
- 
getUsername
- 
setPassword
- 
getPassword
- 
setCatalog
- 
getCatalog
- 
setSchema
- 
getSchema
- 
setConnectionPropertiesSpecify 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. - See Also:
 
- 
getConnectionPropertiesReturn the connection properties to be passed to the Driver, if any.
- 
getConnectionThis implementation delegates togetConnectionFromDriver, using the default username and password of this DataSource.- Throws:
- SQLException
- See Also:
 
- 
getConnectionThis implementation delegates togetConnectionFromDriver, using the given username and password.- Throws:
- SQLException
- See Also:
 
- 
getConnectionFromDriverprotected Connection getConnectionFromDriver(@Nullable String username, @Nullable String password) throws SQLException Build properties for the Driver, including the given username and password (if any), and obtain a corresponding Connection.- Parameters:
- username- the name of the user
- password- the password to use
- Returns:
- the obtained Connection
- Throws:
- SQLException- in case of failure
- See Also:
 
- 
getConnectionFromDriverObtain a Connection using the given properties.Template method to be implemented by subclasses. - Parameters:
- props- the merged connection properties
- Returns:
- the obtained Connection
- Throws:
- SQLException- in case of failure
 
 
-