转:Can not issue data manipulation statements with executeQuery()错误解决

下午没事,就练习了下连接数据库,结果发现了一个问题,哈哈

Can not issue data manipulation statements with executeQuery()

原因是这句:

st.executeQuery("insert  into  student  values('"+name+"','"+age+"','"+introduce+"')") ;

 

我是看了书上一个例子,然后开始模仿,发现问题后,发现书上其他程序语句都是用这句,

后来看了几个网页,才明白这句应该该成这样子:

 

st.execute("insert  into  student  values('"+name+"','"+age+"','"+introduce+"')") ;

 

最后总结:如果你的SQL 语句是诸如update,insert的更新语句,应该用statement的execute()方法,如果用的是statement的executeQuery()就会出现上诉问题.

原文地址:http://blog.csdn.net/cherishme1988/article/details/7399225

posted @ 2014-10-26 12:03  技术宅星云  阅读(1542)  评论(0)    收藏  举报