Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void update(String[] columnsArray, String[] valuesArray, String whereCol, String whereVal, 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 " + whereCol + " = '" + whereVal + "'";
- 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