There are two db-oracle and postgresql. Through java, in the interface there is a button, after clicking on which the following occurs, data from one table is extracted from Oracle and inserted into the essence, and then in the postgresql database. How to implement a ban on entering data already taken out with a subsequent activation? Should it be done at the database level or at the Java level? Here is a sample code, with some features, relating exclusively to the system itself.
private static Statement stmt; private static ResultSet rs; private static Connection connection; private void getUsrAndCreateUsr(){ connection = null; String query="select usr_key, usr_status, usr_udf_hrid, usr_last_name, usr_first_name, usr_middle_name, usr_email, usr_udf_hrdateofbirth from usr where usr_status !='Deleted'"; try{ connection = getConnect(); stmt = connection.createStatement(); rs = stmt.executeQuery(query); while (rs.next()){ Long usr_key = rs.getLong("usr_key"); String usr_status = rs.getString("usr_status"); String usr_udf_hrid = rs.getString("usr_udf_hrid"); String usr_last_name = rs.getString("usr_last_name"); String usr_first_name = rs.getString("usr_first_name"); String usr_middle_name = rs.getString("usr_middle_name"); String usr_email = rs.getString("usr_email"); java.sql.Date usr_udf_hrdateofbirth = rs.getDate("usr_udf_hrdateofbirth"); RUser newUser = new RUser(); newUser.setStatus(dictContentService.getDictContentByCode(111L, usr_status)); newUser.setCode(usr_udf_hrid); newUser.setLastName(usr_last_name); newUser.setFirstName(usr_first_name); newUser.setMiddleName(usr_middle_name); newUser.setEmail(usr_email); newUser.setBirthDate(usr_udf_hrdateofbirth); newUser.setDescription("from Oracle"); newUser.setLocked(false); userService.saveBase(newUser); } }catch (SQLException sqlEx) { sqlEx.printStackTrace(); }finally{ try { connection.close(); } catch(SQLException se) { /*can't do anything */ } try { stmt.close(); } catch(SQLException se) { /*can't do anything */ } try { rs.close(); } catch(SQLException se) { /*can't do anything */ } } }