Code:
- public void TransferData() {
-
- System.out.println("Starting Transfer...");
- long startTimeMS = System.currentTimeMillis( );
- try {
- Statement stmt = sqlConn.createStatement();
- ResultSet rs = stmt.executeQuery("select distinct c.location_cd, c.customer_no, ue.unit_no " +
- " from CINTAS.cadmin.unit_Extension ue " +
- " inner join CINTAS.cadmin.customer c " +
- " on ( ue.cust_id = c.cust_id ) " +
- " left outer join CINTAS.cadmin.unit u " +
- " on ( ue.cust_id = u.cust_id AND ue.unit_no = u.unit_no ) " +
- " where u.cust_id IS NULL ");
- System.out.println("---ResultSet in: " + Long.toString(System.currentTimeMillis( ) - startTimeMS));
-
- i5Conn.setAutoCommit(false);
- //i5Conn.setTransactionIsolation(JDBC_TRANSACTION_READ_COMMITTED);
- startTimeMS = System.currentTimeMillis( );
- PreparedStatement ps = i5Conn.prepareStatement("INSERT INTO CINTASDTA.INACTCAB VALUES(?,?,?)");
- System.out.println("---StmtPrepared in: " + Long.toString(System.currentTimeMillis( ) - startTimeMS));
-
-
- startTimeMS = System.currentTimeMillis( );
- int nbrRecs = 0;
- while (rs.next()) {
- ps.setString(1,rs.getString(1));
- ps.setInt(2,rs.getInt(2));
- ps.setString(3,rs.getString(3));
- //ps.executeUpdate();
- ps.addBatch();
- nbrRecs += 1;
- if (nbrRecs >= 5000) {
- ps.executeBatch();
- i5Conn.commit();
- nbrRecs = 0;
- }
-
- }
-
- ps.executeBatch();
- i5Conn.commit();
-
- System.out.println("---Data inserted in: " + Long.toString(System.currentTimeMillis( ) - startTimeMS));
-
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- }
- }
-
-
|
|