Tuesday, March 17, 2009

ResultSet.TYPE_SCROLL_SENSITIVE example



import java.sql.*;
class GetDataScrollable
{
public static void main(String[] args) throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","system","chandru");
System.out.println(" nected 2 DB.....");
/*In case of scroll sensitive result set can use refreshRow method ,
to get the changes that are made by some other application after
the ResultSet is opened.*/
Statement stmt=con.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String vsql="select * from emp3";
ResultSet rs=stmt.executeQuery(vsql);
System.out.println("RS has been opened.....");
rs.absolute(2);
System.out.println(rs.getString(1));
//System.in.read();
rs.updateString("ename","lax");
rs.updateRow();
}
}



0 comments:

Post a Comment