IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.services.jdbcservicesinfra
Class JDBCService

java.lang.Object
  extended bycom.ibm.btt.base.Service
      extended bycom.ibm.btt.services.BTTServiceRequester
          extended bycom.ibm.btt.services.PooledServiceRequester
              extended bycom.ibm.btt.services.jdbcservicesinfra.JDBCService
All Implemented Interfaces:
DatabaseConnect, Externalizable, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
JDBCTableService, Journal

public abstract class JDBCService
extends PooledServiceRequester
implements DatabaseConnect

The JDBCService provides the implementation of the DatabaseConnect interface. All JDBC services extend from this class inheriting all methods related to connecting to a database.

See Also:
Serialized Form

Field Summary
protected  java.sql.PreparedStatement addPstmt
          Keeps the preparedStatement attribute value.
protected  java.lang.String addString
          Keeps the SQL sentence used when adding a records.
protected  boolean autoCommit
          Keeps the commit criteria the JDBCTable service must follow.
protected  Hashtable connectionProperties
          Keeps the details of the connection being used by the service.
protected  java.sql.Connection databaseConnection
          Each JDBCService instance must have its own connection to the database so that when the application commits or rolls back, only the changes made by that application are affected.
protected  java.lang.String databaseURL
          The database URL.
protected  java.lang.String dataSourceName
          Keeps the name of the DataSource factory object in the naming system.
protected  java.sql.DatabaseMetaData metaData
          Each JDBCService instance must have its own connection to the database so that when the application commits or rolls back, only the changes made by that application are affected.
protected  java.lang.String password
          The user password to connect to the database.
protected  java.lang.String poolName
          Keeps the name of the pool when using the connection pooling for WebSphere 2.0.
protected  java.lang.String sharedConnection
          Keeps the alias of the database connection that the service instance would like to share with another service.
protected static int STMT_POOL_SIZE_DEFAULT
          Default number of elements of the array.
protected  java.util.ArrayList stmtPool
          Array to keep different statements
protected  int stmtPoolSize
          Number of elements of the array.
protected  java.lang.String updateString
          Keeps the SQL sentence used when updating all columns of a record.
protected  java.lang.String user
          The user identification to connect to the database.
protected  boolean waitRetry
          Keeps the waitRetry attribute used by the WebSphere 2.0 connection pooling.
 
Fields inherited from class com.ibm.btt.services.PooledServiceRequester
poolable, poolId
 
Fields inherited from class com.ibm.btt.services.BTTServiceRequester
COMPID
 
Fields inherited from class com.ibm.btt.base.Service
externalizer, name
 
Constructor Summary
JDBCService()
          * This constructor creates a JDBCService object.
 
Method Summary
 void connect()
          Connects to the Database set in the DataSource definition without userid and password This method can only be used if the connection is requested using a pool of connections implemented as a DataSource with the database URL specified as part of the DataSource definition.
 void connect(java.lang.String aUser, java.lang.String aPassword)
          Connects to the Database set in the DataSource definition using aUser and aPassword.
 void disconnect()
          Closes the Database connection.
 boolean getAutoCommit()
          Returns the autoCommit attribute value.
 java.lang.String getDataSourceName()
          Returns the dataSourceName attribute value.
 java.lang.String getPassword()
          Returns the password attribute value.
 java.lang.String getUser()
          Returns the user attribute value.
 boolean isConnected()
          Returns true if there is a connection to the database or false if there is not.
 boolean isWaitRetry()
          Returns the waitRetry attribute value.
 void setAutoCommit(boolean b)
          Sets the autoCommit attribute.
 void setDataSourceName(java.lang.String newDataSourceName)
          Sets the dataSourceName attribute value to newDataSourceName.
 void setPassword(java.lang.String s)
          Sets the password attribute to the string provided as an argument.
 void setUser(java.lang.String s)
          Sets the user attribute to the string provided as an argument.
 void setWaitRetry(boolean newWaitRetry)
          Sets the waitRetry attribute value to newWaitRetry.
 boolean verifyConnection()
          Checks for the database connection availability by calling the Connection Manager.
 
Methods inherited from class com.ibm.btt.services.PooledServiceRequester
getGrantTime, getPoolable, getPoolable, getPoolId, getServiceID, grantServiceID, initializeFrom, initializeFrom, processRequest, releaseOrphan, releaseOrphan, releasePoolable, releaseServiceRequester, setGrantTime, setPoolId
 
Methods inherited from class com.ibm.btt.services.BTTServiceRequester
getCachingEnabled, getInactiveTimeout, getLastAccess, getServiceInvocation, getServiceType, HashMapToHashtable, newInstance, setCachingEnabled, setInactiveTimeout, setLastAccess, setServiceID, setServiceInvocation, setServiceType
 
Methods inherited from class com.ibm.btt.base.Service
externalizer, getExternalizer, getName, getTagName, readExternal, readExternal, readObject, removeExternal, setExternalizer, setName, terminate, toString, toStrings, toTags, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

databaseConnection

protected java.sql.Connection databaseConnection
Each JDBCService instance must have its own connection to the database so that when the application commits or rolls back, only the changes made by that application are affected.


autoCommit

protected boolean autoCommit
Keeps the commit criteria the JDBCTable service must follow.


databaseURL

protected java.lang.String databaseURL
The database URL. It is only used if the autoConnect attribute is set to true.


user

protected java.lang.String user
The user identification to connect to the database. It is only used if the autoConnect attribute is set to true.


password

protected java.lang.String password
The user password to connect to the database. It is only used if the autoConnect attribute is set to true.


poolName

protected java.lang.String poolName
Keeps the name of the pool when using the connection pooling for WebSphere 2.0.


waitRetry

protected boolean waitRetry
Keeps the waitRetry attribute used by the WebSphere 2.0 connection pooling. If it is 'true', the servlet can wait for a connection to become available if no one is immediately available. If the connection does not become available before the wait period expires, the IBMConnMgrException is thrown. If it is 'false', the exception is thrown immediately.


dataSourceName

protected java.lang.String dataSourceName
Keeps the name of the DataSource factory object in the naming system. This is needed if the application uses any implementation of the JDBC interface for connection pooling.


metaData

protected java.sql.DatabaseMetaData metaData
Each JDBCService instance must have its own connection to the database so that when the application commits or rolls back, only the changes made by that application are affected.


sharedConnection

protected java.lang.String sharedConnection
Keeps the alias of the database connection that the service instance would like to share with another service.


connectionProperties

protected Hashtable connectionProperties
Keeps the details of the connection being used by the service.


addString

protected java.lang.String addString
Keeps the SQL sentence used when adding a records.


updateString

protected java.lang.String updateString
Keeps the SQL sentence used when updating all columns of a record.


addPstmt

protected java.sql.PreparedStatement addPstmt
Keeps the preparedStatement attribute value.


STMT_POOL_SIZE_DEFAULT

protected static final int STMT_POOL_SIZE_DEFAULT
Default number of elements of the array.

See Also:
Constant Field Values

stmtPoolSize

protected int stmtPoolSize
Number of elements of the array.


stmtPool

protected java.util.ArrayList stmtPool
Array to keep different statements

Constructor Detail

JDBCService

public JDBCService()
* This constructor creates a JDBCService object.

Method Detail

connect

public void connect()
             throws DSEInternalErrorException,
                    DSEInvalidRequestException,
                    DSESQLException,
                    DSEObjectNotFoundException,
                    DSEException
Connects to the Database set in the DataSource definition without userid and password This method can only be used if the connection is requested using a pool of connections implemented as a DataSource with the database URL specified as part of the DataSource definition.

Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught
DSEObjectNotFoundException - if the JDBCServicesConnectionManager cannot be found
DSEException - if an exception is thrown when calling the pool of connections manager

connect

public void connect(java.lang.String aUser,
                    java.lang.String aPassword)
             throws DSEInternalErrorException,
                    DSEInvalidRequestException,
                    DSESQLException,
                    DSEObjectNotFoundException,
                    DSEException
Connects to the Database set in the DataSource definition using aUser and aPassword. This method can only be used if the connection is requested using a pool of connections implemented as a DataSource with the database URL specified as part of the DataSource definition.

Specified by:
connect in interface DatabaseConnect
Parameters:
aUser - java.lang.String - the user identification
aPassword - java.lang.String - the user password
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQLException is caught
DSEObjectNotFoundException - if the JDBCServicesConnectionManager cannot be found
DSEException - if an exception is thrown when calling the pool of connections manager

disconnect

public void disconnect()
                throws DSEInvalidRequestException,
                       DSESQLException,
                       DSEException
Closes the Database connection.

Specified by:
disconnect in interface DatabaseConnect
Throws:
DSESQLException - if a SQLException occurs
DSEException - if an exception is thrown when calling the pool of connections manager
DSEInvalidRequestException - if the database connection is null

getAutoCommit

public boolean getAutoCommit()
                      throws DSEException
Returns the autoCommit attribute value.

Returns:
boolean
Throws:
DSEException

getDataSourceName

public java.lang.String getDataSourceName()
                                   throws DSEException
Returns the dataSourceName attribute value.

Specified by:
getDataSourceName in interface DatabaseConnect
Returns:
java.lang.String
Throws:
DSEException

getPassword

public java.lang.String getPassword()
                             throws DSEException
Returns the password attribute value.

Returns:
java.lang.String
Throws:
DSEException

getUser

public java.lang.String getUser()
                         throws DSEException
Returns the user attribute value.

Returns:
java.lang.String
Throws:
DSEException

isConnected

public boolean isConnected()
                    throws DSEInvalidRequestException,
                           DSEInternalErrorException,
                           DSESQLException,
                           DSEObjectNotFoundException,
                           DSEException
Returns true if there is a connection to the database or false if there is not. If the autoConnect attribute has been set to true and a connection to the database does not already exist, this method creates its own connection.

Specified by:
isConnected in interface DatabaseConnect
Returns:
boolean
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught
DSEObjectNotFoundException
DSEException

isWaitRetry

public boolean isWaitRetry()
                    throws DSEException
Returns the waitRetry attribute value.

Specified by:
isWaitRetry in interface DatabaseConnect
Returns:
boolean
Throws:
DSEException

setAutoCommit

public void setAutoCommit(boolean b)
                   throws DSEException
Sets the autoCommit attribute.

Parameters:
b - boolean value
Throws:
DSEException

setDataSourceName

public void setDataSourceName(java.lang.String newDataSourceName)
                       throws DSEException
Sets the dataSourceName attribute value to newDataSourceName.

Specified by:
setDataSourceName in interface DatabaseConnect
Parameters:
newDataSourceName - java.lang.String
Throws:
DSEException

setPassword

public void setPassword(java.lang.String s)
                 throws DSEException
Sets the password attribute to the string provided as an argument.

Parameters:
s - java.lang.String
Throws:
DSEException

setUser

public void setUser(java.lang.String s)
             throws DSEException
Sets the user attribute to the string provided as an argument.

Parameters:
s - java.lang.String
Throws:
DSEException

setWaitRetry

public void setWaitRetry(boolean newWaitRetry)
                  throws DSEException
Sets the waitRetry attribute value to newWaitRetry.

Specified by:
setWaitRetry in interface DatabaseConnect
Parameters:
newWaitRetry - boolean
Throws:
DSEException

verifyConnection

public boolean verifyConnection()
                         throws DSESQLException,
                                DSEException
Checks for the database connection availability by calling the Connection Manager.

Returns:
boolean
Throws:
DSESQLException - if an SQLException is caught
DSEException - if an exception is thrown when calling the pool of connections

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005