Question in ResultSet.TYPE_FORWARD_ONLY
Hi All
I have written a sample code, which should throw an exception technically, but it is not, i have made line as bold, the code is
import java.sql.*;
public class SampleJDBC
{
public static void main(String[] args) throws Exception
{
Class.forName("com.jnetdirect.jsql.JSQLDriver");
Connection con = DriverManager.getConnection("jdbc:JSQLConnect://10.0.1.107","sa","sa");
String str = "SELECT * FROM emp_ext";
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,Re sultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery(str);
System.out.println("Fetch Direction : " + rs.getFetchDirection()); // prints 1000 which is ResultSet.FETCH_FORWARD
System.out.println("Type : " + rs.getType()); // prints 1003 which is ResultSet.TYPE_FORWARD_ONLY
System.out.println("============================== =============");
while(rs.next())
{
System.out.println(rs.getString(1)+" : " +rs.getString(2)+" : "+rs.getString(3)+" : "+rs.getString(4)+" : "+rs.getString(5));
}
System.out.println("============================== =============");
rs.absolute(2); // It should throw an exception here right, since this is type forward only, but it is not.
System.out.println(rs.getString(1)+" : " +rs.getString(2)+" : "+rs.getString(3)+" : "+rs.getString(4)+" : "+rs.getString(5));
rs.absolute(1);
System.out.println(rs.getString(1)+" : " +rs.getString(2)+" : "+rs.getString(3)+" : "+rs.getString(4)+" : "+rs.getString(5));
con.close();
}
}
So what is the problem here, These are the information about the versions etc,
Driver Information
Driver Name: NetDirect JSQLConnect
Driver Version: 2.2712
Database Information
Database Name: Microsoft SQL Server
Database Version: 8.0.760
Jdk Information
Java Version : java version "1.4.0"
|