I am trying to write a java program that gives the number of rows
fetched by a query. It does not return any row. See below.
import java.util.*;
import java.io.*;
import java.lang.*;
import java.sql.*;
public class test
{
public static void main(String[] args)
{
try
{
int vCnt = 5;
String vConnect = "sun.jdbc.odbc.JdbcOdbcDriver";
String vURL = "jdbc:odbc:archerarjun";
String vQuery = " Select * from wp_carriers ";
boolean vTmp;
Class.forName(vConnect);
java.sql.Connection vConnObj = DriverManager.getConnection(vURL);
Statement vRetStmtObj =
vConnObj.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE );
ResultSet rs = vRetStmtObj.executeQuery(vQuery);
while (rs.next())
{
System.out.println(rs.getString(1)+" , "+rs.getString(2));
}
vTmp = rs.last();
vCnt = rs.getRow();
System.out.print("Total "+vCnt+" rows fetched.");
vTmp = rs.absolute(1);
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(SQLException sqle)
{
System.err.println(sqle);
}
}
}