com.ibm.websphere.rsadapter
Class JdbcAccessorImpl

java.lang.Object
  |
  +--com.ibm.websphere.rsadapter.JdbcAccessorImpl
All Implemented Interfaces:
WSNativeConnectionAccessor

public class JdbcAccessorImpl
extends java.lang.Object
implements WSNativeConnectionAccessor

This class provides a conduit for the WebSphere ResourceAdapter CCI function to access the Native Connection. All Native Connection accesses are funneled through the methods on this object.

This is the 'Generic' JdbcAccessor, for accessing non-WebSphere-specific Native Connections.

A DataSource is passed to this object on the constructor. The getConnection() methods use the DataSource to create new Native Connections. The Native Connections are stored in the CCI Connection objects, and passed back to this object when a Native Connection method needs to be invoked.


Constructor Summary
JdbcAccessorImpl()
           
JdbcAccessorImpl(javax.sql.DataSource datasource)
          This constructor takes as an input parameter a Datasource.
 
Method Summary
 void clearWarnings(java.lang.Object nativeConnection, WSInteractionSpec interactionSpec)
          This method clears all the warnings for an Interaction associated with the Native Connection.
 void close(java.lang.Object nativeConnection)
          This method initiates a close of the connection.
 java.lang.Object getConnection()
          This method gets a Native Connection.
 java.lang.Object getConnection(WSCciConnectionSpec connectionSpec)
          This method gets a Native Connection.
 javax.resource.cci.ConnectionMetaData getMetaData(java.lang.Object nativeConnection)
          This method gets the information on the underlying database instance represented through an active connection.
 javax.resource.cci.ResultSetInfo getResultSetInfo(java.lang.Object nativeConnection)
          This method returns an object from which information on the ResultSet functionality can be determined.
 javax.resource.cci.ResourceWarning getWarnings(java.lang.Object nativeConnection, WSInteractionSpec interactionSpec)
          This method returns the first ResourceWarning of the chain of warnings for an Interaction associated with the Native Connection.
 boolean isClosed(java.lang.Object nativeConnection)
          This method checks if the native connection is closed.
 void localTransactionBegin(java.lang.Object nativeConnection)
          This method initiates a local transaction begin().
 void localTransactionCommit(java.lang.Object nativeConnection)
          This method initiates a local transaction commit().
 void localTransactionRollback(java.lang.Object nativeConnection)
          This method initiates a local transaction rollback().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcAccessorImpl

public JdbcAccessorImpl()

JdbcAccessorImpl

public JdbcAccessorImpl(javax.sql.DataSource datasource)
This constructor takes as an input parameter a Datasource. The getConnection() methods use the DataSource to create 'native' Connections.

The parameter is required -- NullPointerExceptions may occur if it is null.

Parameters:
datasource - - a javax.sql.DataSource
Method Detail

getConnection

public java.lang.Object getConnection(WSCciConnectionSpec connectionSpec)
                               throws javax.resource.ResourceException
This method gets a Native Connection. A component should use the getConnection variant with com.ibm.websphere.rsadapter.WSConnectionSpec parameter if it needs to pass any resource adapter specific security information and connection parameters. In the component-managed sign-on case, an application component passes security information (example: username, password) through the ConnectionSpec instance.

It is important to note that the properties passed through the getConnection method should be client-specific (example: username, password, language) and not related to the configuration of a target database instance (example: port number, server name). The ManagedConnectionFactory instance is configured with the complete set of properties required for the creation of a connection to a database instance.

Specified by:
getConnection in interface WSNativeConnectionAccessor
Parameters:
connectionSpec - - Connection parameters and security information specified as a com.ibm.websphere.rsadapter.WSConnectionSpec instance
Returns:
a Native Connection instance
Throws:
javax.resource.ResourceException - - Failed to get a connection instance. Examples of error cases are:
  • Invalid specification of input parameters
  • Invalid configuration of ManagedConnectionFactory-- example: invalid server name
  • Application server-internal error--example: connection pool related error
  • Communication error
  • EIS-specific error--example: database not active
  • Resource adapter-internal error
  • Security related error; example: invalid user
  • Failure to allocate system resources

getConnection

public java.lang.Object getConnection()
                               throws javax.resource.ResourceException
This method gets a Native Connection. This getConnection variant should be used when a component wants the container to manage EIS sign-on. This case is termed container-managed sign-on. The component does not pass any security information.

Specified by:
getConnection in interface WSNativeConnectionAccessor
Returns:
a Native Connection instance
Throws:
javax.resource.ResourceException - - Failed to get a connection instance. Examples of error cases are:
  • Invalid configuration of ManagedConnectionFactory-- example: invalid server name
  • Application server-internal error--example: connection pool related error
  • Communication error
  • EIS-specific error--example: EIS not active
  • Resource adapter-internal error
  • Security related error; example: invalid user
  • Failure to allocate system resources

close

public void close(java.lang.Object nativeConnection)
           throws javax.resource.ResourceException
This method initiates a close of the connection. A client should not use a closed connection.

Specified by:
close in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection on which to do the close()
Throws:
javax.resource.ResourceException - - Exception thrown if close on a connection fails.

Any invalid connection close invocation--example, calling close on a connection that is already closed--should also throw this exception.


isClosed

public boolean isClosed(java.lang.Object nativeConnection)
                 throws javax.resource.ResourceException
This method checks if the native connection is closed.

Specified by:
isClosed in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection on which to do isClosed()
Throws:
javax.resource.ResourceException - - Exception thrown if there is a problem checking if the connection is closed.

clearWarnings

public void clearWarnings(java.lang.Object nativeConnection,
                          WSInteractionSpec interactionSpec)
                   throws javax.resource.ResourceException
This method clears all the warnings for an Interaction associated with the Native Connection.

Specified by:
clearWarnings in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection associated with the Interaction
interactionSpec - - the WSInteractionSpec associated with the Interaction
Throws:
javax.resource.ResourceException - - Failed to clear ResourceWarnings

getWarnings

public javax.resource.cci.ResourceWarning getWarnings(java.lang.Object nativeConnection,
                                                      WSInteractionSpec interactionSpec)
                                               throws javax.resource.ResourceException
This method returns the first ResourceWarning of the chain of warnings for an Interaction associated with the Native Connection.

Specified by:
getWarnings in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection associated with the Interaction
interactionSpec - - the WSInteractionSpec associated with the Interaction
Returns:
- the ResourceWarning at top of the warning chain or null if there are none
Throws:
javax.resource.ResourceException - - Failed to get ResourceWarnings

localTransactionBegin

public void localTransactionBegin(java.lang.Object nativeConnection)
                           throws javax.resource.ResourceException
This method initiates a local transaction begin().

Specified by:
localTransactionBegin in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection on which to do the begin()
Throws:
javax.resource.ResourceException - - Failed to begin a local transaction

localTransactionCommit

public void localTransactionCommit(java.lang.Object nativeConnection)
                            throws javax.resource.ResourceException
This method initiates a local transaction commit().

Specified by:
localTransactionCommit in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection on which to do the commit()
Throws:
javax.resource.ResourceException - - Failed to commit a local transaction

localTransactionRollback

public void localTransactionRollback(java.lang.Object nativeConnection)
                              throws javax.resource.ResourceException
This method initiates a local transaction rollback().

Specified by:
localTransactionRollback in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection on which to do the rollback()
Throws:
javax.resource.ResourceException - - Failed to roll back a local transaction

getMetaData

public javax.resource.cci.ConnectionMetaData getMetaData(java.lang.Object nativeConnection)
                                                  throws javax.resource.ResourceException
This method gets the information on the underlying database instance represented through an active connection.

Specified by:
getMetaData in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection from which to get the MetaData
Returns:
a javax.resource.cci.ConnectionMetaData instance representing information about the database instance
Throws:
javax.resource.ResourceException - - Failed to get information about the connected database instance. Error can be resource adapter-internal, EIS-specific or communication related.

getResultSetInfo

public javax.resource.cci.ResultSetInfo getResultSetInfo(java.lang.Object nativeConnection)
                                                  throws javax.resource.ResourceException
This method returns an object from which information on the ResultSet functionality can be determined.

Specified by:
getResultSetInfo in interface WSNativeConnectionAccessor
Parameters:
nativeConnection - - the Connection used by the returned object to get the ResultSetInfo
Returns:
a javax.resource.cci.ResultSetInfo instance
Throws:
javax.resource.ResourceException - - Failed to get ResultSet related information


 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.