Skip site navigation (1) Skip section navigation (2)

Re: commit after select

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Bob Bie <bob1234(at)pi(dot)be>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: commit after select
Date: 2004-04-05 22:05:52
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Bob Bie wrote:
> Hello,
> I'm writing a java program that uses transactions. For this reason I
> turned of the autocimmit in java (sqlConnection.setAutocommit(false);)
> This seems to work but now he also seems to lock the tables when I
> only do a select. I can solve this bij doing a commit after each
> select.

In general, SELECTs do not acquire locks. What behaviour leads to 
believe they do?

Have you read the concurrency control chapter of the docs?

> I only want to know if it is normal that I have to do a commit after a
> select.

With autocommit off, a SELECT (or in fact *any* query) will start a new 
transaction. It's your responsibility to eventually close that 
transaction (via commit() or rollback()) at an apropriate point.

> I use java 1.4.2_01 and postgres 7.3. The jdbc driver I use is called
> pg73jdbc3.

This is quite an old driver; you're better off running the current 7.4 
drivers (they will talk to a 7.3 database fine).


In response to

pgsql-jdbc by date

Next:From: Oliver JowettDate: 2004-04-05 22:19:23
Subject: slow delivery of pgsql-jdbc mail?
Previous:From: Dave CramerDate: 2004-04-05 22:00:37
Subject: Re: Connection Pooling, JDBC and SSL

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group