public ConnectionResults getPooledConnection ( final CommonDataSource ds , String userName , String password , final boolean is2Phase , final WSConnectionRequestInfoImpl cri , boolean useKerberos , Object gssCredential ) throws ResourceException { if ( tc . isEntryEnabled ( ) ) Tr . entry ( this , tc , "getPooledConnection" , AdapterUtil . toString ( ds ) , userName , "******" , is2Phase ? "two-phase" : "one-phase" , cri , useKerberos , gssCredential ) ; // if kerberose is set then issue a warning that no special APIs are used instead, // a getConnection() without username/password will be used. // to get a connection. if ( useKerberos ) { Tr . warning ( tc , "KERBEROS_NOT_SUPPORTED_WARNING" ) ; } try { final String user = userName == null ? null : userName . trim ( ) ; final String pwd = password == null ? null : password . trim ( ) ; PooledConnection pConn = AccessController . doPrivileged ( new PrivilegedExceptionAction < PooledConnection > ( ) { public PooledConnection run ( ) throws SQLException { boolean buildConnection = cri . ivShardingKey != null || cri . ivSuperShardingKey != null ; if ( is2Phase ) if ( buildConnection ) return mcf . jdbcRuntime . buildXAConnection ( ( XADataSource ) ds , user , pwd , cri ) ; else if ( user == null ) return ( ( XADataSource ) ds ) . getXAConnection ( ) ; else return ( ( XADataSource ) ds ) . getXAConnection ( user , pwd ) ; else if ( buildConnection ) return mcf . jdbcRuntime . buildPooledConnection ( ( ConnectionPoolDataSource ) ds , user , pwd , cri ) ; else if ( user == null ) return ( ( ConnectionPoolDataSource ) ds ) . getPooledConnection ( ) ; else return ( ( ConnectionPoolDataSource ) ds ) . getPooledConnection ( user , pwd ) ; } } ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "getPooledConnection" , AdapterUtil . toString ( pConn ) ) ; return new ConnectionResults ( pConn , null ) ; } catch ( PrivilegedActionException pae ) { FFDCFilter . processException ( pae . getException ( ) , getClass ( ) . getName ( ) , "1298" ) ; ResourceException resX = new DataStoreAdapterException ( "JAVAX_CONN_ERR" , pae . getException ( ) , DatabaseHelper . class , is2Phase ? "XAConnection" : "PooledConnection" ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "getPooledConnection" , "Exception" ) ; throw resX ; } catch ( ClassCastException castX ) { // There's a possibility this occurred because of an error in the JDBC driver // itself. The trace should allow us to determine this. FFDCFilter . processException ( castX , getClass ( ) . getName ( ) , "1312" ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "Caught ClassCastException" , castX ) ; ResourceException resX = new DataStoreAdapterException ( castX . getMessage ( ) , null , DatabaseHelper . class , is2Phase ? "NOT_A_2_PHASE_DS" : "NOT_A_1_PHASE_DS" ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "getPooledConnection" , "Exception" ) ; throw resX ; } }
Get a Pooled or XA Connection from the specified DataSource . A null userName indicates that no user name or password should be provided .