--读取
select da.ContentLength,da.DocContent from DOC_ATTACHMENT da where DocNo='';
ASResultSet rs = Sqlca.getASResultSet(sSql);
byte[] bArray = null;
String sDocContent = "";
if(rs.next()) {
int iContentLength = rs.getInt("ContentLength");
if(iContentLength >0) {
bArray = new byte[iContentLength];
java.io.InputStream inStream = null;
inStream = rs.getBinaryStream("DocContent");
int iByte = 0;
while(true) {
iByte = inStream.read(bArray);
if(iByte<=0) break;
sDocContent += newString(bArray,"GBK");
}
}
}
rs.getStatement().close();
System.out.println(sDocContent);
--存储
sSql = "update DOC_ATTACHMENT set DocContent=? where DocNo=";
PreparedStatement ps = Sqlca.conn.PreparedStatement(sSql);
pa.clearParameters();
bArray = sDocContent.getBytes("GBK");
ps.setBinaryStream(1,new ByteArrayInputStream(bArray,0,bArray.length),bArray.length);
ps.executeUpdate();
ps.close();