首页 > 学院 > 开发设计 > 正文

JDBC判断数据库中表是否存在

2019-11-09 13:30:09
字体:
来源:转载
供稿:网友
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;  }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表