public Boolean judgeTableIsExit(String tableName) { Connection conn = null; ResultSet rs = null; try { String[] types = {"TABLE"}; conn = SessionFactoryUtils.getDataSource(getSession().getSessionFactory()).getConnection(); DatabaseMetaData dbMetaData = conn.getMetaData(); rs = dbMetaData.getTables( null, null, DbTableUtil.getDataType(getSession()).equals("ORACLE") ? tableName.toUpperCase() : tableName, types); if (rs.next()) { return true; } else { return false; } } catch (SQLException e) { throw new RuntimeException(); } finally { // 关闭连接 try { if (rs != null) { rs.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { e.printStackTrace(); } } }
/** * 获取数据操作接口 * * @return */ private DbTableHandleI getTableUtil() { return DbTableUtil.getTableHandle(getSession()); }