java.lang.IllegalStateException: Blobs may not be accessed after serialization 我使用的是oracle9,数据类型为Blob,从客户端把数据传到服务器后,对数据进行处理时,报错,信息如下:java.lang.IllegalStateException: Blobs may not be accessed after serialization不知道是什么原因,请高手指点,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看看源码,blob为空就会产生这个异常.1 //$Id: SerializableBlob.java,v 1.1 2005/03/02 11:43:35 oneovthafew Exp $2 package org.hibernate.lob;3 4 import java.io.InputStream;5 import java.io.OutputStream;6 import java.io.Serializable;7 import java.sql.Blob;8 import java.sql.SQLException;9 10 /**11 * @author Gavin King12 */13 public class SerializableBlob implements Serializable, Blob {14 15 private transient final Blob blob;16 17 public SerializableBlob(Blob blob) {18 this.blob = blob;19 }20 21 public Blob getWrappedBlob() {22 if ( blob==null ) {23 throw new IllegalStateException("Blobs may not be accessed after serialization");24 }25 else {26 return blob;27 }28 }29 30 public long length() throws SQLException {31 return getWrappedBlob().length();32 }33 34 public byte[] getBytes(long pos, int length) throws SQLException {35 return getWrappedBlob().getBytes(pos, length);36 }37 38 public InputStream getBinaryStream() throws SQLException {39 return getWrappedBlob().getBinaryStream();40 }41 42 public long position(byte[] pattern, long start) throws SQLException {43 return getWrappedBlob().position(pattern, start);44 }45 46 public long position(Blob pattern, long start) throws SQLException {47 return getWrappedBlob().position(pattern, start);48 }49 50 public int setBytes(long pos, byte[] bytes) throws SQLException {51 return getWrappedBlob().setBytes(pos, bytes);52 }53 54 public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {55 return getWrappedBlob().setBytes(pos, bytes, offset, len);56 }57 58 public OutputStream setBinaryStream(long pos) throws SQLException {59 return getWrappedBlob().setBinaryStream(pos);60 }61 62 public void truncate(long len) throws SQLException {63 getWrappedBlob().truncate(len);64 }65 66 } pl/Sql小编程 关于oracle中的sequence的问题 oracle的SQL PLUS新建管理表空间出错 sybase中语句转换成oracle 请教一个Oracle8i在Celeron4处理器机器上安装的问题!急..... 请问SQLServer 中 求日期的函数Datepart在Oracle中用什么代替??? 每次使用数据库时都要关闭再打开?如何解决呢? 安装过sharepoint的朋友进来救命啊!!!!!! 关于日期方面的 关于两个表之间数据的导入问题! 请贵人,帮晚辈写一些简单的存储过程. 高手帮忙 万分谢谢!
1 //$Id: SerializableBlob.java,v 1.1 2005/03/02 11:43:35 oneovthafew Exp $
2 package org.hibernate.lob;
3
4 import java.io.InputStream;
5 import java.io.OutputStream;
6 import java.io.Serializable;
7 import java.sql.Blob;
8 import java.sql.SQLException;
9
10 /**
11 * @author Gavin King
12 */
13 public class SerializableBlob implements Serializable, Blob {
14
15 private transient final Blob blob;
16
17 public SerializableBlob(Blob blob) {
18 this.blob = blob;
19 }
20
21 public Blob getWrappedBlob() {
22 if ( blob==null ) {
23 throw new IllegalStateException("Blobs may not be accessed after serialization");
24 }
25 else {
26 return blob;
27 }
28 }
29
30 public long length() throws SQLException {
31 return getWrappedBlob().length();
32 }
33
34 public byte[] getBytes(long pos, int length) throws SQLException {
35 return getWrappedBlob().getBytes(pos, length);
36 }
37
38 public InputStream getBinaryStream() throws SQLException {
39 return getWrappedBlob().getBinaryStream();
40 }
41
42 public long position(byte[] pattern, long start) throws SQLException {
43 return getWrappedBlob().position(pattern, start);
44 }
45
46 public long position(Blob pattern, long start) throws SQLException {
47 return getWrappedBlob().position(pattern, start);
48 }
49
50 public int setBytes(long pos, byte[] bytes) throws SQLException {
51 return getWrappedBlob().setBytes(pos, bytes);
52 }
53
54 public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
55 return getWrappedBlob().setBytes(pos, bytes, offset, len);
56 }
57
58 public OutputStream setBinaryStream(long pos) throws SQLException {
59 return getWrappedBlob().setBinaryStream(pos);
60 }
61
62 public void truncate(long len) throws SQLException {
63 getWrappedBlob().truncate(len);
64 }
65
66 }