Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1.  public boolean saveToDatabase() {//////////////////////////creating phone //method to get custID before posting from page
  2.         boolean saved = false;
  3.         Connection c = DBHelperClass.getConnection();
  4.         if (c != null) {
  5.             try {
  6.                 Statement s = c.createStatement();
  7.                 String template = "INSERT INTO phones (custID, brand ) VALUES (?, ?)";
  8.                 PreparedStatement inserter = c.prepareStatement(template);
  9.                 inserter.setInt(1, this.custID);
  10.                 inserter.setString(2, this.brand);
  11.                 inserter.executeUpdate();
  12.                 saved = true;
  13.             } catch (SQLException ex) {
  14.                 Logger.getLogger(Customer_phoneAuction.class.getName()).log(Level.SEVERE, null, ex);
  15.             }
  16.  
  17.         }
  18.         return saved;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement