db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernt M. Johnsen" <Bernt.John...@Sun.COM>
Subject Re: ResultSet.getInt()
Date Wed, 22 Feb 2006 20:20:00 GMT
I think your answer lies in the description of wasNull()

  boolean wasNull()
                throws SQLException

    Reports whether the last column read had a value of SQL NULL. Note
    that you must first call one of the getter methods on a column to
    try to read its value and then call the method wasNull to see if
    the value read was SQL NULL.

You have not called RS.getXXX() and thus the excpetion is correct.


>>>>>>>>>>>> Thomas Vatter wrote (2006-02-22 20:49:59):
> 
> I have a problem using ResultSet.getInt() method, each call returns an 
> exception:
> org.apache.derby.client.am.SqlException: Invalid operation:
> wasNull() called with no data retrieved
>        at org.apache.derby.client.am.ResultSet.wasNull(Unknown Source)
> 
> The code is
>        ResultSetMetaData RSMD = RS.getMetaData();
>        int INTcols = RSMD.getColumnCount();
>        String STRtemp = null;
>        while(RS.next())
>        {
>            String STRvalue = new String();           
>            for(int INTcol = 1; INTcol <= INTcols; INTcol++)
>            {
>                int INTdummy = RSMD.getColumnType(INTcol);              
>                switch((int)RSMD.getColumnType(INTcol))
>                {
>                        if(!RS.wasNull()) // raises exception
>                        
> {                                                                           
> 
>                            STRvalue = "" + 
> RSaktuelles.getInt(INTcol);                                              
>                        } 
>        ...
>        }
>         }
>    }
> 
> what can I do to avoid this exception
> 
> tom
> 

-- 
Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

Mime
View raw message