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

1.这个异常的报错翻译过来就是

不能发出数据操纵语句与executeQuery()

2.这里要检查一下你要执行的实际SQL语句要做什么操作

查询呢?还是修改?

3.如果是修改的话,需要添加@Modifying注解,这样程序才知道这是一个修改语句,同时要添加事物的管理

可以这样进行更改

 executeQurery()改成excuteUpdate() 

时间: 2024-08-04 04:00:23

Can not issue data manipulation statements with executeQuery() 异常处理的相关文章

兔子-- 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

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

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

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

[Hive - LanguageManual] Hive Data Manipulation Language

LanguageManual DML Hive Data Manipulation Language Hive Data Manipulation Language Loading files into tables Syntax Synopsis Notes Inserting data into Hive Tables from queries Syntax Synopsis Notes Dynamic Partition Inserts Example Additional Documen

Data manipulation primitives in R and Python

Data manipulation primitives in R and Python Both R and Python are incredibly good tools to manipulate your data and their integration is becoming increasingly important1. The latest tool for data manipulation in R is Dplyr2 whilst Python relies onPa

Hive 6、Hive DML(Data Manipulation Language)

DML主要是对Hive 表中的数据进行操作的(增 删 改),但是由于Hadoop的特性,所以单条的修改.删除,其性能会非常的低所以不支持进行级操作: 主要说明一下最常用的批量插入数据较为常用的方法: 1.从文件中加载数据 语法:LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)] 例: load data local i

Data manipulation in python (module 6)

1. Pandas plotting import matplotlib.pyplot as plt import numpy as np import pandas as pd %matplotlib notebook plt.style.use("seaborn-colorblind") np.random.seed(123) # cumsum: add value_of_i + value_of_i+1 = value_of_i+2 df = pd.DataFrame({'A':