Good evening, guys,
I've just come across an issue on a ResultSet returned from a PreparedStatemnt.
next() function of ResultSet hangs if I set the parameter with setString() like below.
PreparedStatemnt ps = null;
ResultSet rs = null;
ps = con.prepareStatemnt("select id from Table1 where name = ?");
ps.setString(1, "Bob");
rs = ps.executeQuery();
if(rs.next()){
}
However, it works fine if I do not set the parameter and concatenate the parameter to the query like this,
PreparedStatemnt ps = null;
ResultSet rs = null;
ps = con.prepareStatemnt("select id from Table1 where name = 'Bob' ");
rs = ps.executeQuery();
if(rs.next()){
}
I've applied these two methods to two same table, one with 100 records and the other with 10 million records.
Setting the parameter worked on small table, but the large table.
Concatenating the parameter to the sql query string worked on both.
Is this a bug? or am I missing something important?
regards,