0

我有一个名为 enter 的 Oracle 过程,它返回 RAW 类型作为结果。当我想注册名为“ret”的参数时,我收到此错误:

 java.sql.SQLException: Parameter Type Conflict: sqlType=-2

这是我的 java 方法和 import 语句:

import org.apache.openjpa.jdbc.sql.Raw;

public Raw enter(int pid) {
    Connection connection;
    CallableStatement cstmt;
    try {
        connection = cscadaDataSource.getConnection();
        connection.setAutoCommit(false);
        cstmt = connection.prepareCall("{ CALL process_logging.PROCESSMONITOR_ENTER(?,?) }");
        cstmt.setInt(1, pid);
        cstmt.registerOutParameter(2,OracleTypes.RAW , "ret");
        cstmt.execute();

        Raw result = (Raw) cstmt.getObject(2);

        connection.commit();
        return result;
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}

如何在 Java 中获取这个 RAW 类型的输出参数?提前致谢!

4

1 回答 1

1

void registerOutParameter(int parameterIndex, int sqlType, String typeName) 抛出 SQLException

参数:
parameterIndex - 第一个参数是 1,第二个参数是 2,...
sqlType - 来自 Types 的值
typeName - SQL 结构化类型的完全限定名称

您有参数名称,而不是参数类型。

尝试使用:

cstmt.registerOutParameter(2,OracleTypes.RAW)

于 2014-05-21T10:40:46.040 回答