You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Nikesh, Kishlay" <ki...@fidelity.co.in> on 2006/07/25 06:24:53 UTC

Setting Client identity in Connection Object

Hi,

We need to pass in the Client credentials(identity) along with
connection object. We are fetching connections through the RAD
configured data source. Our application uses spring/iBatis in middleware
and database as Oracle 10g.
Does anyone have any ideas on how to achieve this ? I am aware that In
the OracleConnection class there's a method setClientIdentifier which
does the required job. Since we are using Websphere6.0 configured data
source, I am unable to get an object of type OracleConnection. I tried
type-casting, but unfortunately it did not work ! 

import java.sql.Connection;
import oracle.jdbc.driver.OracleConnection;

SqlMapClient sqlMap = getSqlMapClient();
Connection conn = sqlMap.getDataSource().getConnection();
OracleConnection oconn = (OracleConnection)conn;
oconn.setClientIdentifier("user1");
sqlMap.setUserConnection(oconn);

// Use this loaded sqlMap object for query execution now

Another issue is that since we might not be transactions so how can this
be ensured that the Oracle Connection object being picked up from
connection pool for a particular query execution is not allocated or,
exchanged with another connection object during the course of the query
execution ? Its very important for us to retain the same connection
object throughout the lifecycle of the query/stored proc execution.

Thanks in advance,
Nikesh