Bug #17945 Defect in Sample Code of 18.3.1 Basic JDBC concepts
Submitted: 6 Mar 2006 1:26 Modified: 28 Jul 2006 13:04
Reporter: Brian Brooks Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Documentation Severity:S3 (Non-critical)
Version:5.1 OS:N/A
Assigned to: MC Brown CPU Architecture:Any

[6 Mar 2006 1:26] Brian Brooks
Description:
There is a defect in  MySQL 3.23, 4.0, 4.1 Reference Manual :: 18 Connectors :: 18.3 MySQL Connector/J :: 18.3.1 Basic JDBC concepts :: 18.3.1.3 Using CallableStatements to Execute Stored Procedures.

http://dev.mysql.com/doc/refman/4.1/en/cj-using-callable-statements.html?ff=nopfpls

The sample code has a defect.  To correct the code replace most references to 'cStmt' with 'rs'.  Like below

    while (hadResults) {
        ResultSet rs = cStmt.getResultSet();

        // process result set
        ...

        hadResults = rs.getMoreResults();
    }

    //
    // Retrieve output parameters
    //
    // Connector/J supports both index-based and
    // name-based retrieval
    //

    int outputValue = rs.getInt(2); // index-based
    outputValue = rs.getInt("inOutParam"); // name-based

...

How to repeat:
Try to execute the sample code.  You'll get compile errors.

Suggested fix:
See description.
[6 Mar 2006 11:53] Valeriy Kravchuk
Verified just as described. Examples in documentation should be checked and corrected.
[28 Jul 2006 13:04] MC Brown
Fixed in the C/J documentation.