This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi, I�m trying to update a column, but when the updateString method is executed, I get a NullPointerException, does anybody knows what�s going on? I�m not mispelling the column, it *is* a String and if I do a getString() I get the current value correctly. Any help is greatly appreciated. Francisco
Francisco<br />SCJP<br />please use the [code][/code] tags when showing code.Click <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page" target="_blank" rel="nofollow">here</a> to see an example.
I think some string is null which you are trying to access. why don't you paste the code here?
Anbudan & Mahalo,<br />Arul<br /> <br />-Not a sun certified Java professional :-)
Francisco A Guimaraes
Joined: Mar 20, 2002
After some hours, I discovered what was wrong: when you create a Statment with the default method it is forward-only and read-only, and for you to be able to update the columns in the result set it must be scrollable and updatable. Two arguments that you must pass when getting the Statement. All this trouble could easily be avoided if instead of NullPointerException, they throwed a SQLException with the message "Trying to update a read-only resultSet", or something like that, don�t you all think? Francisco
All this trouble could easily be avoided if instead of NullPointerException, they throwed a SQLException with the message "Trying to update a read-only resultSet", or something like that, don�t you all think?
Yes, I agree. But I wanted to make sure you understand who "they" are in this case. It's not Sun -- it's whoever implemented the JDBC driver you're using. Statement is just an interface -- the implementations are supplied by driver vendors.
In this case "they" are Sun, because I was using the jdbc-Odbc driver provided by sun. Some might say that it is not a "commercial" driver, but I honestly think that�s no excuse for a lousy job; a NullPointerException doesn�t help anyone. I lost a couple of hours to discover the problem and it could have been easily avoided. Francisco