如何启动JDBC Debug模式,打印JDBC诊断日志
1.下载Debug版本jar包</strong></span>
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); String loader = Thread.currentThread().getContextClassLoader().toString().replaceAll("[,=:\"]+", ""); ObjectName pattern = new ObjectName("com.oracle.jdbc:type=diagnosability,name=" + loader); ObjectName diag = ((ObjectName[]) (mbs.queryNames(pattern, null).toArray(new ObjectName[0])))[0]; mbs.setAttribute(diag, new Attribute("LoggingEnabled", true)); System.out.println("LoggingEnabled = " + mbs.getAttribute(diag, "LoggingEnabled"));