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()就会出现上诉问题

转自:https://blog.csdn.net/cherishme1988/article/details/7399225

猜你喜欢

转载自www.cnblogs.com/xiaodongxiaodong/p/9284907.html