Advertisement
attila66

Untitled

May 10th, 2020
1,350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1.         Statement stmt = null;
  2.         try {
  3.             String URL = "jdbc:mysql://localhost:3306/test";
  4.             Connection conn = DriverManager.getConnection(URL, "****", "****");
  5.  
  6.             stmt = conn.createStatement(
  7.                ResultSet.TYPE_SCROLL_SENSITIVE,
  8.                ResultSet.CONCUR_UPDATABLE
  9.             );
  10.  
  11.             String query = "SELECT * FROM pers";
  12.             ResultSet res = stmt.executeQuery(query);
  13.  
  14.             if (res.absolute(3)) {
  15.                 res.updateString("name", "Xxxx Yyyy");
  16.                 res.updateInt("age", 48);
  17.                 res.updateRow();
  18.             }
  19.         } catch (SQLException ex) {
  20.             System.out.println(ex);
  21.         } finally {
  22.             if (stmt != null) {
  23.                 try {
  24.                     stmt.close();
  25.                     System.out.println("Database Connection closed");
  26.                 } catch (SQLException ex) {
  27.                 }
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement