我试图从数据库中加载所有的表,但我不能加载它。我在下面列出的代码是什么。没有错误显示黑色显示我只是得到了输出
Tables Names
--------------------
我把代码附在下面。
Connection con;
PreparedStatement pst;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/db_eatspossible", "root","");
DatabaseMetaData db = con.getMetaData();
String[] tabTypes = {"TABLES"};
System.out.println("");
System.out.println("Tables Names");
System.out.println("----------------------");
ResultSet tb = db.getTables(null, null, null, tabTypes);
while (tb.next())
System.out.println(tb.getString("TABLE_NAME"));
con.close();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
暂无答案!
目前还没有任何答案,快来回答吧!