/**
* 查询数据库是否有某表
* @param cnn
* @param tableName
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
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;
}
查询数据库是否存在某表
猜你喜欢
转载自wjch-111.iteye.com/blog/1612293
今日推荐
周排行