Re: Jdbc3PoolingDataSource default auto commit is false - Mailing list pgsql-jdbc

From Csaba Nagy
Subject Re: Jdbc3PoolingDataSource default auto commit is false
Date
Msg-id 1049360110.18440.8.camel@coppola.ecircle.de
Whole thread Raw
In response to Jdbc3PoolingDataSource default auto commit is false  (Ryan Christianson <ryan@echospace.com>)
Responses Re: Jdbc3PoolingDataSource default auto commit is false
List pgsql-jdbc
You still could have set the autocommit flag on a per connection basis.
The default autocommit is the autocommit value a newly checked out
connection will have, but you can set it to on after checking out the
connection from the pool.
And yes, when autocommit is off, you need to commit/rollback after your
queries.
BTW, I find the autocommit being off by default as rather useless and
confusing, as people will know how to explicitly open a transaction when
they want to have one wrapping more queries, and queries not explicitly
wrapped in transactions are usually to be committed immediately. It is
confusing, as your case clearly demonstrates.

HTH,
Csaba.

On Wed, 2003-04-02 at 19:55, Ryan Christianson wrote:
> Hi.
>
> I am useing Jdbc3PoolingDataSource to do database pooling. When I first
> started using it some of my updates where not taking effect. So I
> started enabled postgres logging and watched my queries, and I found out
> why. The Jdbc3PoolingDataSource by default sets setDefaultAutoCommit to
> false, and because of that, after every query it was calling "rollback".
>
> To fix it, I extended Jdbc3PoolingDataSource, over-wrote the
> createConnectionPool like so:
>     protected ConnectionPool createConnectionPool() {
>         ConnectionPool pool = super.createConnectionPool();
>         pool.setDefaultAutoCommit(true);
>         return pool;
>     }
>
> So my question is, how should I have worked with defaultAutoCommit set
> to true? Would I need to wrap all of my queries in begin; and commit; ?
>
> Thanks
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>


pgsql-jdbc by date:

Previous
From: Joseph Shraibman
Date:
Subject: Re: SQLException : Unknown Response Type
Next
From: apratim sharma
Date:
Subject: abstract method error while using rs.beforeFirst() ???