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

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);”


你可能感兴趣的:(java,mysql,jdbc)