This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes NullPointerException from result set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NullPointerException from result set" Watch "NullPointerException from result set" New topic
Author

NullPointerException from result set

Francisco A Guimaraes
Ranch Hand

Joined: Mar 20, 2002
Posts: 182
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.
Arulkumar Gopalan
Ranch Hand

Joined: Oct 13, 2003
Posts: 104
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
Ranch Hand

Joined: Mar 20, 2002
Posts: 182
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
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


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.


[Jess in Action][AskingGoodQuestions]
Francisco A Guimaraes
Ranch Hand

Joined: Mar 20, 2002
Posts: 182
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException from result set
 
Similar Threads
localhost to web server
Switch with wrappers
SCJP Brainteaser (2)
java for real and.... virtual
JTable Header selection