我在将oracle 9i迁移到11g时遇到了以下问题:由DatabaseMetaData检索的存储过程的参数infors与oracle 11g没有错误
这是我的测试
预言
create or replace procedure prodc_test(
-- numeric datatypes --
pparam01 float,
pparam02 number,
--pparam03 binary_float, not available in 9i --
--pparam04 binary_double, not available in 9i --
-- character datatypes --
pparam20 char,
pparam21 in varchar,
pparam22 in out varchar2,
pparam23 out nchar,
pparam24 nvarchar2,
pparam25 long,
-- date datatype --
pparam30 date,
pparam31 timestamp,
pparam32 timestamp with time zone,
pparam34 timestamp with local time zone,
-- lob datatypes --
pparam40 blob,
pparam41 clob,
pparam42 nclob,
pparam43 bfile,
-- raw and long raw datatypes --
pparam50 raw,
pparam51 long raw,
-- rowid and urowid datatypes --
pparam60 rowid,
pparam61 urowid
) as
begin
--null;
pparam22 := 'test22';
pparam23 := 'test23';
end;
/
的java
DatabaseMetaData dbMetaData = dbConn.getMetaData();
LOGGER.debug("DB DriverVersionn ={}", dbMetaData.getDriverVersion());
LOGGER.debug("DB Product Name ={}", dbMetaData.getDatabaseProductName());
LOGGER.debug("DB Product Version={}", dbMetaData.getDatabaseProductVersion());
LOGGER.debug("DB Driver Name ={}", dbMetaData.getDriverName());
LOGGER.debug("DB Driver Version ={}", dbMetaData.getDriverVersion());
LOGGER.debug("DB Username ={}", dbMetaData.getUserName());
LOGGER.debug("DB URL ={}", dbMetaData.getURL());
String procedure = "PRODC_TEST";
ResultSet tSchema = dbMetaData.getProcedureColumns(null, null, procedure, null);
while (tSchema.next()) {
String fieldName = tSchema.getString("COLUMN_NAME").substring(1);
LOGGER.debug("getProcedureParameters({}), COLUMN_NAME:{}, COLUMN_TYPE:{}, DATA_TYPE:{}, TYPE_NAME:{}", procedure, fieldName,
tSchema.getInt("COLUMN_TYPE"), tSchema.getString("DATA_TYPE"), tSchema.getString("TYPE_NAME"));
}
}
tSchema.close();
使用oracle 9i,输出
DB DriverVersionn =11.2.0.3.0
DB Product Name =Oracle
DB Product Version=Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.4.0 - Production
DB Driver Name =Oracle JDBC driver
DB Driver Version =11.2.0.3.0
DB Username =SCHEMA_USER
DB URL =jdbc:oracle:thin:@x.y.z.t:1521:SID
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM01, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:FLOAT
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM02, COLUMN_TYPE:1, DATA_TYPE:3, TYPE_NAME:NUMBER
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM20, COLUMN_TYPE:1, DATA_TYPE:1, TYPE_NAME:CHAR
ggetProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM21, COLUMN_TYPE:1, DATA_TYPE:12, TYPE_NAME:VARCHAR2
ggetProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM22, COLUMN_TYPE:2, DATA_TYPE:12, TYPE_NAME:VARCHAR2
ggetProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM23, COLUMN_TYPE:4, DATA_TYPE:1111, TYPE_NAME:NCHAR
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM24, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:NVARCHAR2
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM25, COLUMN_TYPE:1, DATA_TYPE:-1, TYPE_NAME:LONG
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM30, COLUMN_TYPE:1, DATA_TYPE:93, TYPE_NAME:DATE
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM31, COLUMN_TYPE:1, DATA_TYPE:93, TYPE_NAME:TIMESTAMP
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM32, COLUMN_TYPE:1, DATA_TYPE:-101, TYPE_NAME:TIMESTAMP WITH TIME ZONE
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM34, COLUMN_TYPE:1, DATA_TYPE:-102, TYPE_NAME:TIMESTAMP WITH LOCAL TIME ZONE
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM40, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:BLOB
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM41, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:CLOB
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM42, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:NCLOB
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM43, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:BFILE
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM50, COLUMN_TYPE:1, DATA_TYPE:-3, TYPE_NAME:RAW
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM51, COLUMN_TYPE:1, DATA_TYPE:-4, TYPE_NAME:LONG RAW
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM60, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:ROWID
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM61, COLUMN_TYPE:1, DATA_TYPE:1111, TYPE_NAME:UROWID
使用oracle 11g,输出为
DB DriverVersionn =11.2.0.3.0
DB Product Name =Oracle
DB Product Version=Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
DB Driver Name =Oracle JDBC driver
DB Driver Version =11.2.0.3.0
DB Username =SCHEMA_USER
DB URL =jdbc:oracle:thin:@x.y.z.t2:1521:SID
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM01, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:float
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM02, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:number
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM03, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:binary_float
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM04, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:binary_double
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM20, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:char
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM21, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:varchar2
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM22, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:varchar2
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM23, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:nchar
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM24, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:nvarchar2
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM25, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:long
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM30, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:date
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM31, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:timestamp
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM32, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:timestamp with time zone
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM34, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:timestamp with local time zone
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM40, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:blob
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM41, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:clob
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM42, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:nclob
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM43, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:bfile
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM50, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:raw
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM51, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:long raw
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM60, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:rowid
getProcedureParameters(PRODC_TEST), COLUMN_NAME:PARAM61, COLUMN_TYPE:0, DATA_TYPE:1111, TYPE_NAME:urowid
=>问题:COLUMN_TYPE = 0(java.sql.DatabaseMetaData.procedureColumnUnknown)和DATA_TYPE = 1111(java.sql.Types.OTHER)
为什么呢?这是一个错误吗?解? 非常感谢