1 Reply Latest reply on May 8, 2007 8:46 PM by Weston M. Price

    I can't see Conneciton Sharing happening .

    Vicky Kak Master

      I am making the <res-sharing-scope>Unshareable</res-sharing-scope> in the web.xml file , here goes the code .

      <resource-ref>
       <description>DB Connection</description>
       <res-ref-name>jdbc/testDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Unshareable</res-sharing-scope>
       </resource-ref>


      I have a jsp which does the following
      InitialContext ctx = new InitialContext();
       DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/testDS");
       UserTransaction utx = (UserTransaction)ctx.lookup("UserTransaction");
       utx.begin();
       Connection con = ds.getConnection();
       out.println("First Connection --> "+con.toString()+"<br>");
       WrappedConnection unlycon = (WrappedConnection)con;
       out.println(unlycon.getUnderlyingConnection()+"<br>");
       Connection con1 = ds.getConnection();
       WrappedConnection unlycon1 = (WrappedConnection)con1;
       out.println(unlycon1.getUnderlyingConnection()+"<br>");
       out.println("Second Connection"+con1);
       utx.commit();
       con.close();
       con1.close();

      And I see the following result
      First Connection --> org.jboss.resource.adapter.jdbc.WrappedConnection@4e9bea
      org.hsqldb.jdbc.jdbcConnection@169674
      org.hsqldb.jdbc.jdbcConnection@169674
      Second Connectionorg.jboss.resource.adapter.jdbc.WrappedConnection@de3c87


      Since the resource sharing is defined as Unsharable I was expecting the underlying connection reference as different but it is not .
      Am I missing some thing here ?