星期日, 十一月 26, 2006

java如何获得存储过程的参数(例子)

Connection conn = JDBCUtils.getConnection();
DatabaseMetaData dbmd = conn.getMetaData();

ResultSet rs = dbmd.getProcedureColumns(null, "DATAPUMP", "GET_INCOME_STATEMENT", "%");
while (rs.next()) {
String dbColumnName = rs.getString("COLUMN_NAME");
short dbColumnReturn = rs.getShort("COLUMN_TYPE");
switch (dbColumnReturn) {
case DatabaseMetaData.procedureColumnReturn:
System.out.println(dbColumnName+ " return");
break;
case DatabaseMetaData.procedureColumnIn:
System.out.println(dbColumnName+ " in");
break;
case DatabaseMetaData.procedureColumnOut:
System.out.println(dbColumnName+ " out");
break;
case DatabaseMetaData.procedureColumnInOut:
System.out.println(dbColumnName+ " inout");
break;
}

}

----------------------------------------------------------------------------------------------------------------------------

其中

Parameters to getProcedureColumns

The JDBC API defines the following parameters for this method call:

  • catalog

    总是null

  • schemaPattern

    用户名

  • procedureNamePattern

    存储过程名字匹配

  • column-Name-Pattern

    column名字匹配

没有评论: