Bug #4510 connector/j 3.13. beta does not handle integers correctly
Submitted: 12 Jul 2004 5:32 Modified: 12 Jul 2004 17:44
Reporter: Rafael Steil Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S2 (Serious)
Version:3.1.3 beta OS:Microsoft Windows (Windows / Linux)
Assigned to:

[12 Jul 2004 5:32] Rafael Steil
When using auto_increment columns ( int type ) , connector/j ends with an exception when the new id is bigger than 32767. This error does not occur in previous versions. I'hve tested both under linux ( 4.0.12 ) and windows (  4.0.15-nt ). 
The exception raised is 

java.sql.SQLException: Illegal operation on empty result set.
	at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:4648)
	at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1229)

For example, consider the table

create table autokeytest ( word_id int not null primary key auto_increment, word varchar(100));

When trying to insert data into this table using Statement.RETURN_GENERATED_KEYS ( when the id is bigger than 32767 ), the exception is throwed. 

How to repeat:
This class, when using connector/j's version 3.1.3 beta, ends with an error.

public class AutoKeysTest {

	public static void main(String[] args) {
		try {
			Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=root");
			PreparedStatement p = conn.prepareStatement("insert into autokeytest ( word ) values ( ? )", Statement.RETURN_GENERATED_KEYS);
			p.setString(1, "blah");
			for (int i = 0; i < 45000; i++) {
				System.out.println("Executing "+ i);
				ResultSet rs = p.getGeneratedKeys();
				System.out.println("Id: "+ rs.getInt(1));
		catch (Exception e) {
[12 Jul 2004 17:44] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at