java读写数据库中CLOB类型代码

来源:www.heci.net 时间:2006/4/11 17:01:44 作者:heci
java读写数据库中CLOB类型代码

//向数据库中添加CLOB类型代码
ds = DBConn.getDataSource("dsn");
connection = ds.getConnection();
connection.setAutoCommit(false);
StringReader buf = new StringReader("strClob");
sqlQuery="insert into table (clob) values(?)";
preparedstatement = connection.prepareStatement(sqlQuery);
preparedstatement.setCharacterStream(4,buf,regionIntro.getBytes().length);
preparedstatement.executeUpdate();
connection.commit();
connection.setAutoCommit(true);

//读
Clob content=rs.getClob("ClobFiledName");
if(content!=null)//得到校区简介的内容
contentStr = content.getSubString(1,(int)content.length());内容来源:[ http://www.heci.net 贺词收藏网 ]!