| Bug #3146 | CallableStatement Output Parameters Indexed Incorrectly | ||
|---|---|---|---|
| Submitted: | 11 Mar 2004 13:29 | Modified: | 11 Mar 2004 13:37 |
| Reporter: | Mark Matthews | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S2 (Serious) |
| Version: | 3.1.1 | OS: | |
| Assigned to: | Mark Matthews | CPU Architecture: | Any |
[11 Mar 2004 13:37]
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
http://www.mysql.com/doc/en/Installing_source_tree.html
Additional info:
This is fixed, and will be available in the nightly build after 00:00 GMT 11-March-04 at http://downloads.mysql.com/snapshots.php

Description: It appears callable statement output parameters are indexed via their order of registration, rather than the order they appear in the prepareCall() method. How to repeat: import java.lang.*; import java.io.*; import java.sql.*; // Notice, do not import com.mysql.jdbc.* // or you will have problems! public class TestInOut_Params { public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (Exception ex) { // handle the error System.out.println("Error Loading MySQL Driver!" + ex); } try { Connection conn = DriverManager.getConnection("jdbc:mysql:///test"); // Do something with the Connection CallableStatement cStmt = conn.prepareCall("{call test_inout_params(?, ?, ?)}"); // 1 = index and 3 = value // cStmt.setInt(1,3); // try param name based set cStmt.setInt("in1", 3); cStmt.registerOutParameter(2,Types.INTEGER); cStmt.registerOutParameter(3,Types.INTEGER); cStmt.execute(); // index based on number of output vars not total number of params int outputValue1 = cStmt.getInt(2); // index-based int outputValue2 = cStmt.getInt(3); // index-based // print the output paramates System.out.println("Result 1: " + outputValue1); System.out.println("Result 2: " + outputValue2); } catch (SQLException ex) { // handle any errors System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } } }