One More Programme on - TopicsExpress



          

One More Programme on ResultSets: ============================== import java.sql.*; class DBL { Connection con; Statement st; ResultSet rs; public static void main(String args[]) throws Exception { Class.forName(oracle.jdbc.driver.OracleDriver); con=DriverManager.getConnection(jdbc:oracle:thin:@localhost:1521:xe,system,durga); st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rs=st.executeQuery(select * from emp1); System.out.println(data Before Updation); System.out.println(ENO ENAME ESAL); System.out.println(-------------------); while(rs.next()) { System.out.println(rs.getInt(1)++rs.getString(2)++rs.getFloat(3)); } System.out.println(Application is in Pausing State,provide updations on db); System.in.read(); System.out.println(data After Updation); System.out.println(ENO ENAME ESAL); System.out.println(-------------------); while(rs.next()) { rs.refreshRow(); System.out.println(rs.getInt(1)++rs.getString(2)++rs.getFloat(3)); } } } -->To move ResultSet cursor to before first record we have to use the following method from ResultSet public void beforeFirst() -->To move ResultSet cursor to After the last record we have to use the following method from ResultSet public void afterLast() -->To move ResultSet cursor to a particular record we have to use the following method from ResultSet public void absolute(int rec_position) -->In case of scroll sensitive ResultSet objects to reflect later database updations into the ResultSet object we have to refresh each and every record for this we have to use the following method from ResultSet public void refreshRow() -->where refreshRow() method can be used to refresh only one record. -->If we use Type4 Driver provided by oracle in the above application then JVM will raise an exception like java.sql.SQLException:unsupportedfeature:refreshrow -->In jdbc applications scroll sensitive ResultSet object should be supported by Type1 Driver provided by Sun MicroSystems,which could not be supported by Type4 Driver provided by oracle. -->In Jdbc applications scroll Insensitive ResultSet object could not be supported by both Type1 Driver provided by Sun MicroSystems and Type4 Driver provided by oracle. -->In jdbc applications the main purpose of UpdatableResultSet object is to perform updations on its content in order to perform the manipulations with the data available at Database
Posted on: Sun, 21 Dec 2014 14:39:12 +0000

Trending Topics



Recently Viewed Topics




© 2015