亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網
    最全最豐富的資訊網站

    java判斷數據庫是否存在

    java判斷數據庫是否存在

    java判斷數據庫是否存在的代碼:

    public static boolean isExistDatabase(String database) {         Connection conn = null;         Statement stmt = null;         ResultSet rs = null;// 數據庫結果集         try {             conn = getConnection();             stmt = conn.createStatement();             String sql = "SELECT COUNT(*) FROM information_schema.schemata WHERE schema_name="" + database + """;             System.out.println(sql);             rs = stmt.executeQuery(sql);             if (rs.next()) {                 if (rs.getInt(1) == 0) {                     return false;                 } else {                     return true;                 }             }             return false;         } catch (Exception e) {             throw new TenantException(e.getMessage(), Status.INTERNAL_SERVER_ERROR);         } finally {             try {                 if (rs != null) {                     rs.close();                 }                 if (stmt != null) {                     stmt.close();                 }                 if (conn != null) {                     conn.close();                 }             } catch (SQLException e) {                 throw new TenantException("mysql關閉連接失敗:" + e.getMessage(), Status.INTERNAL_SERVER_ERROR);             }         }     }

    關鍵SQL語法:

    String sql = "SELECT COUNT(*) FROM information_schema.schemata WHERE schema_name="" + database + """;

    贊(0)
    分享到: 更多 (0)
    網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號