JDBC commit() not working?

From: Robert Berger <rwb(at)vtiscan(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: JDBC commit() not working?
Date: 2001-08-16 03:15:29
Message-ID: 3B7B3AD1.C7C4E339@vtiscan.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have some code that's doing connection pooling for some servlets. I
turn autoCommit off and let each caller determine when to commit.

Hoever, commit() does not seem to be releasing read locks, causing
my periodic VACUUM task to block.

In the following code, after commit() is called, ps shoes the backend
state as "idle in transaction". If I turn autocommit on, the state is
"idle" Why the difference?

import java.sql.*;

public class ctest {
public static void main(String argv[]) {
try {
String driverName = "org.postgresql.Driver";
Class.forName(driverName).newInstance();

Connection con = DriverManager.getConnection(
"jdbc:postgresql://127.0.0.1/jackson","db","zzzz");

con.setAutoCommit(false);

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM s_image");
rs.next();
int count = rs.getInt(1);
rs.close();

con.commit();

System.out.println(count);

Thread.sleep(30000);

} catch (Exception e) { e.printStackTrace(); }
}
}

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Fordyce 2001-08-16 03:37:27 RE: OpenBSD 2.9 - installation works fine but psql won't run
Previous Message Killian May 2001-08-16 02:56:34 Missing Sequence File