|
SafeJDBC v2.00 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.safejdbc.javax.sql.SafeDataSource
public class SafeDataSource
Implementation of that
allows the wrapping of native "clear" DataSourceDataSource that references an
application database.
Notes :
getInstance(DataSource, DataSource) method.SafeDataSourceFactory
in an EJB/J2EE environment.
SafeDataSourceFactory| Method Summary | ||
|---|---|---|
Connection |
getConnection()
Returns a Cipher Connection to the database. |
|
Connection |
getConnection(String username,
String password)
Returns a Cipher Connection to the database. |
|
static SafeDataSource |
getInstance(DataSource dsApplication,
DataSource dsSafeJdbcCatalog)
Creates and configures a SafeDataSource instance that wraps an application
. |
|
int |
getLoginTimeout()
Returns the login timeout (in seconds) for connecting to the database. |
|
PrintWriter |
getLogWriter()
Returns the log writer being used by this data source. |
|
boolean |
isWrapperFor(Class<?> iface)
Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. |
|
void |
setLoginTimeout(int loginTimeout)
Sets the login timeout (in seconds) for connecting to the database. |
|
void |
setLogWriter(PrintWriter logWriter)
Sets the log writer being used by this data source. |
|
|
unwrap(Class<T> iface)
Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static SafeDataSource getInstance(DataSource dsApplication,
DataSource dsSafeJdbcCatalog)
SafeDataSource instance that wraps an application
DataSource.
getConnection() will return a Cipher Connection that wraps
an application Connection extracted from the connection pool.
InitialContext initCtx = new InitialContext();
// Get a DataSource for connection to the application database
DataSource dsApplication
= (DataSource) initCtx.lookup("java:/comp/env/jdbc/application");
// Get a DataSource for connection to the SafeJdbc Catalog database
DataSource dsSafejdbcCat
= (DataSource) initCtx.lookup("java:/comp/env/jdbc/safejdbc_catalog");
// This will wrap the two previous DataSources
DataSource dsSafe = SafeDataSource.getInstance(dsApplication, dsSafejdbcCat);
// Ok, create a Cipher Connection.
// If native wrapped driver implements connection pooling,
// this will get a wrapped Connection from the pool
Connection conn = dsSafe.getConnection();
if (conn instanceof CipherConnection)
{
System.out.println("Good! Connection obtained from DataSource is a Cipher Connection!");
}
dsApplication - the DataSource that defines the application database to be
wrappeddsSafeJdbcCatalog - the DataSource that defines the SafeJdbc Catalog database
public Connection getConnection()
throws SQLException
getConnection in interface DataSourceSQLException - if a database access error occurs
public Connection getConnection(String username,
String password)
throws SQLException
getConnection in interface DataSourceusername - Database user on whose behalf the Connection is being madepassword - The database user's password
SQLException - if a database access error occurs
public int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLException - if a database access error occurs
public PrintWriter getLogWriter()
throws SQLException
getLogWriter in interface CommonDataSourceSQLException - if a database access error occurs
public void setLoginTimeout(int loginTimeout)
throws SQLException
setLoginTimeout in interface CommonDataSourceloginTimeout - The new login timeout, or zero for no timeout
SQLException - if a database access error occurs
public void setLogWriter(PrintWriter logWriter)
throws SQLException
setLogWriter in interface CommonDataSourcelogWriter - The new log writer
SQLException - if a database access error occurs
public <T> T unwrap(Class<T> iface)
throws SQLException
unwrap recursively on the wrapped object
or a proxy for that result. If the receiver is not a
wrapper and does not implement the interface, then an SQLException is thrown.
unwrap in interface Wrapperiface - A Class defining an interface that the result must implement.
SQLException - If no object found that implements the interface
public boolean isWrapperFor(Class<?> iface)
throws SQLException
isWrapperFor on the wrapped
object. If this does not implement the interface and is not a wrapper, return false.
This method should be implemented as a low-cost operation compared to unwrap so that
callers can use this method to avoid expensive unwrap calls that may fail. If this method
returns true then calling unwrap with the same argument should succeed.
isWrapperFor in interface Wrapperiface - a Class defining an interface.
SQLException - if an error occurs while determining whether this is a wrapper
for an object with the given interface.
|
SafeJDBC v2.00 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||