public class DataSourceProxy
extends java.lang.Object
implements javax.sql.DataSource
Constructor and Description |
---|
DataSourceProxy(java.sql.Connection conn)
Initialize the new instance with a ready-to-use connection.
|
DataSourceProxy(javax.sql.DataSource dataSource) |
DataSourceProxy(javax.sql.DataSource dataSource,
java.lang.String username,
java.lang.String password) |
DataSourceProxy(java.lang.String url)
Initialize the new instance with an URL for the database connection.
|
DataSourceProxy(java.lang.String url,
java.lang.String username,
java.lang.String password)
Initialize the new instance with all necessary connection information.
|
Modifier and Type | Method and Description |
---|---|
java.sql.Connection |
getConnection()
Attempt to establish a database connection
|
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password)
Attempt to establish a database connection
|
protected javax.sql.DataSource |
getDataSource() |
protected java.sql.Connection |
getDataSourceConnection()
Attempt to establish a database connection using the wrapped datasource
|
protected java.sql.Connection |
getDbConnection() |
java.lang.String |
getDbPassword() |
java.lang.String |
getDbUrl() |
java.lang.String |
getDbUserid() |
int |
getLoginTimeout()
Returns the maximum time in seconds that this
data source can wait while attempting to connect
to a database.
|
java.io.PrintWriter |
getLogWriter()
Returns the log writer for this data source
|
protected boolean |
hasConnection() |
protected boolean |
hasDataSource() |
boolean |
isWrapperFor(java.lang.Class<?> iface)
Always returns false.
|
protected void |
setDataSource(javax.sql.DataSource newValue) |
protected void |
setDbConnection(java.sql.Connection newValue) |
void |
setDbPassword(java.lang.String password) |
void |
setDbUrl(java.lang.String url) |
void |
setDbUserid(java.lang.String userId) |
void |
setDriverClassName(java.lang.String driverClassName)
Creates an instance of the given class name in order to register the
database driver.
|
void |
setLoginTimeout(int timeout)
Sets the maximum time in seconds that this
data source can wait while attempting to connect
to a database.
|
void |
setLogWriter(java.io.PrintWriter writer)
Sets the log writer for this data source
|
<T> T |
unwrap(java.lang.Class<T> iface)
Always throws SQLException, becaus eno interfaces are supported.
|
public DataSourceProxy(java.sql.Connection conn)
public DataSourceProxy(java.lang.String url, java.lang.String username, java.lang.String password)
public DataSourceProxy(java.lang.String url)
public DataSourceProxy(javax.sql.DataSource dataSource, java.lang.String username, java.lang.String password)
public DataSourceProxy(javax.sql.DataSource dataSource)
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
public java.lang.String getDbUrl()
public void setDbUrl(java.lang.String url)
public java.lang.String getDbUserid()
public void setDbUserid(java.lang.String userId)
public java.lang.String getDbPassword()
public void setDbPassword(java.lang.String password)
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLoginTimeout(int timeout) throws java.sql.SQLException
setLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter writer) throws java.sql.SQLException
setLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setDriverClassName(java.lang.String driverClassName)
protected boolean hasDataSource()
protected boolean hasConnection()
protected java.sql.Connection getDataSourceConnection() throws java.sql.SQLException
java.sql.SQLException
protected java.sql.Connection getDbConnection()
protected void setDbConnection(java.sql.Connection newValue)
protected javax.sql.DataSource getDataSource()
protected void setDataSource(javax.sql.DataSource newValue)