Bug #70726 Wrong ResultSet.getType() values for internally generated ResultSets

Submitted: 25 Oct 2013 10:06 Modified: 28 Feb 2022 9:40
Reporter: Filipe Silva Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.26 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any

[25 Oct 2013 10:06] Filipe Silva
Description:
The ResultSet retrieved from Statement.getGeneratedKeys() has and invalid type, equals to 0.

The same happens with all ResultSets obtained from MetaData objects, unless useInformationSchema=true is used, in which case their type is TYPE_FORWARD_ONLY.

How to repeat:
Just obtain ResultSets from Statement.getGeneratedKeys() or any RS/DB MetaData object that returns a ResultSet and call .getType().

Returned value should be 1003 instead of 0.

Suggested fix:
Set default ResultSet type value to ResultSet.TYPE_FORWARD_ONLY.
[25 Oct 2013 10:07] Filipe Silva
Verified by the reporter.
[2 Jan 2016 22:32] Ramin Orujov
Test case

Attachment: Bug70726.java (text/x-java), 1.58 KiB.

[2 Jan 2016 22:34] Ramin Orujov
Fixed this bug 

create table test.bug70726(
    id int primary key auto_increment,
    str varchar(20)
);

insert into test.bug70726 values(null, 'a');
insert into test.bug70726 values(null, 'b');
insert into test.bug70726 values(null, 'c');

select * from test.bug70726;

# output before fix, result set type is 0 
raminorujov@ro--ubuntu:~/Downloads$ javac -cp .:mysql-connector-java-5.1.38-SNAPSHOT-bin.jar Bug70726.java 
raminorujov@ro--ubuntu:~/Downloads$ java -cp .:mysql-connector-java-5.1.38-SNAPSHOT-bin.jar Bug70726
insert count = 1
Statement.getGeneratedKeys() result set type = 0
id = 8
DatabaseMetaData.getCatalogs() result set type = 0
information_schema
mysql
performance_schema
test
raminorujov@ro--ubuntu:~/Downloads$ 

# output after fix, result set type is 1003 TYPE_FORWARD_ONLY
raminorujov@ro--ubuntu:~/repo/ro-mysql-connector-j/mysql-connector-j$ cp build/mysql-connector-java-5.1.38-SNAPSHOT/mysql-connector-java-5.1.38-SNAPSHOT-bin.jar ~/Downloads/
raminorujov@ro--ubuntu:~/repo/ro-mysql-connector-j/mysql-connector-j$ cd ~/Downloads/
raminorujov@ro--ubuntu:~/Downloads$ java -cp .:mysql-connector-java-5.1.38-SNAPSHOT-bin.jar Bug70726
insert count = 1
Statement.getGeneratedKeys() result set type = 1003
id = 9
DatabaseMetaData.getCatalogs() result set type = 1003
information_schema
mysql
performance_schema
test
raminorujov@ro--ubuntu:~/Downloads$
[28 Feb 2022 9:40] Alexander Soklakov
Posted by developer:
 
This bug is not reproducible with the latest Connector/J 8.0.

Connector/J 5.1 series came to EOL on Feb 9th, 2021, see https://www.mysql.com/support/eol-notice.html, so this bug will not be fixed there.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.062 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.