From: | Csaba Nagy <nagy(at)ecircle-ag(dot)com> |
---|---|
To: | Ryan Christianson <ryan(at)echospace(dot)com> |
Cc: | Postgres JDBC <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Jdbc3PoolingDataSource default auto commit is false |
Date: | 2003-04-03 08:55:09 |
Message-ID: | 1049360110.18440.8.camel@coppola.ecircle.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
>
From | Date | Subject | |
---|---|---|---|
Next Message | apratim sharma | 2003-04-03 15:58:33 | abstract method error while using rs.beforeFirst() ??? |
Previous Message | Rohit Johry | 2003-04-03 05:33:40 | PLS HELP in connecting with jdbc driver |