| Bug #113131 | Setting Negative Fetch Size Without Throwing Error | ||
|---|---|---|---|
| Submitted: | 19 Nov 2023 2:59 | Modified: | 21 May 2025 6:18 |
| Reporter: | Wenqian Deng | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 8.1.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[24 Nov 2023 6:40]
MySQL Verification Team
Hello Wenqian Deng, Thank you for the report and test case. Verified as described. regards, Umesh
[11 Dec 2023 16:41]
Axyoan Marcelo
Posted by developer: Hi, see this page: https://dev.mysql.com/doc/connector-j/en/connector-j-reference-implementation-notes.html under ResultSet for more information. In short, the reason why setting fetch size to the min int value (-2147483648) doesn't throw an exception is because Connector/J has a functionality which is enabled by setting fetch size to that specific value.
[12 Jan 2024 1:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".

Description: According to JDBC specifications, setting a fetch size with a negative value should result in an SQLException. However, in the provided test case, when the fetch size is set to -2147483648 (the minimum value of an int), the MySQL JDBC connector accepts this value without throwing any exception, which is contrary to the expected behavior. How to repeat: @Test public void test() throws SQLException { Connection con = null; Statement stmt = null; con = DriverManager.getConnection("jdbc:mysql://localhost:3366/test968?user=user&password=password"); stmt = con.createStatement(1004, 1007, 1); stmt.setFetchSize(-2147483648); // not throwing error System.out.println(stmt.getFetchSize()); }