Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void update(String[] columnsArray, String[] valuesArray, String whereColumn, String whereValue, String table){
- String sql = "UPDATE " + table + " SET ";
- for (int i = 0; i < columnsArray.length; i++) {
- sql += columnsArray[i] + " = " + valuesArray[i] + ", ";
- }
- sql = sql.substring(0, sql.length() - 2);
- sql += " WHERE " + whereColumn + " = " + whereValue;
- System.out.println(sql);
- try{
- stmt = conn.createStatement();
- stmt.executeQuery(sql);
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement