Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


(JDBC) can't get preparedStatement to work

(JDBC) can't get preparedStatement to work

(JDBC) can't get preparedStatement to work


   I'm using Mimer SQL v8.2.3B and a JDBC (2.0 compliant) driver v2.8. Here's a snippet of the code I simply can't get to work:

String stat= "select * from simple where mykey < ?";
PreparedStatement ps= conn.prepareStatement(stat);
ps.setInt(1, 42);
ResultSet rs= ps.executeQuery();

The column 'mykey' is defined as 'integer(8) primary key'
The resultset always contains zero rows (which isn't true in my example. If I change the code snippet into this --

String stat= "select * from simple where mykey < 42";
PreparedStatement ps= conn.prepareStatement(stat);
ResultSet rs= ps.executeQuery();

everything works as a breeze. I can't simplify this any further; ideas anyone? Do I miss somethings completely obvious? Any help is sincerely appreciated,

kind regards,


RE: (JDBC) can't get preparedStatement to work

Hello JosHorsmeier!
Your problem is peculiar. The code you have posted is correct, and both variants should work equally well. Unfortunately, I have tried your exact code on a 8.2.4 server without being able to reproduce the problem.

integer(8) is by the way a nonstandardized data type. Perhaps you will be able to work around the problem by casting the column to an integer. Like:

select * from simple where cast(mykey as integer)<?

It looks as if there might be a problem with the INTEGER(n) data type and JDBC on 8.2.3B servers and the above could be a way to avoid the problem.

RE: (JDBC) can't get preparedStatement to work

Greetings 'HondaBoy', and thanks for your reply. I was so agitated, I even forgot to complete my two examples; in my code I need the number of rows in the resultset. I determine this as follows:

// prepare a statement as seen in my prev.message
int nofRows= ress.last()?ress.getRow():0;

if (nofRows == 0)
   // empty resultset
   // process the resultset

Now here's the quirck -- if the prepared statement contains *no* IN parameters, everything works fine. If the statement *does* contain IN parameters, the ress.last() call fails. I found a silly workaround (by sheer serendipity) -- if I call a spurious 'ress.next()' call first, the 'ress.last()' call works and the entire shebang following this code works as expected. There's something fishy going on here ...

BTW, the 'integer(8)' type is handled well by the JDBC driver, i.e. it is translated to an ordinary int.

resuming: a preparedStatement without any IN parameters works as expected; a pS *with* IN parameters causes a consecutive 'ress.last()' call to fail. A spurious 'ress.next()' call automagically fixes this problem.

Thanks again for replying, I really appreciate it.

kind regards,


ps. is this the only Mimer related discussion group/forum?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close