7 Replies Latest reply on Nov 23, 2005 11:59 AM by Adrian Brock

    Wrapped Connection

    Jason Price Newbie

      I have a situation where I need to get a connection which I can commit and rollback as required.

      I have a method that returns a java.sql.connection object from a DataSource:

      DataSource ds = (DataSource) jndiCntx.lookup("java:DSNAME");
      con = ds.getConnection();

      However the setAutoCommit isn't wokring as when I look at the connection auto commit is alwasy true. The Datasource is set up as follows:
       <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>

      I have tried to set a <Connection-proprty> tag to set auto commit to false, Setting the transaction isolation value and defining the datasource as no-tx-datasource. None of which make any difference. Googling about I notice that you can get a WrappedConnection and return the underlying Connection object which I hope I can then set autocommit on. Unfortunately I can't find the jar that I need to reference to get the WrappedConnection class from?

      This must be something quite simple I just can't seem to find any info at all!
      Can someone point me in the right direction?