1. 程式人生 > >java sql SQLException Can not issue data manipulation statem

java sql SQLException Can not issue data manipulation statem

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow

也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!

               

1、錯誤描述

java.sql.SQLException:Can not issue data manipulation statements with executeQuery()


2、錯誤原因

Class.forName("com.mysql.jdbc.Driver");Connection conn = null;Statement stat = null;ResultSet rs = null;try { conn = DriverManager.getConnection(url, username, password); stat = conn.createStatement(); stat.executeQuery(sql);
}
Statement在呼叫查詢SQL方法時,呼叫executeQuery,導致出錯


3、解決辦法

     將“stat.executeQuery(sql);”換成“stat.execute(sql);”


           

給我老師的人工智慧教程打call!http://blog.csdn.net/jiangjunshow

這裡寫圖片描述