Hi, Please see below for a section of code which works that queries a sql database for the number of rows of information in the table pair and retrurns this number as part of a ResultSet. However in order to access the result I then have to perform a while loop on the RecordSet in order to access this number. My question, is there a more efficient way to access the number of records seeing as the while loop only has to loop once (only one value is returned from the SQL query), or do I have to continue using the while loop?
Many thanks
CODE
try {
SQLConn Sconn = new SQLConn(serverName, SQLPortNumber, userName,password, databaseName, giveOutput);
ResultSet rs = Sconn.executeQuery("SELECT COUNT(pair_id) FROM pair");
// Fetch each row from the result set
while (rs.next()) {
// Get the data from the row using the column index
String s = rs.getString(1);
System.out.println(s);
// Get the data from the row using the column name
s = rs.getString("col_string");
}
} catch (SQLException e) {
}
This post has been edited by javamad: 2 Jul, 2009 - 02:12 AM