Guest User

jdbc.java

a guest
Jan 14th, 2020
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Override
  2.     public boolean add(FoodItem f) {
  3.         String query = "INSERT INTO Foods (food_name, serving_size, unit) "
  4.                 + "VALUES (?, ?, ?)";
  5.         try (Connection connection = getConnection();
  6.                 PreparedStatement ps = connection.prepareStatement(query)){
  7.             ps.setString(2, f.getServingSize());
  8.             ps.setString(3, f.getUnit());
  9.             return true;
  10.         }catch (SQLException e){
  11.             System.err.println(e);
  12.             return false;
  13.         }
  14.     }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×