我有一个 java 存储过程,我试图将一个 byte[] 数组插入到表中的 oracle blob 字段中。
我按如下方式创建了一个准备好的语句,但是当我执行准备好的语句时它会随机失败。我已经缩小了问题来自 pstmt.setBytes(4,content) 的范围。我得到的错误是:
ORA-01460: 请求的转换未实现或不合理。
private static void insertFile(Connection connOracle, int zipFileId, byte[] data, String filepath, String filename ) throws SQLException {
try {
String QUERY = "INSERT INTO files(file_id, zip_file_id, filename, file_path, content) VALUES(SEQ_FILE_ID.nextval,?,?,?,?)";
PreparedStatement pstmt = connOracle.prepareStatement(QUERY);
pstmt.setInt(1,zipFileId);
pstmt.setString(2, filename);
pstmt.setString(3, filepath);
pstmt.setBytes(4, data);
System.out.println("INSERTING file_id " + filepath + ", " + filename + " INTO DATABASE");
pstmt.execute();
pstmt.close();
}
catch (SQLException e) {
throw new SQLException(e.getMessage());
}