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

JDBC Trouble when exception appears .

From: "Nicolas Paymal" <npaymal(at)instranet(dot)com>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: JDBC Trouble when exception appears .
Date: 2002-03-05 09:52:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
I got some pb with this configuration database pgsql 7.1 and connect with
jdbc driver from 7.2

I notice something that could be a jdbc bugs :
when connection is not set to autocommit (setAutocommit(false))
When you catch an exception, the next requests until the next commit are
totaly ingored ex code :

import java.sql.*;

class TestJDBC2_Pg {

   static private String driver = "org.postgresql.Driver";
   private static String url    =
"jdbc:postgresql://"; // compatible 7.1
and 7.2

   static void main(String argv[]) throws Exception{

      Connection con        = null;
      Statement  statement  = null;
      ResultSet  rset       = null;

      try {
         con = DriverManager.getConnection(url, "user", "passwd");
         statement = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
         catch (java.sql.SQLException e) {System.out.println("plaintage sql"
+e );
         String strquery = "SELECT VALUE FROM WRONGTABLENAME\n";
      try {
         String result;
         rset= statement.executeQuery(strquery);
         if (rset !=null &&
             result= rset.getString("VALUE");
         int i=0;
         catch (java.sql.SQLException e) {System.out.println("error sql "
+e );

      strquery = "DROP INDEX WRONGINDEXNAME\n";

      try {
         int i=0;
         catch (java.sql.SQLException e) {System.out.println("error sql "
+e );

excecute this code  As you can see the second query is not excecuted (no
exception appears);

this does not appears if I do not comment the rollback() insinde the catch
exception (in red);

but you understand that during a connection I don't always what to rollback
all modif when I catch an exception.

So that cause me a lots of problems .

Is there any solutions ?

pgsql-bugs by date

Next:From: Arkadiusz MiskiewiczDate: 2002-03-06 09:18:44
Subject: regression - postgresql 7.2 on power pc/linux
Previous:From: JustinDate: 2002-03-05 02:50:22
Subject: Re: postmaster problem....

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