public boolean getAllTableName(String tableName) throws Exception {
Connection conn = jdbcTemplate.getDataSource().getConnection();
ResultSet tabs = null;
try {
DatabaseMetaData dbMetaData = conn.getMetaData();
String[] types = { "TABLE" };
tabs = dbMetaData.getTables(null, null, tableName, types);
if (tabs.next()) {
return true;
}
} catch (Exception e) {
e.printStackTrace();
}finally{
tabs.close();
conn.close();
}
return false;
}
JDBC判断数据库中表是否存在
最新推荐文章于 2019-06-02 13:15:33 发布