package com.lunhan.xxx;

import com.lunhan.xxx.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);
    }
}