@Override public boolean editTenant(TenantBean tenant, String fname, String lname) { try { Connector c = new Connector(); Connection connection = c.getConnection(); String query = "update tenant set image = ?, contact = ?, gender = ?, address = ?, degree = ?, school = ?, expectedyearofgrad = ?, status=? where fname = ? and lname = ? "; PreparedStatement ps = connection.prepareStatement(query); ps.setBlob(1, tenant.getImage()); ps.setDouble(2, tenant.getContact()); ps.setString(3, tenant.getGender()); ps.setString(4, tenant.getAddress()); ps.setString(5, tenant.getDegree()); ps.setString(6, tenant.getSchool()); ps.setInt(7, tenant.getExpectedyearofgrad()); ps.setBoolean(8, tenant.getStatus()); ps.setString(9, fname); ps.setString(10, lname); ps.executeUpdate(); return true; } catch (SQLException ex) { Logger.getLogger(TenantDAOImplementation.class.getName()).log(Level.SEVERE, null, ex); } return false; }
@Override public boolean addTenant(TenantBean tenant) { // important try { Connector c = new Connector(); Connection connection = c.getConnection(); String query = "insert into tenant (tenantID, fname, lname, image, contact, gender, address, degree, school, expectedyearofgrad, status)" + " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; PreparedStatement ps = connection.prepareStatement(query); ps.setInt(1, tenant.getTenantID()); ps.setString(2, tenant.getFname()); ps.setString(3, tenant.getLname()); ps.setBlob(4, tenant.getImage()); // ps.setLong(5, 639166267392L); ps.setLong(5, tenant.getContact()); ps.setString(6, tenant.getGender()); ps.setString(7, tenant.getAddress()); ps.setString(8, tenant.getDegree()); ps.setString(9, tenant.getSchool()); ps.setInt(10, tenant.getExpectedyearofgrad()); ps.setBoolean(11, tenant.getStatus()); ps.executeUpdate(); connection.close(); return true; } catch (SQLException ex) { Logger.getLogger(TenantDAOImplementation.class.getName()).log(Level.SEVERE, null, ex); } return false; }