gpt4 book ai didi

java - 如何在Java中注册Raw类型的OutParameter

转载 作者:行者123 更新时间:2023-12-01 12:57:12 25 4
gpt4 key购买 nike

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

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

这是我的java方法和导入语句:

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类型的输出参数?预先感谢!

最佳答案

void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException :

Parameters:
parameterIndex - the first parameter is 1, the second is 2,...
sqlType - a value from Types
typeName - the fully-qualified name of an SQL structured type

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

尝试仅使用:

cstmt.registerOutParameter(2,OracleTypes.RAW)

关于java - 如何在Java中注册Raw类型的OutParameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23777891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com