查询死锁

    public void getLockInfo() throws ClassNotFoundException, SQLException {
        log.info("开始执行SQL语句查询Lock信息");
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/devtools?characterEncoding=utf-8&useSSL=false", "root", "pas");
        PreparedStatement preparedStatement = connection.prepareStatement("show engine innodb status");
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            String type = resultSet.getString("Type");
            String status = resultSet.getString("Status");
            String[] statusList = status.split("\n");

            for (String st : statusList) {
                log.info("hh - {}", st);
            }
        }


        log.info("结束执行SQL语句查询Lock信息");
    }
posted @ 2021-05-26 01:20  宋不争  阅读(51)  评论(0编辑  收藏  举报