我正在使用一个实用程序,您可以压缩多个MS Office文件,然后将其上传到Db。
问题是当我上传zip时,1个条目可以正常工作,当有2个或更多条目我得到异常时(这里有一些编码问题)。
java.sql.SQLException: Ïðåâûøåí ðàçìåð äàííûõ, ðàçðåøåííûé äëÿ ýòîãî òèïà: 45804
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:99)
at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:1771)
at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:986)
at oracle.jdbc.driver.OraclePreparedStatement.setBinaryStream(OraclePreparedStatement.java:2299)
at fr.CDb.addArchFile(CDb.java:254)
at fr.CFr.addZipArch(CFr.java:41)
at fr.CMain.main(CMain.java:13)
我的上传代码(cs.setBinaryStream()上的EXCEPTION TRIGGERS):
public void addArchFile() {
CDb cb = new CDb();
OracleConnection conn = cb.getConn();
OracleCallableStatement cs = null;
String fileDir = CFr.getFileDir();
String fileName = CFr.getFileName();
try {
//
File f = new File(fileDir + fileName);
FileInputStream in = new FileInputStream(f);
FileNameMap fileNameMap = URLConnection.getFileNameMap();
//
cs = (OracleCallableStatement)conn.prepareCall("Begin Va_File.Add_File(?, ?, ?, ?, ?); End;");
cs.setString(1, (String)FilenameUtils.getExtension(fileName));
cs.setString(2, (String)fileNameMap.getContentTypeFor(fileDir + fileName));
cs.setString(3, fileName);
cs.setBinaryStream(4, in, (int)f.length());
cs.setInt(5, (int)f.length());
cs.execute();
in.close();
//
System.out.println(Arrays.toString(Thread.currentThread().getStackTrace()));
} catch(Exception e) {
e.printStackTrace();
e.getMessage();
} finally {
done(cs);
done(conn);
}
}
我的包中的Add_File proc:
Procedure Add_File(
i_Mime_Type Varchar2,
i_Ext Varchar2,
i_Name Varchar2,
i_Cont Blob,
i_Cont_Size Number
)
Is
v_Id Integer;
r_File Va_Arch_Files%Rowtype;
Begin
Select Nvl(Max(t.Arch_Id), 0) + 1 Into v_Id From Va_Arch_Files t;
--
r_File.Arch_Id := v_Id;
r_File.Mime_Type := i_Mime_Type;
r_File.Ext := i_Ext;
r_File.Name := i_Name;
r_File.Cont := i_Cont;
r_File.Cont_Size := i_Cont_Size;
r_File.Created_By := 1;
r_File.Creation_Date := Sysdate;
r_File.Update_By := r_File.Created_By;
r_File.Update_Date := r_File.Creation_Date;
--
Insert Into Va_Arch_Files Values r_File;
--
Commit;
Exception When Others Then
Rollback;
Raise_Application_Error(-20000, Sqlerrm);
End;
我尝试了ZipOutputStream
(Java)和ZipArchiveOutputStream
(Apache Commons Compress)。我怀疑zip条目应该以某种方式解析并转换为byte []然后转换为Blob,但我无法在网上找到任何值得的东西。
答案 0 :(得分:0)
解决方案:
调整新ojdbc6.jar
驱动程序的所有连接类。
删除有关旧版和旧版的所有内容已停止classes12.jar
。