如何获得PreparedStatement最终执行的sql语句

2025-03-11 00:51:34
推荐回答(1个)
回答1:

靠谱,推荐大家使用。�0�2�0�2Connection con = DriverManager.getConnection(url); DebugLevel debug = DebugLevel.ON; String sql = "SELECT name,rate FROM EmployeeTable WHERE rate > ?"; //Use a factory instead of Connection to get a PreparedStatement. //PreparedStatement ps = con.prepareStatement(sql); PreparedStatement ps = StatementFactory.getStatement(con,sql,debug); ps.setInt(1,25); //If ps is a DebuggableStatement, you see the statement, //otherwise, an object identifier is displayed System.out.println(" debuggable statement= " + ps.toString());�0�2�0�2附件是这段代码中用到的类。�0�2�0�2�0�2�0�2�0�2�0�2�0�2