|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.db.util.DataSourceProxy
public class DataSourceProxy
This class is a datasource wrapper for other datasources or simple connections. It allows to pass simple connection information such as url, userid, password as a datasource to other objects that require a javax.sql.DataSource rather than java.sql.Connection as input. In addition the wrapping of other datasource objects plus their associated userid/password data is supported. That allows to pass around just one object that can be asked to return a connection via getConnection().
Constructor Summary | |
---|---|
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. |
Method Summary | ||
---|---|---|
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 |
|
|
unwrap(java.lang.Class<T> iface)
Always throws SQLException, becaus eno interfaces are supported. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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)
Method Detail |
---|
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)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |