| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 844 人关注过本帖
标题:[求助]Orcale BLOB 乱码问题
只看楼主 加入收藏
huangnetian
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2005-9-24
收藏
 问题点数:0 回复次数:0 
[求助]Orcale BLOB 乱码问题
我往orcale数据里存了一个"hhfs",从文件里读出来的,但是取出来后却是乱码:
这个是存入的方法
private void insertBlob(Connection conn){
try{


conn.setAutoCommit(false);

Statement st = conn.createStatement();


st.executeUpdate("insert into test1 values('hxc',empty_blob())");



ResultSet rs = st.executeQuery(

"select * from test1 where name='hxc' for update");

if (rs.next()) {




oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob("xml");



OutputStream outStream = blob.getBinaryOutputStream();



File file = new File("c:\\ttt.txt");

InputStream fin = new FileInputStream(file);


byte[] b = new byte[blob.getBufferSize()];

int len = 0;

while ( (len = fin.read(b)) != -1) {

outStream.write(b, 0, len);

//blob.putBytes(1,b);

}
fin.close();
outStream.flush();
outStream.close();
conn.commit();
}}catch(Exception e){
e.printStackTrace();
}
}
取出方法:
while(rs.next()){
BLOB blob = (BLOB)rs.getBlob("xml");
byte[] bb = blob.getBytes();

FileOutputStream out = new FileOutputStream("c:\\t1.txt");
out.write(bb);
out.flush();
请大看帮我想想办法,求求,
搜索更多相关主题的帖子: BLOB Orcale 乱码 
2007-06-14 13:59
快速回复:[求助]Orcale BLOB 乱码问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017918 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved