如何获得PreparedStatement最终执行的sql语句
1个回答
展开全部
靠谱,推荐大家使用。 C onnection con = D riverM anager.getC onnection(url); D ebugLevel debug = D ebugLevel.O N ; String sql = "SELEC T nam e,rate FRO M Em ployeeTable W H ERE rate > ?"; //U se a factory instead of C onnection to get a PreparedStatem ent. //PreparedStatem ent ps = con.prepareStatem ent(sql); PreparedStatem ent ps = Statem entFactory.getStatem ent(con,sql,debug); ps.setInt(1,25); //If ps is a D ebuggableStatem ent, you see the statem ent, //otherw ise, an object identifier is displayed System .out.println(" debuggable statem ent= " + ps.toString()); 附件是这段代码中用到的类。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询