大家好,又见面了,我是你们的朋友全栈君。
private List<String> getTableNames(DatabaseMetaData md) throws SQLException {
ArrayList<String> tables = new ArrayList<String>();
ResultSet rs = md.getTables(null, null, "", null);
while (rs.next()) {
tables.add(rs.getString("TABLE_NAME")); //表名
Logger.info("Comment: " + rs.getString("REMARKS")); //表名的注释
}
return tables;
}
此时获取不到表名的注释,原因是需要在jdbc url 添加如下参数useInformationSchema=true
jdbc_url=jdbc:mysql://127.0.0.1:3306/raw-data?useUnicode=true&characterEncoding=UTF-8&useInformationSchema=true
参考 mysql DatabaseMetaData 获取table remarks为空的解决办法_gavin_新浪博客
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/150989.html原文链接:https://javaforall.net