CSDN博客

img javaindex

回滚操作

发表于2008/9/28 7:30:00  180人阅读

 import java.sql.*;

public class TestScroll {
 public static void main(String args[]) {

  try {
   new oracle.jdbc.driver.OracleDriver();
   String url = "jdbc:oracle:thin:@192.168.0.1:1521:SXT";
   Connection conn = DriverManager
     .getConnection(url, "scott", "tiger");
   Statement stmt = conn.createStatement(
     ResultSet.TYPE_SCROLL_INSENSITIVE,
     ResultSet.CONCUR_READ_ONLY);
   ResultSet rs = stmt
     .executeQuery("select * from emp order by sal");
   rs.next();
   System.out.println(rs.getInt(1));
   rs.last();
   System.out.println(rs.getString(1));
   System.out.println(rs.isLast());
   System.out.println(rs.isAfterLast());
   System.out.println(rs.getRow());
   rs.previous();
   System.out.println(rs.getString(1));
   rs.absolute(6);
   System.out.println(rs.getString(1));
   rs.close();
   stmt.close();
   conn.close();
  } catch (SQLException e) {
   e.printStackTrace();
  }
 }
}

阅读全文
0 0

相关文章推荐

img
取 消
img