首页 > 数据库技术 > 详细

[自动化专题]JDBC操作mysql时遇到的拦路虎

时间:2015-03-26 16:45:00      阅读:256      评论:0      收藏:0      [点我收藏+]

在挫折中成长,在错误中学习。聊聊我们在Selenium自动化中使用JDBC操作mysql数据库中遇到的那些拦路虎:

 

错误一:Can not issue data manipulation statements with executeQuery()

报错场景:执行statement.executeQuery("delete from table where....."),结果执行失败,日志记录以上报错;在mysql客户端检查sql语句是ok的。

问题分析:如果你的SQL 语句是诸如update,insert,delete等更新语句时,应该用statement.execute()方法,如果用的是statement的executeQuery()就会出现上述问题

总结:了解statement的常用方法,

         statement.executeQuery("select .........")   executeQuery参数sql一般是select.....

         statement.execute("update...")  execute参数sql一般是update,insert,delete等更新语句

 

错误二:使用JDBC查询mysql中数据,查询条件为中文时,查询不到数据

JDBC mysql 中文查询不到数据解决

[自动化专题]JDBC操作mysql时遇到的拦路虎

原文:http://www.cnblogs.com/sylvia-liu/p/4368848.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!