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);”
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
原文地址:https://www.cnblogs.com/odejsjhshw/p/10368354.html
时间: 2024-11-09 01:39:08