Bug #119261 Statement.executeQuery() cannot issue statements that do not produce result sets.
Submitted: 29 Oct 6:39 Modified: 30 Oct 18:58
Reporter: Lasse Lindqvist Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:9.5.0 OS:Any
Assigned to: CPU Architecture:Any

[29 Oct 6:39] Lasse Lindqvist
Description:
Updating from 9.4.0 to 9.5.0 gives unwanted "Statement.executeQuery() cannot issue statements that do not produce result sets." errors when executing some simple queries of type

For me this was reproduced via Spring Data Repository like

@Repository
public interface SomeRepository extends JpaRepository<Some, Long> {
	Optional<Some> findByOtherId(Long otherId);
}

and the generated SQL is of type:

select some_0.id, ... , some_0.version 
from some some_0 
where some_0.other_id=?] 
[Statement.executeQuery() cannot issue statements that do not produce result sets.] [n/a]

These are Hibernate generated SQL and not hand made, although it was reproduced also with one hand made relatively simple select query.

https://github.com/mysql/mysql-connector-j/compare/9.4.0...9.5.0 had changes in QueryInfo class and I think those are what cause these bugs in some statements. 99 % of statements still execute correctly.

How to repeat:
I do not yet have SQL statements that I can share because this is work code.

But I think the parser is faulty when handling "select into", because one of the columns contains text "printout" which in itself contains "into" and this is handled wrong.
[30 Oct 13:42] Felix Feisst
I can confirm this bug. Here is a reproduction scenario:

I have a table t1 with three BIGINT column id, underlying_id, mergedinto_id. As soon as a query contains the mergedinto_id column, the exception occurs:

DataSource dataSource = ...
dataSource.getConnection().createStatement().executeQuery("select underlying_id from t1 where id=3");
dataSource.getConnection().createStatement().executeQuery("select mergedinto_id from t1 where id=3");

In the above example the first query runs just quite fine, the second query gets the following exception:

java.sql.SQLException: Statement.executeQuery() cannot issue statements that do not produce result sets.

	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:121)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:81)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:55)
	at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1238)
[30 Oct 18:58] Filipe Silva
Thank you for your interest in MySQL Connector/J and for taking the time to report this.

Duplicate of Bug#119245.