tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Pringle <Jason.Prin...@amdocs.com>
Subject Defect in parsing connectionProperties in a Resource declaration?
Date Thu, 04 Aug 2011 20:26:14 GMT
We're configuring a datasource like so in server.xml:


<Resource name="jdbc/UCPPool"
              auth="Container"
              factory="oracle.ucp.jdbc.PoolDataSourceImpl"
              type="oracle.ucp.jdbc.PoolDataSource"
              description="UCP Pool in Tomcat"
              connectionFactoryClassName="oracle.jdbc.pool.OracleDataSource"
              minPoolSize="2"
              maxPoolSize="20"
              inactiveConnectionTimeout="20"
              user="scott"
              password="tiger"
              url="jdbc:oracle:thin:@db-host.dev:50071:mydb"
              connectionPoolName="UCPPool"
              validateConnectionOnBorrow="true"
              sqlForValidateConnection="select 1 from DUAL"
              connectionProperties=";oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR=3000;" />


Notice that the connectionProperties attribute has leading and trailing semicolons.  We've
noticed that if they are not present, then the leading/trailing characters are stripped out
of the value string.  Moreover, additional properties are just ignored.

Code we're using to see the behavior:

    DataSource ds = null;
    Connection conn = null;
    ResultSet result = null;
    Statement stmt = null;
    ResultSetMetaData rsmd = null;
    try{
      Context context = new InitialContext();
      Context envCtx = (Context) context.lookup("java:comp/env");
      ds =  (DataSource)envCtx.lookup("jdbc/UCPPool");
      if (ds != null) {
        PoolDataSourceImpl pds = (PoolDataSourceImpl)ds;
        System.out.println("Print all conn props:" + pds.getConnectionProperties().toString());
        System.out.println("Print value of just oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR:
" +pds.getConnectionProperty("oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR"));
        conn = ds.getConnection();
        stmt = conn.createStatement();
        result = stmt.executeQuery("SELECT * FROM DEPT");
       }
     }

...
Print all conn props:{oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR=3000}
Print value of just oracle.net.ns.SQLnetDef.TCP_CONNTIMEOUT_STR: 3000


This may be an error in the oracle factory (oracle.ucp.jdbc.PoolDataSourceImpl) or in the
parsing logic in Tomcat when reading the XML file.  I haven't been able to locate that code
for a quick review, nor have we had time to try passing that property to other drivers and
see if it works (thus narrowing suspicion on the oracle factory class).

Can someone point me to the area of code in tomcat that initially parses the resource (in
GlobalResources) and then instantiates the resources (I assume the actual instantiation is
via org.apache.naming.factory.ResourceFactory, but don't know the code path leading towards
that invocation).

We're seeing this on Tomcat 7.0.11 and (I think) on 7.0.14.

(Fedora 11, 64-bit, Sun JDK 1.6.0.24 64-bit).

Thanks!

Jason Pringle

This message and the information contained herein is proprietary and confidential and subject
to the Amdocs policy statement,
you may review at http://www.amdocs.com/email_disclaimer.asp


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message