データベースに圧縮ファイルを保存するために休止状態を使用しています。Blobファイルを作成しましたHibernate.createBlob(input stream)
今、私はプロセスを逆にしてBlobをファイルに変換したいので、Zip4jで開くことができます。私はこれをやろうとしましたが、常に例外が発生します
File file = new File("origfile.zip"); try { InputStream is = blob.getBinaryStream(); <- exception FileOutputStream opt = new FileOutputStream(file); int read = 0; byte[] bytes = new byte[1024]; while ((read = is.read(bytes)) != -1) { opt.write(bytes, 0, read); }
例外は次のとおりです。
2013-07-03 18:38:35,482 [DEBUG] [HibernateTransactionManager,doBegin(),569] - Exposing Hibernate transaction as JDBC transaction [com.mchange.v2.c3p0.impl.NewProxyConnection@69875a82] java.sql.SQLException: could not reset reader at org.hibernate.lob.BlobImpl.getBinaryStream(BlobImpl.java:106) at org.hibernate.lob.SerializableBlob.getBinaryStream(SerializableBlob.java:62) at com.gleeb.backbonetemplates.services.LivePreviewService.prepareDesignForLivePreview(LivePreviewService.java:35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
ありがとう。