Hi all,
I really hope someone here will be able to help me with this, it is driving me mad.
I have a query that is returning records within SQL Server, and i am trying to get the number of records returned for checks within my code. this is what i have at the moment:
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection con = DriverManager.getConnection(url, username, password);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs_item;
rs_item = stmt.executeQuery("select TOP 1 ColA, ColB from DATA_TBL_9");
rs_item.last();
int num_recs = rs_item.getRow();
out.println(num_recs); <-- this returns -3 everytime!!!!
I've tried doing:
while (rs_item.next()) {
out.println(rs_item.getRow() + "<br />");
}
and this increments as expected.
I've read somepeople saying to do a count(*) before each query and to use that, but i am going to have 9 queries running on this page, so would like to use the above method if available to minimize hits on the database, i don't really want to have 18 queries running.
Any ideas?
TIA
Tony
I really hope someone here will be able to help me with this, it is driving me mad.
I have a query that is returning records within SQL Server, and i am trying to get the number of records returned for checks within my code. this is what i have at the moment:
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection con = DriverManager.getConnection(url, username, password);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs_item;
rs_item = stmt.executeQuery("select TOP 1 ColA, ColB from DATA_TBL_9");
rs_item.last();
int num_recs = rs_item.getRow();
out.println(num_recs); <-- this returns -3 everytime!!!!
I've tried doing:
while (rs_item.next()) {
out.println(rs_item.getRow() + "<br />");
}
and this increments as expected.
I've read somepeople saying to do a count(*) before each query and to use that, but i am going to have 9 queries running on this page, so would like to use the above method if available to minimize hits on the database, i don't really want to have 18 queries running.
Any ideas?
TIA
Tony