elkers
2025-04-07 bd9808a81b1eafdc75a42c1c9904408dc888061d
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
package com.nanjing.water;
 
import com.nanjing.water.common.util.StringUtil;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;
 
public class MySqlExportTest {
    public static void main(String[] args) {
        String dbName = "water_basic";
 
        Connection CONN;
        //加载驱动
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        //获得连接
        try {
            CONN = DriverManager.getConnection("jdbc:mysql://113.250.189.120:23306/" + dbName + "?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false",
                    "lunhan", "lunhan123");
        } catch (SQLException e) {
            System.out.println(e.toString());
            return;
        }
 
        List<String> listSql = GenCodeMysql.export(CONN, dbName);
        String sql = StringUtil.join(listSql, "\n\n");
 
        System.out.println(sql);
    }
}