物件序列化後,寫入Oracle Blob欄位:“無法從套接字讀取更多的資料”

mellon發表於2003-09-15
..............
StringBuffer sb=new StringBuffer("insert into LF_CTRL_PLAN(plan_no,fcno,itemid,netid,fore_category,plan_name,creator,plan_ser,createdate,fctype,foreType,recommendation) values(?,?,?,?,?,?,?,?,?,?,?,?)");
PreparedStatement preStat=conn.prepareStatement(sb.toString());
//物件序列化後,存入資料庫
ByteArrayOutputStream byteOut=new ByteArrayOutputStream();
ObjectOutputStream outObj=new ObjectOutputStream(byteOut);
outObj.writeObject(this) ;
final byte[] objbytes=byteOut.toByteArray();
InputStream in=new InputStream(){
int objbytesIndex=0;
public int read(){
while(objbytesIndex<objbytes.length){
return objbytes[objbytesIndex++];
}
return -1;
}
};
preStat.setBinaryStream(8,in,objbytes.length);
...........
preStat.executeUpdate() ;
return plan_no;
}

相關文章