六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 196|回复: 0

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

[复制链接]

升级  60%

6

主题

6

主题

6

主题

童生

Rank: 1

积分
30
 楼主| 发表于 2013-2-7 21:08:07 | 显示全部楼层 |阅读模式
 
这个是链接地址
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 displayed  System.out.println(" debuggable statement= " + ps.toString()); 
 
附件是这段代码中用到的类。
 
 
 
 
 
 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表