[jboss-user] [JCA/JBoss] - I can't see Conneciton Sharing happening .

vickyk do-not-reply at jboss.com
Sat May 5 02:22:35 EDT 2007


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 at 4e9bea
  | org.hsqldb.jdbc.jdbcConnection at 169674
  | org.hsqldb.jdbc.jdbcConnection at 169674
  | Second Connectionorg.jboss.resource.adapter.jdbc.WrappedConnection at 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 ?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043406#4043406

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043406



More information about the jboss-user mailing list