Re: NPE on ResultSet update
Posted by: Rusty Wright
Date: December 11, 2004 08:16PM

I tested my code with mysql-4.0.21 and I get the NPE there as well.

Exception in thread "main" java.lang.NullPointerException
at com.mysql.jdbc.UpdatableResultSet.syncUpdate(UpdatableResultSet.java:1953)
at com.mysql.jdbc.UpdatableResultSet.updateString(UpdatableResultSet.java:1642)
at com.mysql.jdbc.UpdatableResultSet.updateString(UpdatableResultSet.java:1684)
at DB.db_update(DB.java:76)
at Waitlistd.server(Waitlistd.java:55)
at Waitlistd.main(Waitlistd.java:19)

Here is my code:

st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
sql = "select * from waitlistd where host='" + host + "';";
rs = st.executeQuery(sql);

// jdbc doesn't seem to have a rowCount() function to
// tell you how many rows were retrieved, but last()
// returns false if there are no rows in the result set.
//
if (! rs.last()) {
db_insert(con, fpu, host);

return;
}

// re-run the query so we're on the right row for
// the following updates.
//
rs = st.executeQuery(sql);

if (fpu.get_Logon())
rs.updateString("type", "on");
else
rs.updateString("type", "off");

if ((sid = fpu.get_SID()) != null)
rs.updateString("kps", sid);

Options: ReplyQuote


Subject
Written By
Posted
December 11, 2004 07:52PM
Re: NPE on ResultSet update
December 11, 2004 08:16PM
December 11, 2004 08:43PM
December 12, 2004 10:56AM
December 12, 2004 12:13PM
December 12, 2004 02:06PM
December 12, 2004 02:24PM
December 12, 2004 11:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.