Fwd: Exception in thread "main" - Mailing list pgsql-jdbc

From Mathew McBride
Subject Fwd: Exception in thread "main"
Date
Msg-id 200210090655.38029.matt@mcbridematt.dhs.org
Whole thread Raw
Responses Re: Fwd: Exception in thread "main"
List pgsql-jdbc
Hi,

    I wrote up some code to retrive a company name associated with a id from a
database. This is the code I used:

try {
    Connection db = DriverManager.getConnection("jbdc:postgresql:vapilot",
"postgres" , " ");
    PreparedStatement st = db.prepareStatement("SELECT \"va_vairline\" FROM
\"va_pilots\" WHERE va_id='1'");
    ResultSet rs = st.executeQuery();
    add(name);
    add(va);
    va.setText(rs.getString("va_vairline"));
    }
    catch (SQLException se) {
    System.out.println("ERROR: Cannot Execute SQL query");
    }

I compiled and ran it:
java -Djdbc.drivers=org.postgresql.Driver org/vaproject/vapilot/va_pilot
And it said this:
Exception in thread "main" java.lang.NullPointerException
        at org.postgresql.jdbc2.ResultSet.getString(ResultSet.java:168)
        at org.postgresql.jdbc2.ResultSet.getString(ResultSet.java:553)
        at org.vaproject.vapilot.infoPanel.<init>(va_pilot_gui.java:130)
        at org.vaproject.vapilot.va_pilot_gui.<init>(va_pilot_gui.java:37)
        at org.vaproject.vapilot.va_pilot.<init>(va_pilot.java:14)
        at org.vaproject.vapilot.va_pilot.main(va_pilot.java:27)

I used the file jdbc7.2dev-1.2.jar from the RedHat 7.3 RPM postgresql-jdbc.
Should I either download a new one from the JDBC driver website or compile
one myself?



pgsql-jdbc by date:

Previous
From: "David Wall"
Date:
Subject: Re: jdbc cursor positioning
Next
From: Mathew McBride
Date:
Subject: Exception in thread "main"