Retrieves a description of the stored procedure parameters and result columns.
public java.sql.ResultSet getProcedureColumns(java.lang.String sCatalog, java.lang.String sSchema, java.lang.String proc, java.lang.String col)
Parameters
sCatalog
A string that contains the catalog name. Providing a null to this parameter indicates that the catalog name does not need to be used.
sSchema
A string that contains the schema name pattern. Providing a null to this parameter indicates that the schema name does not need to be used.
proc
A string that contains the procedure name pattern.
col
A string that contains the column name pattern. Providing a null to this parameter returns a row for each column.
Return Value
A SQLServerResultSet object.
Exceptions
Remarks
This getProcedureColumns method is specified by the getProcedureColumns method in the java.sql.DatabaseMetaData interface.
The result set returned by the getProcedureColumns method will contain the following information:
Name | Type | Description |
---|---|---|
PROCEDURE_CAT |
string |
The name of the database in which the specified stored procedure resides. |
PROCEDURE_SCHEM |
string |
The schema for the stored procedure. |
PROCEDURE_NAME |
string |
The name of the stored procedure. |
COLUMN_NAME |
string |
The name of the column. |
COLUMN_TYPE |
short |
The type of the column. It can be one of the following values: procedureColumnUnknown (0) procedureColumnIn (1) procedureColumnInOut (2) procedureColumnOut (4) procedureColumnReturn (5) procedureColumnResult (3) |
DATA_TYPE |
short |
The SQL data type from java.sql.Types. |
TYPE_NAME |
string |
The name of the data type. |
PRECISION |
integer |
The total number of significant digits. |
LENGTH |
integer |
The length of the data in bytes. |
SCALE |
short |
The number of digits to the right of the decimal point. |
RADIX |
short |
The base for numeric types. |
NULLABLE |
short |
Indicates if the column can contain a null value. It can be one of the following values: procedureNoNulls (0) procedureNullable (1) procedureNullableUnknown (2) |
REMARKS |
string |
The description of the procedure column. Note:
SQL Server does not return a value for this column.
|
COLUMN_DEF |
string |
The default value of the column. |
SQL_DATA_TYPE |
short |
Not supported by the JDBC driver. |
SQL_DATETIME_SUB |
short |
Not supported by the JDBC driver. |
CHAR_OCTET_LENGTH |
integer |
The maximum number of bytes in the column. |
ORDINAL_POSITION |
integer |
The index of the column within the table. |
IS_NULLABLE |
string |
Indicates if the column allows null values. |
SS_DATA_TYPE |
short |
The SQL Server data type that is used by extended stored procedures. Note:
For more information about the data types returned by SQL Server, see "Data Types (Transact-SQL)" in SQL Server Books Online.
|
Example
The following example demonstrates how to use the getProcedureColumns method to return information about the uspGetBillOfMaterials stored procedure in the SQL Server 2005 AdventureWorks sample database.
public static void executeGetProcedureColumns(Connection con) { try { DatabaseMetaData dbmd = con.getMetaData(); ResultSet rs = dbmd.getProcedureColumns(null, null, "uspGetBillOfMaterials", null); ResultSetMetaData rsmd = rs.getMetaData(); // Display the result set data. int cols = rsmd.getColumnCount(); while(rs.next()) { for (int i = 1; i <= cols; i++) { System.out.println(rs.getString(i)); } } rs.close(); } catch (Exception e) { e.printStackTrace(); } }