Advertisement
lemansky

Untitled

Nov 19th, 2020
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1.  public void update(String[] columnsArray, String[] valuesArray, String whereColumn, String whereValue, String table){
  2.         String sql = "UPDATE " + table + " SET ";
  3.         for (int i = 0; i < columnsArray.length; i++) {
  4.             sql += columnsArray[i] + " = " + valuesArray[i] + ", ";
  5.         }
  6.         sql = sql.substring(0, sql.length() - 2);
  7.         sql += " WHERE " + whereColumn + " = " + whereValue;
  8.         System.out.println(sql);
  9.         try{
  10.             stmt = conn.createStatement();
  11.             stmt.executeQuery(sql);
  12.         } catch (SQLException e) {
  13.             System.out.println(e.getMessage());
  14.         }
  15.        
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement