1821349743@qq.com
2023-02-20 a387ff8978bd0e738e83e0277cfa38d7c3ab3080
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.product.data.sync.test;
 
import com.alibaba.fastjson.JSONObject;
import com.product.common.utils.HttpTest;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @author: ZhouJie
 * @date: 2021/8/12 9:29
 * @description:
 */
 
public class SyncConfigTest extends HttpTest {
    private static String URL_STRING[] = {
            "jdbc:informix-sqli://localhost:9092/test:informixserver=demores",
//            "jdbc:ids://9.123.147.100:10000/sysmaster"
    };
    private static String USER = "informix";
    private static String PASSWORD = "123456";
 
    public static void main(String[] args) {
        try {
            connectInForMix();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
//        saveSync();
//        delSync();
    }
 
    //保存数据库同步配置
    public static void saveSync() {
        Map<String, Object> m = new HashMap<>();
        m.put("url/api", "/api/sync/save-syncconfig/v1");
        m.put("~table~", "product_sys_database_sync_config");
        //m.put("uuid", "5507c128-368b-4143-a4e1-7e81aeac349d");//传uuid是修改 不传新增
        m.put("database_config_uuid", "test002-sdfqwe45w-4jhn4n-qweqwe");
        m.put("corn", "0/10 * * * * ?");
 
        List sub = new ArrayList();
        Map sub1 = new HashMap();
        sub1.put("created_by", "100");
        sub1.put("created_utc_datetime", "2021-08-13 09:00:09");
        sub1.put("updated_by", "100");
        sub1.put("updated_utc_datetime", "2021-08-13 09:00:09");
        sub1.put("org_level_uuid", "test801021test002");
        sub.add(sub1);
        m.put("product_sys_database_sync_config_sub", sub);
        System.out.println(new JSONObject(m).toJSONString());
 
        testPost(m);
    }
 
    //删除数据库同步配置
    public static void delSync() {
        Map<String, Object> m = new HashMap<>();
        m.put("url/api", "/api/sync/delete-syncconfig/v1");
        m.put("~table~", "product_sys_database_sync_config");
        m.put("uuid", "7b9be61c-c15e-4915-b1fd-d7f4ee9b9134,414315de-59c6-4d87-ae7e-b4ef30c20ca3");
 
    }
 
    public static void connectInForMix() throws ClassNotFoundException {
        Connection conn;
        Class.forName("com.informix.jdbc.IfxDriver");
//        Class.forName("com.ibm.db2.jcc.DB2Driver");
        try {
            System.out.println("Testing JDBC URL: " + URL_STRING[0]);
            conn = DriverManager.getConnection(URL_STRING[0], USER, PASSWORD);
            Integer num = 0;
            for (int j = 0; j < 50; j++) {
                StringBuffer insertSql = new StringBuffer();
                for (int i = 0; i < 1000; i++) {
                    insertSql.append(" INSERT INTO test_project(name,money,describe)VALUES");
                    insertSql.append("('name").append(i).append("',").append(i).append(",'").append("describe").append(i).append("');");
                }
                PreparedStatement ps = conn.prepareStatement(insertSql.toString());
 
                num = num + ps.executeUpdate();
            }
            System.out.println("新增数据" + num + "条。");
            conn.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return;
    }
}