public static void main(String[] args) throws SQLException, ClassNotFoundException {
JowDistr.DB dbConfig = JowDistr.loginConfig.dbConfig;
DBConfig.init("", dbConfig);
Connection conn = DriverManager.getConnection(DBConfig.DB_URL, DBConfig.DB_USER,
DBConfig.DB_PWD);
System.out.println(DBConfig.DB_URL);
DatabaseMetaData databaseMetaData = conn.getMetaData();
// 从DatabaseMetaData获取表信息
ResultSet tableSet = databaseMetaData.getTables(null, "wild_login", "login_account", new String[] { "TABLE" });
while(tableSet.next()) {
System.out.println("---------------------" + tableSet.getString(1));
}
tableSet.close();
ResultSet _tableSet = databaseMetaData.getTables(null, "wild_login", "core_id_allot", new String[] { "TABLE" });
while(_tableSet.next()) {
System.out.println("---------------------" + _tableSet.getString(1));
}
_tableSet.close();
}
打印:
jdbc:mysql://127.0.0.1:3306/wild_login?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&createDatabaseIfNotExist=true
---------------------wild_login
---------------------wild_game0