com.bankframe.ei.txnhandler.hostcache
Class DataSourceWrapper

java.lang.Object
  extended bycom.bankframe.ei.txnhandler.hostcache.Retry
      extended bycom.bankframe.ei.txnhandler.hostcache.DataSourceWrapper

public class DataSourceWrapper
extends Retry

This class is a wrapper class used for connecting to a database. Depending on the Application servers differnet methods are required to connect to the database.


Constructor Summary
DataSourceWrapper(java.util.Hashtable env, java.lang.String dataSourceName)
          Creates new DataSourceWrapper
 
Method Summary
 void close()
          This closes the member's connection.
 java.sql.Statement createStatement()
          This method creates a statement from the DataSource.
static java.sql.Connection getConnection(java.util.Hashtable env, java.lang.String dataSourceName)
          A static method for getting a JDBC connection from a DataSource.
 java.sql.DatabaseMetaData getMetaData()
          This method gets the connection's meta data.
 void open()
          This method opens the connection.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          This method creates a prepared statement.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          This method creates a prepared statement.
 boolean runRetry()
          This is run on every retry.
 
Methods inherited from class com.bankframe.ei.txnhandler.hostcache.Retry
retry
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceWrapper

public DataSourceWrapper(java.util.Hashtable env,
                         java.lang.String dataSourceName)
                  throws java.sql.SQLException,
                         javax.naming.NamingException
Creates new DataSourceWrapper

Parameters:
env - The JNDI env.
dataSourceName - The DataSource JNDI name.
Throws:
java.sql.SQLException - If an error occurs during a database operation.
javax.naming.NamingException - If there was a problem looking up the DataSource.
Method Detail

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException,
                                          javax.naming.NamingException
This method creates a statement from the DataSource.

Returns:
The created statement.
Throws:
java.sql.SQLException - If an exception occurred in getting the statement.
javax.naming.NamingException - If an exception occurred in opening the connection.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException,
                                                   javax.naming.NamingException
This method creates a prepared statement.

Parameters:
sql - The statement to compile.
Returns:
The compiled prepared statement.
Throws:
java.sql.SQLException - If an exception occurred in getting the statement.
javax.naming.NamingException - If an error occurred in finding the DataSource in the JNDI tree.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException,
                                                   javax.naming.NamingException
This method creates a prepared statement.

Parameters:
sql - The SQL to compile.
resultSetType - Please see the Connection.prepareStatement() javadoc for more on this argument.
resultSetConcurrency - Please see the Connection.prepareStatement() javadoc for more on this argument.
Returns:
The compiled prepared statement.
Throws:
java.sql.SQLException - If an exception occurred in getting the statement.
javax.naming.NamingException - If an error occurred in finding the DataSource in the JNDI tree.

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws javax.naming.NamingException,
                                             java.sql.SQLException
This method gets the connection's meta data.

Returns:
The connection's meta data.
Throws:
javax.naming.NamingException - If an error occurred in finding the DataSource in the JNDI tree.
java.sql.SQLException - If an exception occurred in getting the meta data.

open

public void open()
          throws javax.naming.NamingException,
                 java.sql.SQLException
This method opens the connection.

Throws:
javax.naming.NamingException - If an error occurred in finding the DataSource in the JNDI tree.
java.sql.SQLException - If an error occurred in opening the connection.

runRetry

public boolean runRetry()
This is run on every retry.

Specified by:
runRetry in class Retry
Returns:
Returns the success of the retry.

getConnection

public static java.sql.Connection getConnection(java.util.Hashtable env,
                                                java.lang.String dataSourceName)
                                         throws javax.naming.NamingException,
                                                java.sql.SQLException
A static method for getting a JDBC connection from a DataSource.

Parameters:
env - The JNDI environment for the InitialContext. If this is null it is assumed that new InitialContext() will work.
dataSourceName - The JNDI name of the DataSource.
Returns:
Returns the connection.
Throws:
javax.naming.NamingException - If a error occurred in looking up the DataSource name.
java.sql.SQLException - If an error occurred in getting the connection.

close

public void close()
           throws java.sql.SQLException
This closes the member's connection.

Throws:
java.sql.SQLException - If an error occurred in opening the connection.


Copyright © 2004 Siebel Systems, Inc. All rights reserved.