File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException from result set

 
Francisco A Guimaraes
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Arulkumar Gopalan
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think some string is null which you are trying to access. why don't you paste the code here?
 
Francisco A Guimaraes
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Francisco A Guimaraes
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic