Thread: Bug #595: No connection with jdbc since update to 7.2

Bug #595: No connection with jdbc since update to 7.2

From
pgsql-bugs@postgresql.org
Date:
Norbert Pfaff (np@tangro.de) reports a bug with a severity of 4
The lower the number the more severe it is.

Short Description
No connection with jdbc since update to 7.2

Long Description
Exception in thread "main" Etwas ungewöhnliches ist passiert.  Bitte Teilen Sie diesem Fehler mit: Exception:
java.lang.NullPointerException
Stack Trace:

java.lang.NullPointerException
    at org.postgresql.Connection.openConnection(Unknown Source)
    at org.postgresql.Driver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at TestPostgreSQL.main(TestPostgreSQL.java:84)
End of Stack Trace

    at org.postgresql.Driver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at TestPostgreSQL.main(TestPostgreSQL.java:84)

Sample Code
public class TestPostgreSQL {


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

        // Load the driver class
        //
        Class.forName("org.postgresql.Driver");

        // Try to connect to the DB server.
        // We tell JDBC to use the "postgresql" driver
        // and to connect to the "template1" database
        // which should always exist in PostgreSQL.
        // We use the username "postgres" and no
        // password to connect. Since we're not accessing
        // any tables but only an SQL function
        // this should work.
        //
        Connection conn = DriverManager.getConnection(
            "jdbc:postgresql://localhost:5432:template1","postgres","database");

        // Set up and run a query that fetches
        // the current date using the "now()" PostgreSQL function.
        //
        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("SELECT now();");

        // Iterate through the rows of the result set
        // (obviously only one row in this example) and
        // print each one.
        //
        while (rset.next()) {
            System.out.println(rset.getString(1));
        }

        // Close result set, statement and DB connection
        //
        rset.close();
        stmt.close();
        conn.close();

    }


}


No file was uploaded with this report