List:MySQL and Java« Previous MessageNext Message »
From:Mark Matthews Date:February 6 2003 3:50pm
Subject:Re: Null ResultSet?
View as plain text  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Filip Rachunek wrote:
> Hello,
> I have a web application and when my servlets call a 
> Statement.executeQuery() method, the returning ResultSet is sometimes 
> null. Is that possible? I thought that even empty result sets were 
> non-null objects. Or should I add a is-null check for all result sets I 
> use?
> Here is the exception:
> 
> java.lang.NullPointerException:
>     at com.mysql.jdbc.ResultSet.next(ResultSet.java:2421)
> 
> 
> Thanks.
> Filip Rachunek
> 
> http://BrainKing.com

In another e-mail (to me) you said that you were using the 'latest' 
version? Are you absolutely sure (no old ones laying around in your 
CLASSPATH or jre/lib/ext)? If you check line 2421 in ResultSet.java, it 
is the following method code:

if (!reallyResult()) {
             throw new java.sql.SQLException("ResultSet is from UPDATE. 
No Data",
                 "S1000");
         }

This calls the 'reallyResult()' method, which returns a boolean. There 
is nowhere in this code that a NullPointerException could be thrown.

	-Mark
- -- 
MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/

For technical support contracts, visit https://order.mysql.com/?ref=mmma

     __  ___     ___ ____  __
    /  |/  /_ __/ __/ __ \/ /  Mark Matthews <mark@stripped>
   / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
  /_/  /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
         <___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+QoRFtvXNTca6JD8RAuR6AKC6uVUM2z1GVO9Zud02RIijCcVkRgCgqmXp
Ygu/vePF8qf5eV6rq9Ef1+c=
=h45R
-----END PGP SIGNATURE-----

Thread
Null ResultSet?Filip Rachunek5 Feb
  • Re: Null ResultSet?Mark Matthews6 Feb
  • Re: Null ResultSet?Mark Matthews6 Feb
Re: Null ResultSet?Filip Rachunek7 Feb