Exception in thread "main"

Поиск
Список
Период
Сортировка
Искать

Exception in thread "main"

От:
Mathew McBride <mcbridematt@iprimus.com.au>
Дата:
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.(va_pilot_gui.java:130)
        at org.vaproject.vapilot.va_pilot_gui.(va_pilot_gui.java:37)
        at org.vaproject.vapilot.va_pilot.(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?
FAQ