社区
Java EE
帖子详情
散分200,顺带问个问题。
duye
2006-10-31 09:14:50
主要是散分。
问题为:
j2ee应用中如何读写oracle数据库中的clob或者blob字段,要求是自己写过的例子,网上例子我找过,我们的开发人员都说不成,谢谢。
...全文
946
101
打赏
收藏
散分200,顺带问个问题。
主要是散分。 问题为: j2ee应用中如何读写oracle数据库中的clob或者blob字段,要求是自己写过的例子,网上例子我找过,我们的开发人员都说不成,谢谢。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
101 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
abc1223
2006-11-09
打赏
举报
回复
顶
Rodney815
2006-11-09
打赏
举报
回复
顶!
技术开发到天荒地老
2006-11-09
打赏
举报
回复
主要是散分。
=============================================
何时结贴?
cqm2099
2006-11-08
打赏
举报
回复
up
CpRcF
2006-11-08
打赏
举报
回复
接分。
《深入浅出 hibernate》 这书上有个例子,是关于向oracle中插入blob/clob字段的例子。
allright_flash
2006-11-08
打赏
举报
回复
94
allright_flash
2006-11-08
打赏
举报
回复
⊙⌒⊙
∨
allright_flash
2006-11-08
打赏
举报
回复
┌──┐
│好贴│ ╭───────╮
└──┘ ┏━━━━━━━┓ │ 既然有分, │
┏┓ ┏┫ |||┣┓∠ 这贴就顶了 │
┣┫ ┗┫━━ ┃ ━━┣┛ ╰───────╯
┏┳┫┣┳┓ ┃ ━━━━━ ┃
┃ ┃ ┗━━━┳━━━┛
┗━━━━┻━━━━▇▇▇┛ ()000o
┃ ┃ (````)
┃ ┃ )``/
┛ ┗━━(__/
andy_linky
2006-11-08
打赏
举报
回复
接分,随便学习……
water_carrier
2006-11-08
打赏
举报
回复
mark
xfzhangbin
2006-11-08
打赏
举报
回复
接分咯
zlinerxz
2006-11-08
打赏
举报
回复
public boolean setClob(String ID, String SQL, String content)
{
boolean flag = false;
//com.bill.base.Lj.debug("content"+content);
LogManager loger = new LogManager();
Connection conn = null;
ResultSet rs=null;
oracle.sql.CLOB clob=null;
java.sql.PreparedStatement pstmt=null;
try
{
connectDatabase();
conn = getConnection();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(SQL);
pstmt.executeUpdate();
pstmt.close();
pstmt = conn.prepareStatement("select content from TBDEMAILWaiting where ID=? for update");
pstmt.setString(1,ID);
rs = pstmt.executeQuery();
if (rs.next())
{
clob = (oracle.sql.CLOB)((oracle.jdbc.OracleResultSet) rs).getClob(1);
//writer = ((CLOB)my_clob).setCharacterStream();
// 获得游标 // 使用输入流的形式来,把字符串输入到这个特有的数据库字段中去
BufferedWriter out = new BufferedWriter(clob.getCharacterOutputStream());
//Writer wr = clob.setCharacterStream();
out.write(content);
//out.flush();
out.close();
rs.close();
conn.commit();
pstmt.close();
conn.close();
flag = true;
}
}
catch (SQLException ex1)
{
try
{
conn.rollback();
}
catch (Exception ex)
{
loger.writeLog("SQL rollback ERROR IS" + ex.toString());
}
loger.writeLog("SQL ERROR IS" + SQL);
loger.writeLog("dbm.connect error is: " + ex1.toString());
}
catch (Exception ex)
{
try
{
conn.rollback();
}
catch (Exception e)
{
loger.writeLog("SQL rollback ERROR IS" + e.toString());
}
loger.writeLog("setClob error is " + ex.toString());
}
finally
{
try
{
if (rs != null)
{
rs.close();
}
if (pstmt!=null)
{
pstmt.close();
}
if (conn != null)
{
conn.close();
}
}
catch (SQLException ex)
{
Loger.writeLog("dbman err is= " + ex.toString());
}
}
return flag;
}
public boolean setClob(String tabName ,String fieldName,String iDvalue,String contentVal,String SQL)
{
boolean flag = false;
LogManager loger = new LogManager();
Connection conn = null;
try
{
connectDatabase();
conn = getConnection();
conn.setAutoCommit(false);
executeUpdate(SQL);
Statement st = this.getStatement();
ResultSet rs = st.executeQuery(
"select content from "+tabName+" where "+fieldName+"='" +
iDvalue + "' for update");
if (rs.next())
{
oracle.sql.CLOB clob = ( (oracle.jdbc.driver.OracleResultSet) rs).
getCLOB(1);
clob.putString(1, contentVal);
SQL = "update "+tabName+" set content=? where "+fieldName+"='" + iDvalue + "'";
PreparedStatement pstmt = conn.prepareStatement(SQL);
pstmt.setClob(1, clob);
pstmt.executeUpdate();
pstmt.close();
}
rs.close();
st.close();
conn.commit();
flag = true;
}
catch (SQLException ex1)
{
try
{
conn.rollback();
}
catch (Exception ex)
{
loger.writeLog("SQL rollback ERROR IS" + ex.toString());
}
loger.writeLog("SQL ERROR IS" + SQL);
loger.writeLog("dbm.connect error is: " + ex1.toString());
}
catch (Exception ex)
{
try
{
conn.rollback();
}
catch (Exception e)
{
loger.writeLog("SQL rollback ERROR IS" + e.toString());
}
loger.writeLog("setClob error is " + ex.toString());
}
finally
{
try
{
if (conn != null)
{
conn.close();
}
}
catch (SQLException ex)
{
Loger.writeLog("dbman err is= " + ex.toString());
}
}
return flag;
}
/**
*
* @param ID String
* @return String
*/
public String getClob(String ID)
{
LogManager loger = new LogManager();
Connection conn = null;
try
{
connectDatabase();
conn = getConnection();
Statement st = this.getStatement();
ResultSet rs = st.executeQuery(
"select content from TBDEMAILWaiting where ID='" +
ID + "' ");
oracle.sql.BLOB blob = null;
String content = "";
if (rs.next())
{
oracle.sql.CLOB clob = ( (oracle.jdbc.driver.OracleResultSet) rs).
getCLOB(1);
if (clob != null)
{
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
while (s != null)
{
content += s + "\r\n";
s = br.readLine();
}
}
}
rs.close();
st.close();
conn.close();
return content;
}
catch (SQLException ex1)
{
loger.writeLog("dbm.connect error is: " + ex1.toString());
}
catch (Exception ex)
{
loger.writeLog("setClob error is " + ex.toString());
}
finally
{
try
{
if (conn != null)
{
conn.close();
}
}
catch (SQLException ex)
{
Loger.writeLog("dbman err is= " + ex.toString());
}
}
return "F";
}
public String getClob(String tabName,String fieldName,String contentID)
{
LogManager loger = new LogManager();
Connection conn = null;
try
{
connectDatabase();
conn = getConnection();
Statement st = this.getStatement();
ResultSet rs = st.executeQuery(
"select content from "+tabName+" where "+fieldName+"='" +
contentID + "' ");
oracle.sql.BLOB blob = null;
String content = "";
if (rs.next())
{
oracle.sql.CLOB clob = ( (oracle.jdbc.driver.OracleResultSet) rs).
getCLOB(1);
if (clob != null)
{
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
while (s != null)
{
content += s + "\r\n";
s = br.readLine();
}
}
}
rs.close();
st.close();
conn.close();
return content;
}
catch (SQLException ex1)
{
loger.writeLog("dbm.connect error is: " + ex1.toString());
}
catch (Exception ex)
{
loger.writeLog("setClob error is " + ex.toString());
}
finally
{
try
{
if (conn != null)
{
conn.close();
}
}
catch (SQLException ex)
{
Loger.writeLog("dbman err is= " + ex.toString());
}
}
return "F";
}
sun113
2006-11-08
打赏
举报
回复
zzd8310(经常被模仿,从未被超越!||我之所以把昵称写这么长。就是想看看昵称到底能写多长,真是长啊!!!!!!) ( ) 信誉:100 Blog 2006-11-1 8:14:52 得分: 0 jiu
mywanpi
2006-11-07
打赏
举报
回复
down
这是个假程序员
2006-11-07
打赏
举报
回复
接粉
大选
2006-11-07
打赏
举报
回复
如果有人打著散分的幌子,來問問題,我就只能鄙視你了.
allright_flash
2006-11-07
打赏
举报
回复
祝福lz早点解决问题!
allright_flash
2006-11-07
打赏
举报
回复
接分,随便学习……
allright_flash
2006-11-07
打赏
举报
回复
没用过blob字段,帮顶
BabyWhite
2006-11-07
打赏
举报
回复
接分,随便学习……
加载更多回复(81)
HCIA Security案例实验
3、具有数通基础,想学习安全方向的技术人员、工程师、高校学生等 你将会学到: HCIA Security实验讲解 课程简介: 注意:本课程以实操配置为主,理论学习在该部分是
顺带
而过,本课程目标是提高大家实操动手能力。...
经典的机器学习
200
道面试题及答案
当训练数据线性可分时,通过硬间隔最大化,学习一个线性的分类器,即线性可分支持向量机,又称为硬间隔支持向量机;当训练数据近似线性可分时,通过软间隔最大化,也学习一个线性的分类器,即线性支持向量机,又称为...
世界500强公司面试题(很多)
世界500强公司面试题(很多) 快到春节了,很多朋友又在酝酿跳槽的事,找了许多经典的面试题目,估计这些题目全部研究过了,针对非技术的面试应该足够了:)第一章 微软面试题 面试官:现在我们要问一个问题,看看...
我在CSDN参与的3000个帖子
2:100分急求,随机输出十个小写字母,但是,要求这十个字母不相同 3:求Sn=a+aa+aaa+…+aaa…a(n个a)之值 4:数组题 望高手帮忙! 5:呵呵,来推荐一下我的网站,本站提供大量当今流行的免费的音乐和免费电影,...
《#华为云#听从你心,无问西东》及网友跟帖
《#华为云#听从你心,无问西东》及网友跟帖 HUAWEI管理真经2019-01-28 https://mp.weixin.qq.com/s/Fo2iZydELTgVojpCxSBGJA 总 裁 办 电 子 邮 件 电邮其他【2019】005号 签发人:任正非 转发《#华为云#...
Java EE
67,513
社区成员
225,880
社区内容
发帖
与我相关
我的任务
Java EE
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
复制链接
扫一扫
分享
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章