Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NullPointerException from result set

 
Ranch Hand
Posts: 182
  • 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
 
Ranch Hand
Posts: 104
  • 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
  • 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
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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
  • 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'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic