By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

JDBC

P: n/a
Ron
this code is giving me an excption and I cannot tell why could someone who
is familiar with jdbc help me out, I am using mysql with jdbc, although the
exception does not look like it is getting far enough for that to matter.
Statement stmt = PoolDB.createStatement(ResultSet.TYPE_SCROLL_INSEN SITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet Picks = stmt.executeQuery("SELECT * FROM picks where
week="+week); // get all the cloums and keys so the rows are updateable
ResultSet ScoreCalc; //for lookups to another table
String PlayerOrGoalie; //to determine wich table to look in
String name;
String Test;
while (Picks.next()){ //loop through all the picks
name=Picks.getString(5);
PlayerOrGoalie=Picks.getString(4)=="G"? "goalie":"player"; //select
the table goalie, or player
Test="Select WeekOpenScore, CurrentScore from "+PlayerOrGoalie+" where
name ='"+name+"'";
System.out.println(Test); //shows the query for debugging
ScoreCalc =stmt.executeQuery(Test);
System.out.println("1"); //verifys that the above line is processed;
ScoreCalc.first();
System.out.println("2"); //verifys that the above line is processed;
Picks.updateInt("Score",ScoreCalc.getInt(2)-ScoreCalc.getInt(1));
System.out.println("3"); //verifys that the above line is processed;
Picks.updateRow();
System.out.println("4"); //Output never reaches here
}

gives me this output

Select WeekOpenScore, CurrentScore from player where name ='SomeName'
1
2
3
Exception in thread "main" java.lang.NullPointerException
at com.mysql.jdbc.UpdatableResultSet.refreshRow(Updat ableResultSet.java:628)
at com.mysql.jdbc.UpdatableResultSet.updateRow(Updata bleResultSet.java:1542)
at Hockey2003.main(Hockey2003.java:113)
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ron
Answered my own question by creating a second statement for the second
result set so that my first set would not get closed..... silly me
"Ron" <no*@email.from.here> wrote in message
news:rx*********************@news04.bloor.is.net.c able.rogers.com...
this code is giving me an excption and I cannot tell why could someone who
is familiar with jdbc help me out, I am using mysql with jdbc, although the exception does not look like it is getting far enough for that to matter.
Statement stmt = PoolDB.createStatement(ResultSet.TYPE_SCROLL_INSEN SITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet Picks = stmt.executeQuery("SELECT * FROM picks where
week="+week); // get all the cloums and keys so the rows are updateable ResultSet ScoreCalc; //for lookups to another table
String PlayerOrGoalie; //to determine wich table to look in
String name;
String Test;
while (Picks.next()){ //loop through all the picks
name=Picks.getString(5);
PlayerOrGoalie=Picks.getString(4)=="G"? "goalie":"player"; //select
the table goalie, or player
Test="Select WeekOpenScore, CurrentScore from "+PlayerOrGoalie+" where
name ='"+name+"'";
System.out.println(Test); //shows the query for debugging
ScoreCalc =stmt.executeQuery(Test);
System.out.println("1"); //verifys that the above line is processed;
ScoreCalc.first();
System.out.println("2"); //verifys that the above line is processed;
Picks.updateInt("Score",ScoreCalc.getInt(2)-ScoreCalc.getInt(1));
System.out.println("3"); //verifys that the above line is processed;
Picks.updateRow();
System.out.println("4"); //Output never reaches here
}

gives me this output

Select WeekOpenScore, CurrentScore from player where name ='SomeName'
1
2
3
Exception in thread "main" java.lang.NullPointerException
at com.mysql.jdbc.UpdatableResultSet.refreshRow(Updat ableResultSet.java:628) at com.mysql.jdbc.UpdatableResultSet.updateRow(Updata bleResultSet.java:1542) at Hockey2003.main(Hockey2003.java:113)

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.