@Override public void update(Customer entry) throws SQLException { String sql; sql = "UPDATE 'customer' SET " + "name = \'" + entry.getName() + "\', " + "firstName = '" + entry.getFirstName() + "', " + "address = \'" + entry.getAddress() + "\', " + "zip = \'" + entry.getZip() + "\', " + "city = \'" + entry.getCity() + "\', " + "phoneNo = \'" + entry.getPhoneNo() + "\', " + "eMail = \'" + entry.getEMail() + "\'" + "WHERE customerId = " + entry.getID() + ";"; System.out.println(sql); Statement stmt = dbConnection.getConn().createStatement(); stmt.executeUpdate(sql); }
@Override public int insert(Customer entry) throws SQLException { String sql; ResultSet rs = null; sql = "INSERT INTO 'customer' VALUES (null, '" + entry.getName() + "', " + "\'" + entry.getFirstName() + "\', \'" + entry.getAddress() + "\', '" + entry.getZip() + "\', \'" + entry.getCity() + "\', \'" + entry.getPhoneNo() + "\', \'" + entry.getEMail() + "\');"; System.out.println(sql); Statement stmt = dbConnection.getConn().createStatement(); stmt.executeUpdate(sql); PreparedStatement pstmt = dbConnection.getConn().prepareStatement("select max(customerId) max from 'customer';"); rs = pstmt.executeQuery(); if (rs.next()) {; return rs.getInt("max"); } else { return 0; } }