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

1、错误描述

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

时间: 2024-07-30 13:52:23

java.sql.SQLException:Can not issue data manipulation statements with executeQuery()的相关文章

java sql SQLException Can not issue data manipulation statem

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.getConnecti

兔子-- Can not issue data manipulation statements with executeQuery()

  Can not issue data manipulation statements with executeQuery() 出错地方:st.executeQuery("insert  into  student  values("1","2","3")") ; 如果你的SQL 语句是 update,insert等更新语句,用statement的execute() 如果sql语句是查询语句则用statement.execu

Can not issue data manipulation statements with executeQuery()的解决方案

Can not issue data manipulation statements with executeQuery() 报错的解决方案: 把"ResultSet rs = statement.executeQuery(sql);"改成"boolean rs = statement.execute(sql);"就不会报错了. 原因是查询sql是把查询的结果都打印出来,修改更新(update)只需要判断是否执行成功,不需要打印结果, 所以这里不能用executeQ

Can not issue data manipulation statements with executeQuery() 异常处理

1.这个异常的报错翻译过来就是 不能发出数据操纵语句与executeQuery() 2.这里要检查一下你要执行的实际SQL语句要做什么操作 查询呢?还是修改? 3.如果是修改的话,需要添加@Modifying注解,这样程序才知道这是一个修改语句,同时要添加事物的管理 可以这样进行更改  executeQurery()改成excuteUpdate() 

Can not issue data manipulation statements with executeQuery().解决的方法

query是查询用的,而update是插入和更新,删除修改用的. executeQuery()语句是用于产生单个结果集的语句,如select语句,在什么情况下用,当你的数据库已经保存了数据后,要进行查询了. executeUpdate(),用于执行insert.update或者delete语句,返回值一个表示受影响的行数,即更新值execute()运行语句,返回是否有结果集. 如下这样写就没有问题了. String sql = "insert into student(id,name,age,s

FSG报表打印报错,log文件显示java.sql.SQLException: No corresponding LOB data found

报错信息: +---------------------------------------------------------------------------+ Plsql 程序的日志信息开始 +---------------------------------------------------------------------------+ +-----------------------------------------------------------------------

java.sql.SQLException: Can not issue empty query.

1.错误叙述性说明 java.sql.SQLException: Can not issue empty query. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:

Caused by java sql BatchUpdateException Can not issue exec

1.错误描述 org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [select student_id from b_student where student_code=? ]; Can not issue executeUpdate() for SELECTs; nested exception is java.sql.BatchUpdateException: Can

Caused by: java.sql.SQLException: ResultSet is from UPDATE. No Data.

1.错误描述 org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql