public abstract class

AbstractDriverBasedDataSource

extends AbstractDataSource
java.lang.Object
   ↳ org.springframework.jdbc.datasource.AbstractDataSource
     ↳ org.springframework.jdbc.datasource.AbstractDriverBasedDataSource
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Abstract base class for JDBC javax.sql.DataSource implementations that operate on a JDBC java.sql.Driver.

Summary

[Expand]
Inherited Fields
From class org.springframework.jdbc.datasource.AbstractDataSource
Public Constructors
AbstractDriverBasedDataSource()
Public Methods
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.
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 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 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 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.
Protected Methods
abstract Connection getConnectionFromDriver(Properties props)
Obtain a Connection using the given properties.
Connection getConnectionFromDriver(String username, String password)
Build properties for the Driver, including the given username and password (if any), and obtain a corresponding Connection.
[Expand]
Inherited Methods
From class org.springframework.jdbc.datasource.AbstractDataSource
From class java.lang.Object
From interface java.sql.Wrapper
From interface javax.sql.CommonDataSource
From interface javax.sql.DataSource

Public Constructors

public AbstractDriverBasedDataSource ()

Public Methods

public Connection getConnection ()

This implementation delegates to getConnectionFromDriver, using the default username and password of this DataSource.

Throws
SQLException

public Connection getConnection (String username, String password)

This implementation delegates to getConnectionFromDriver, using the given username and password.

Throws
SQLException

public Properties getConnectionProperties ()

Return the connection properties to be passed to the Driver, if any.

public String getPassword ()

Return the JDBC password to use for connecting through the Driver.

public String getUrl ()

Return the JDBC URL to use for connecting through the Driver.

public String getUsername ()

Return the JDBC username to use for connecting through the Driver.

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.

public void setPassword (String password)

Set the JDBC password to use for connecting through the Driver.

public void setUrl (String url)

Set the JDBC URL to use for connecting through the Driver.

public void setUsername (String username)

Set the JDBC username to use for connecting through the Driver.

Protected Methods

protected abstract Connection getConnectionFromDriver (Properties props)

Obtain 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

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.

Parameters
username the name of the user
password the password to use
Returns
  • the obtained Connection
Throws
SQLException in case of failure