Logo Search packages:      
Sourcecode: mysql-connector-java version File versions

java.sql.ResultSet com::mysql::jdbc::DatabaseMetaData::getProcedureColumns ( String  catalog,
String  schemaPattern,
String  procedureNamePattern,
String  columnNamePattern 
) throws SQLException [inline]

Get a description of a catalog's stored procedure parameters and result columns.

Only descriptions matching the schema, procedure and parameter name criteria are returned. They are ordered by PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value, if any, is first. Next are the parameter descriptions in call order. The column descriptions follow in column number order.

Each row in the ResultSet is a parameter desription or column description with the following fields:

  1. PROCEDURE_CAT String => procedure catalog (may be null)
  2. PROCEDURE_SCHEM String => procedure schema (may be null)
  3. PROCEDURE_NAME String => procedure name
  4. COLUMN_NAME String => column/parameter name
  5. COLUMN_TYPE Short => kind of column/parameter:

    • procedureColumnUnknown - nobody knows
    • procedureColumnIn - IN parameter
    • procedureColumnInOut - INOUT parameter
    • procedureColumnOut - OUT parameter
    • procedureColumnReturn - procedure return value
    • procedureColumnResult - result column in ResultSet

  6. DATA_TYPE short => SQL type from java.sql.Types
  7. TYPE_NAME String => SQL type name
  8. PRECISION int => precision
  9. LENGTH int => length in bytes of data
  10. SCALE short => scale
  11. RADIX short => radix
  12. NULLABLE short => can it contain NULL?

    • procedureNoNulls - does not allow NULL values
    • procedureNullable - allows NULL values
    • procedureNullableUnknown - nullability unknown

  13. REMARKS String => comment describing parameter/column

Note: Some databases may not return the column descriptions for a procedure. Additional columns beyond REMARKS can be defined by the database.

Parameters:
catalog a catalog name; "" retrieves those without a catalog
schemaPattern a schema name pattern; "" retrieves those without a schema
procedureNamePattern a procedure name pattern
columnNamePattern a column name pattern
Returns:
ResultSet each row is a stored procedure parameter or column description
Exceptions:
SQLException if a database access error occurs
See also:
getSearchStringEscape

Definition at line 2573 of file DatabaseMetaData.java.

References com::mysql::jdbc::PreparedStatement::close(), com::mysql::jdbc::ResultSet::close(), getProcedures(), com::mysql::jdbc::ResultSet::getString(), com::mysql::jdbc::ResultSet::next(), and supportsStoredProcedures().

                                                      {
        if (procedureNamePattern == null) {
        }

        if (columnNamePattern == null) {
        }

        Field[] fields = new Field[13];

        fields[0] = new Field("", "PROCEDURE_CAT", Types.CHAR, 0);
        fields[1] = new Field("", "PROCEDURE_SCHEM", Types.CHAR, 0);
        fields[2] = new Field("", "PROCEDURE_NAME", Types.CHAR, 0);
        fields[3] = new Field("", "COLUMN_NAME", Types.CHAR, 0);
        fields[4] = new Field("", "COLUMN_TYPE", Types.CHAR, 0);
        fields[5] = new Field("", "DATA_TYPE", Types.SMALLINT, 0);
        fields[6] = new Field("", "TYPE_NAME", Types.CHAR, 0);
        fields[7] = new Field("", "PRECISION", Types.INTEGER, 0);
        fields[8] = new Field("", "LENGTH", Types.INTEGER, 0);
        fields[9] = new Field("", "SCALE", Types.SMALLINT, 0);
        fields[10] = new Field("", "RADIX", Types.SMALLINT, 0);
        fields[11] = new Field("", "NULLABLE", Types.SMALLINT, 0);
        fields[12] = new Field("", "REMARKS", Types.CHAR, 0);

        List proceduresToExtractList = new ArrayList();

        if (supportsStoredProcedures()) {
            if ((procedureNamePattern.indexOf("%") == -1) &&
                    (procedureNamePattern.indexOf("?") == -1)) {
                proceduresToExtractList.add(procedureNamePattern);
            } else {
                PreparedStatement procedureNameStmt = null;
                ResultSet procedureNameRs = null;

                try {
                    procedureNameRs = getProcedures(catalog, schemaPattern,
                            procedureNamePattern);

                    // Required to be sorted in name-order by JDBC spec,
                    // in 'normal' case getProcedures takes care of this for us,
                    // but if system tables are inaccessible, we need to sort...
                    // so just do this to be safe...
                    Collections.sort(proceduresToExtractList);

                    while (procedureNameRs.next()) {
                        proceduresToExtractList.add(procedureNameRs.getString(3));
                    }
                } finally {
                    SQLException rethrowSqlEx = null;

                    if (procedureNameRs != null) {
                        try {
                            procedureNameRs.close();
                        } catch (SQLException sqlEx) {
                            rethrowSqlEx = sqlEx;
                        }
                    }

                    if (procedureNameStmt != null) {
                        try {
                            procedureNameStmt.close();
                        } catch (SQLException sqlEx) {
                            rethrowSqlEx = sqlEx;
                        }
                    }

                    if (rethrowSqlEx != null) {
                        throw rethrowSqlEx;
                    }
                }
            }
        }

        ArrayList resultRows = new ArrayList();

        for (Iterator iter = proceduresToExtractList.iterator();
                iter.hasNext();) {
            String procName = (String) iter.next();

            getCallStmtParameterTypes(procName, columnNamePattern, resultRows);
        }

        return buildResultSet(fields, resultRows);
    }


Generated by  Doxygen 1.6.0   Back to index