最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
clob字段的处理(oracle)
时间:2022-07-02 18:16:30 编辑:袖梨 来源:一聚教程网
先用PrepareStatement 对象插入(
这时一定要设定Connection对象的AutoCommit为false,即
conn.setAutoCommit(false);
),语句这样写:
String sql = "INSERT INTO flower_news (flower_news_id,news_content,news_author) VALUES (flower_news_id_s.nextval,empty_clob(),?)";
这里news_content字段为clob值。
然后再用select news_content from folwer_news where ....取出刚才插入的那条记录。
再看下面的代码:
rs = st.executeQuery(sql);
java.sql.Clob clob ;
if (rs.next()) {
clob = ((OracleResultSet)rs).getClob(1);
oracle.sql.CLOB my_clob = (oracle.sql.CLOB)clob;
OutputStream writer = my_clob.getAsciiOutputStream();
byte[] contentStr = this.getContent().getBytes();
writer.write(contentStr);
writer.flush();
writer.close();
}
conn.commit();//到最后才提交
其中这个方法我是取到要插入的字符串
你看看吧,照这样做是没有问题的
在整个过程中你都不能提交,否则是不会成功的
这时一定要设定Connection对象的AutoCommit为false,即
conn.setAutoCommit(false);
),语句这样写:
String sql = "INSERT INTO flower_news (flower_news_id,news_content,news_author) VALUES (flower_news_id_s.nextval,empty_clob(),?)";
这里news_content字段为clob值。
然后再用select news_content from folwer_news where ....取出刚才插入的那条记录。
再看下面的代码:
rs = st.executeQuery(sql);
java.sql.Clob clob ;
if (rs.next()) {
clob = ((OracleResultSet)rs).getClob(1);
oracle.sql.CLOB my_clob = (oracle.sql.CLOB)clob;
OutputStream writer = my_clob.getAsciiOutputStream();
byte[] contentStr = this.getContent().getBytes();
writer.write(contentStr);
writer.flush();
writer.close();
}
conn.commit();//到最后才提交
其中这个方法我是取到要插入的字符串
你看看吧,照这样做是没有问题的
在整个过程中你都不能提交,否则是不会成功的
相关文章
- 抖音官方充值入口-抖音充值活动任务奖励领取入口 12-18
- 哔哩哔哩在线免费畅看-2025哔哩哔哩b站网页版最新入口速览 12-18
- 一人之下漫画免费在线观看入口 | 实时缓存无延迟,网页直读免下载 12-18
- 免费PPT成品网站直播推荐-超全免费PPT模板网站盘点 12-18
- 学信网查学历-官方学历查询入口(一键验证学历信息) 12-18
- 虫虫漫画-免费漫画观看入口_海量正版漫画在线畅读平台 12-18