我正在尝试从plsq获取文件句柄,我正在尝试查看是否可以测试plsql包 来自Java我有这个代码:
Properties props = Utils.readProps("database.properties");
Connection con = DBManager.getConnection(props.getProperty("url"), props.getProperty("username"), props.getProperty("password"));
Object file_type = new Object[3];
STRUCT oracleRecord;
try {
//StructDescriptor fileType = StructDescriptor.createDescriptor("UTL_FILE.FILE_TYPE",con);
CallableStatement stmt = con.prepareCall("{call simple_test.caller(?,?,?)");
stmt.setObject(1, "/u01/home/oracle/EI/278");
stmt.setObject(2, "ql_item_test.txt");
stmt.registerOutParameter(3, OracleTypes.STRUCT, "UTL_FILE.FILE_TYPE");
stmt.execute();
oracleRecord = ((OracleCallableStatement)stmt).getSTRUCT(3);
file_type = oracleRecord.getAttributes();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
这个plsql代码:
PROCEDURE caller(file_path VARCHAR2,
file_name VARCHAR2,
fp OUT UTL_FILE.file_type) IS
maxLineSize INTEGER;
BEGIN
maxLineSize := 1024;
fp := UTL_FILE.FOPEN(file_path, file_name, 'R', maxLineSize);
END;
但是当我跑它时我想这个错误:
java.sql.SQLException: invalid name pattern: UTL_FILE.FILE_TYPE
我收到此错误是因为我无法传递/检索plsql类型?
答案 0 :(得分:1)
UTL_FILE.FILE_TYPE是PL / SQL"记录"和Oracle JDBC不支持记录。它确实支持对象和对象和基元的某些集合。请参阅http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraoor.htm http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraarr.htm和http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraoot.htm#i1078761
顺便说一下,我无法看到你用Java做什么呢?