ResultSet.getInt on a NULL value

336 views
Skip to first unread message

Milos Pejovic

unread,
Jun 8, 2008, 4:18:00 PM6/8/08
to H2 Database
Hi all,

I encountered a strange problem, while trying to do this:

ResultSet rs = prepared.executeQuery();
int i = rs.getInt(1);
if (rs.wasNull()) i = -1;

On NULL value H2 throws an exception:

org.h2.jdbc.JdbcSQLException: No data is available [2000-73]
at org.h2.message.Message.getSQLException(Message.java:103)
at org.h2.message.Message.getSQLException(Message.java:114)
at org.h2.message.Message.getSQLException(Message.java:77)
at org.h2.message.Message.getSQLException(Message.java:149)
at
org.h2.jdbc.JdbcResultSet.checkOnValidRow(JdbcResultSet.java:2971)
at org.h2.jdbc.JdbcResultSet.get(JdbcResultSet.java:2977)
at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:285)
[...]

H2 1.0.73 (2008-05-31) embedded on Linux.

I will solve this problem by changing the query, but this should be
possible...

Thomas Mueller

unread,
Jun 8, 2008, 4:41:24 PM6/8/08
to h2-da...@googlegroups.com
Hi,

You need to call rs.next().

Regards,
Thomas

Milos Pejovic

unread,
Jun 8, 2008, 4:43:17 PM6/8/08
to H2 Database
Never mind, I made an error... I forgot to put rs.next() in order to
fetch the row...
H2 works fine as usual :-)

Milos Pejovic

unread,
Jun 8, 2008, 4:45:40 PM6/8/08
to H2 Database
I realized that...

H2 works fine :)


On 8 јун, 22:41, "Thomas Mueller" <thomas.tom.muel...@gmail.com>
wrote:
> Hi,
>
> You need to call rs.next().
>
> Regards,
> Thomas
>
Reply all
Reply to author
Forward
0 new messages