|
@@ -30,16 +30,10 @@ public class DataMySQL2OracleService extends DataSourceOra {
|
|
|
|
|
|
|
|
|
Statement stmt = connSource.createStatement();
|
|
|
- Statement stmtI = connSource.createStatement();
|
|
|
- Statement stmtU = connSource.createStatement();
|
|
|
- Statement stmtL = connSource.createStatement();
|
|
|
Statement stmtC = connSource.createStatement();
|
|
|
Statement stmtS = connSource.createStatement();
|
|
|
Statement stmtT = connSource.createStatement();
|
|
|
ResultSet rs = null;
|
|
|
- ResultSet rsI = null;
|
|
|
- ResultSet rsU = null;
|
|
|
- ResultSet rsL = null;
|
|
|
ResultSet rsC = null;
|
|
|
ResultSet rsS = null;
|
|
|
ResultSet rsT = null;
|
|
@@ -58,25 +52,14 @@ public class DataMySQL2OracleService extends DataSourceOra {
|
|
|
// System.out.println(inSql);
|
|
|
}
|
|
|
try {
|
|
|
- String sqlL = "select create_time_str from data_sync_upnum where table_id=(select max( table_id ) from data_sync_upnum where repo_name='" + repo_name + "')";
|
|
|
- rsL = stmtL.executeQuery(sqlL);
|
|
|
rs = stmt.executeQuery("select * from " + table_name);
|
|
|
- if (rsL.next()) {
|
|
|
- timeL = rsL.getString("create_time_str");
|
|
|
- String sqlI = "select * from " + table_name + " where date_format(create_date,'%Y%m%d')> date_format('" + timeL + "','%Y%m%d')";
|
|
|
-// System.out.println(sqlI);
|
|
|
- rsI = stmtI.executeQuery(sqlI);
|
|
|
- String sqlU = "select * from " + table_name + " where date_format(create_date,'%Y%m%d')<date_format('" + timeL + "','%Y%m%d') and date_format(update_date,'%Y%m%d')>date_format('" + timeL + "','%Y%m%d')";
|
|
|
-// System.out.println(sqlU);
|
|
|
- rsU = stmtU.executeQuery(sqlU);
|
|
|
- }
|
|
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Date beginTime = new Date();
|
|
|
String start = df.format(beginTime);
|
|
|
Long begin = beginTime.getTime();
|
|
|
System.out.println("任务开始,开始时间为:" + start);
|
|
|
|
|
|
- ResultSetMetaData rsmd = rs.getMetaData();
|
|
|
+// ResultSetMetaData rsmd = rs.getMetaData();
|
|
|
// rsS.last();
|
|
|
// int numberOfColumns = rsmd.getColumnCount();
|
|
|
int numberOfColumns = 0;
|
|
@@ -91,61 +74,6 @@ public class DataMySQL2OracleService extends DataSourceOra {
|
|
|
}
|
|
|
pstmt = connDest.prepareStatement(inSql);
|
|
|
|
|
|
- rsL.beforeFirst();
|
|
|
-
|
|
|
- if (rsL.next()) {
|
|
|
- rsI.beforeFirst();
|
|
|
- rsU.beforeFirst();
|
|
|
-// if (rsI.next()) {
|
|
|
- int j = 0;
|
|
|
- while (rsI.next()) {
|
|
|
- j++;
|
|
|
- for (int i = 1; i <= numberOfColumns - 2; i++) {
|
|
|
- String value = rsI.getString(i);
|
|
|
- String column_name=rsI.getMetaData().getColumnName(i);
|
|
|
- String issm=(String)smMap.get(column_name);
|
|
|
- if("0".equals(issm)){
|
|
|
- SM4Utils sm4 = new SM4Utils();
|
|
|
- sm4.secretKey = "1234567887654321";
|
|
|
- value = sm4.decryptData_ECB(value);
|
|
|
- }
|
|
|
- pstmt.setString(i, value);
|
|
|
- }
|
|
|
- pstmt.setObject(numberOfColumns - 1, "I");
|
|
|
- pstmt.setObject(numberOfColumns, up_num);
|
|
|
-// System.out.print("-");
|
|
|
- pstmt.addBatch();
|
|
|
- if (j % 500 == 0) {
|
|
|
- pstmt.executeBatch();
|
|
|
- }
|
|
|
- pstmt.executeBatch();
|
|
|
- }
|
|
|
-// }else if(rsU.next()) {
|
|
|
- while (rsU.next()) {
|
|
|
- j++;
|
|
|
- for (int i = 1; i <= numberOfColumns - 2; i++) {
|
|
|
- String value = rsU.getString(i);
|
|
|
- String column_name=rsU.getMetaData().getColumnName(i);
|
|
|
- String issm=(String)smMap.get(column_name);
|
|
|
- if("0".equals(issm)){
|
|
|
- SM4Utils sm4 = new SM4Utils();
|
|
|
- sm4.secretKey = "1234567887654321";
|
|
|
- value = sm4.decryptData_ECB(value);
|
|
|
- }
|
|
|
- pstmt.setString(i, value);
|
|
|
- }
|
|
|
- pstmt.setObject(numberOfColumns - 1, "U");
|
|
|
- pstmt.setObject(numberOfColumns, up_num);
|
|
|
-// System.out.print("-");
|
|
|
- pstmt.addBatch();
|
|
|
- if (j % 500 == 0) {
|
|
|
- pstmt.executeBatch();
|
|
|
- }
|
|
|
- pstmt.executeBatch();
|
|
|
- }
|
|
|
-// }
|
|
|
- pstmt.executeBatch();
|
|
|
- } else {
|
|
|
int j = 0;
|
|
|
while (rs.next()) {
|
|
|
j++;
|
|
@@ -164,14 +92,13 @@ public class DataMySQL2OracleService extends DataSourceOra {
|
|
|
}
|
|
|
pstmt.setObject(numberOfColumns - 1, "I");
|
|
|
pstmt.setObject(numberOfColumns, up_num);
|
|
|
-// System.out.print("-");
|
|
|
+// pstmt.executeUpdate();
|
|
|
pstmt.addBatch();
|
|
|
if (j % 500 == 0) {
|
|
|
pstmt.executeBatch();
|
|
|
}
|
|
|
}
|
|
|
pstmt.executeBatch();
|
|
|
- }
|
|
|
Date finishTime = new Date();
|
|
|
Long end = finishTime.getTime();
|
|
|
long timeLag = end - begin;
|
|
@@ -196,15 +123,6 @@ public class DataMySQL2OracleService extends DataSourceOra {
|
|
|
if (rs != null) {
|
|
|
rs.close();
|
|
|
}
|
|
|
- if (rsI != null) {
|
|
|
- rsI.close();
|
|
|
- }
|
|
|
- if (rsU != null) {
|
|
|
- rsU.close();
|
|
|
- }
|
|
|
- if (rsL != null) {
|
|
|
- rsL.close();
|
|
|
- }
|
|
|
if (rsC != null) {
|
|
|
rsC.close();
|
|
|
}
|
|
@@ -217,15 +135,6 @@ public class DataMySQL2OracleService extends DataSourceOra {
|
|
|
if (stmt != null) {
|
|
|
stmt.close();
|
|
|
}
|
|
|
- if (stmtI != null) {
|
|
|
- stmtI.close();
|
|
|
- }
|
|
|
- if (stmtU != null) {
|
|
|
- stmtU.close();
|
|
|
- }
|
|
|
- if (stmtL != null) {
|
|
|
- stmtL.close();
|
|
|
- }
|
|
|
if (stmtC != null) {
|
|
|
stmtC.close();
|
|
|
}
|