update
This commit is contained in:
@@ -45,9 +45,9 @@ public class TestClass {
|
||||
|
||||
private static Connection getNmsConnection(){
|
||||
String driver ="com.mysql.jdbc.Driver";
|
||||
String url="jdbc:mysql://10.0.6.247:3306/nms";
|
||||
String username="nms";
|
||||
String password="nms";
|
||||
String url="jdbc:mysql://192.168.10.126:3306/nms-dev";
|
||||
String username="root";
|
||||
String password="111111";
|
||||
Connection conn=null;
|
||||
try{
|
||||
Class.forName(driver);
|
||||
@@ -91,16 +91,21 @@ public class TestClass {
|
||||
@Test
|
||||
public void importData(){
|
||||
Connection nmsConn = getNmsConnection();
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement pstmt=null;
|
||||
PreparedStatement pstmt2=null;
|
||||
try {
|
||||
pstmt=(PreparedStatement)nmsConn.prepareStatement("select table_name as tn from information_schema.tables where TABLE_SCHEMA='nms'");
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
pstmt2=(PreparedStatement)conn.prepareStatement("insert into table_sync_info (table_name,event,last_id,last_date,db_id,mode) values (?,?,?,?,?,?)");
|
||||
pstmt2=(PreparedStatement)nmsConn.prepareStatement("insert into table_sync_info (table_name,event,last_id,last_date,db_id,mode) values (?,?,?,?,?,?)");
|
||||
while(resultSet.next()){
|
||||
String tableName = resultSet.getString("tn");
|
||||
|
||||
if(tableName.indexOf("d")==0) {
|
||||
continue;
|
||||
}else if(tableName.indexOf("m")==0) {
|
||||
continue;
|
||||
}else if(tableName.indexOf("v_")==0) {
|
||||
continue;
|
||||
}
|
||||
pstmt2.setString(1, tableName);
|
||||
pstmt2.setInt(2, 1);
|
||||
pstmt2.setInt(3, 1);
|
||||
@@ -144,7 +149,7 @@ public class TestClass {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
conn.close();
|
||||
nmsConn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user