source file name:  JdbcResultTypes.java

 import java.sql.*;

class JdbcResultTypes

 {

public static void main(String[] args)

{

System.out.println("jdbc program on Result set Types");

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection conn = DriverManager.getConnection("jdbc:odbc:javadsn");

Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

                           ResultSet.CONCUR_READ_ONLY);

String s="select * from "+args[0];

System.out.println("Records display in Forward direction");

ResultSet rs=st.executeQuery(s);

ResultSetMetaData rsmd=rs.getMetaData();

while(rs.next())

{

for(int i=1;i<=rsmd.getColumnCount();i++)

System.out.print(rs.getString(i)+" ");

System.out.print("\n");

}

System.out.println("Records display in Revesed direction");

rs.afterLast();

while(rs.previous())

{

for(int i=1;i<=rsmd.getColumnCount();i++)

System.out.print(rs.getString(i)+" ");

System.out.print("\n");

}

conn.close();

st.close();

}

catch(Exception e1)

{System.out.println(e1);}

}

}

output: