SHARE
TWEET

8. Increase Minions Age

N_Damyanov Jun 16th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void increaseMinionsAge() throws IOException, SQLException {
  2.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  3.         String[] input = br.readLine().split("\\s+");
  4.         String idToChange = String.join(", ", input);
  5.         ResultSet resultSet;
  6.         Statement statement;
  7.         statement = connection.createStatement();
  8.         statement.executeUpdate(String.format("UPDATE minions SET age = age + 1, name = lower(name) WHERE id IN (%s);", idToChange));
  9.  
  10.         resultSet = statement.executeQuery("SELECT name, age FROM minions_db.minions;");
  11.  
  12.         while (resultSet.next()) {
  13.             System.out.println(resultSet.getString(1) + " " + resultSet.getInt(2));
  14.         }
  15.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top