如何获得PreparedStatement最终执行的sql语句
这个是链接地址
http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-overpower.html
自己试了试,成功。
靠谱,推荐大家使用。
Connection 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 displayedSystem.out.println(" debuggable statement= " + ps.toString());
附件是这段代码中用到的类。
页:
[1]