I have Oracle procedure named enter that returns RAW type as result.When I want to register out parameter named 'ret' I get this error :
java.sql.SQLException: Parameter Type Conflict: sqlType=-2
This is my java method and import statement:
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;
}
How can I get this output parameter of RAW type in Java? Thanks in advance!
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
You have parameter name, not parameter type.
Try use just:
cstmt.registerOutParameter(2,OracleTypes.RAW)