/** Inserts pkg new pkg into the database */ private void insert(AreaOfInterest pkg, Connection conn) throws Exception { PreparedStatement pstmt = conn.prepareStatement("INSERT INTO AreaOfInterest VALUES (?,?)"); pstmt.setString(1, pkg.getId()); pstmt.setString(2, pkg.getDescription()); int numUpd = pstmt.executeUpdate(); if (numUpd == 1) { pkg.setObjectAlreadyInDB(true); pkg.setDirty(false); } else { throw new DataException("bad AreaOfInterest update"); } pstmt.close(); }
/** Saves an existing pkg to the database */ private void update(AreaOfInterest pkg, Connection conn) throws Exception { PreparedStatement pstmt = conn.prepareStatement("UPDATE AreaOfInterest SET description=? WHERE guid LIKE ?"); pstmt.setString(1, pkg.getDescription()); pstmt.setString(2, pkg.getId()); int numUpd = pstmt.executeUpdate(); if (numUpd == 1) { pkg.setObjectAlreadyInDB(true); pkg.setDirty(false); } else { throw new DataException("bad AreaOfInterest update"); } pstmt.close(); }