JDBC problem & 7.1 - Mailing list pgsql-general

From Loïc Courtois
Subject JDBC problem & 7.1
Date
Msg-id 00d601c0ce73$695430e0$7501a8c0@JADE
Whole thread Raw
List pgsql-general
Hello,

I have the following java source code:

This one work with pg 7.0.3 , but not with 7.1, with the following error
message:

java.lang.NullPointerException
        at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:116)
        at ouah.stats.Stats.go(Stats.java:242)
        at daily.main(daily.java:54)

///////////////////////////////////////BEGIN////////////////////////////////
///:
Statement statement;
ResultSet results, results2;

try {
            statement = conn.createStatement();

            if(statement.execute("SELECT ...")) {
                results = statement.getResultSet();
                while(results.next()) {
                    System.out.println(results.getInt("nb"));

                    if(statement.execute("SELECT ... WHERE no = " +
results.getString("no") ... ")) {
                        results2 = statement.getResultSet();
                        while(results2.next()) {
                            System.out.println("\t" +
results2.getInt("nb"));
                        }
                        results2.close();
                    }
                }
                results.close();
                statement.close();
            }
} catch (java.sql.SQLException e) { e.printStackTrace();}
///////////////////////////////////////END//////////////////////////////////
/:


This one work with pg 7.1
///////////////////////////////////////BEGIN////////////////////////////////
///:
Statement statement, s2;
ResultSet results, results2;

try {
            statement = conn.createStatement();
            s2 = conn.createStatement();

            if(statement.execute("SELECT ...")) {
                results = statement.getResultSet();
                while(results.next()) {
                    System.out.println(results.getInt("nb"));

                   if(s2.execute("SELECT ... WHERE no = " +
results.getString("no") ... ")) {
                        results2 = s2.getResultSet();
                        while(results2.next()) {
                            System.out.println("\t" +
results2.getInt("nb"));
                        }
                        results2.close();
                    }
                }
                results.close();
                statement.close();
                s2.close();
            }
} catch (java.sql.SQLException e) { e.printStackTrace();}
///////////////////////////////////////END//////////////////////////////////
/:


Please, could I have advice?

Thanks!!

Loic Courtois
Netpartage


pgsql-general by date:

Previous
From: Micah Woods
Date:
Subject: Trigger won't accept function (Please Help)
Next
From: Boulat Khakimov
Date:
Subject: Postgres Bug (ALTER TABLE problem)