Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class UpdateAndShow {
- public static void main(String[] args) {
- Connection con;
- PreparedStatement pstmt;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("Jdbc:Odbc:Aakarshap");
- con.setAutoCommit(false);
- String qrystr="Update Employee set Salary=Salary+1000 where eNum=?";
- pstmt=con.prepareStatement(qrystr);
- pstmt.setInt(1, 1001);
- pstmt.executeUpdate();
- con.commit();
- Statement s = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
- s.execute("SELECT * FROM Employee");
- ResultSet rs = s.getResultSet();
- rs.afterLast(); //go to just after last row.
- while(rs.previous())
- {
- int i;
- for(i = 1; i <= rs.getMetaData().getColumnCount(); i++)
- {
- System.out.print(rs.getString(i) + " ");
- }
- System.out.println();
- }
- }
- catch(ClassNotFoundException ce)
- {
- System.out.println("Error"+ce);
- }
- catch(SQLException se)
- {
- System.out.println("Error"+se);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement