kettle从oracle取出blob中文乱码

需要做一个任务,将某些的服务xml取出来重新调用,xml存在oracle中是blob类型的,sql取出来中文乱码。

查了网上的很多方法,改了配置文件的编码,改了数据库编码都不行。

1。 然后正好那段xml不大,投机了一把

写查询语句的时候直接使用了utl_raw.cast_to_varchar2函数,然后把这个作为入参去调用服务。

2.  针对其他入参较大的就不行了。

 增加了一个字段选择,将blob字段类型选择为String,Encoding选为GBK即可。

 下面是查询过程中花了48积分下载的,不知道对你们有没有用:

1.插入 (用PrepareStatement,用?占位)
File file=new File();
InputStream in=new BufferedInputStream(new FileInputStream(file));
ps.setBinaryStream(1,in,(int)file.length());
2.读取
Blob blob=rs.getBlob(字段);
//IuputStream in=blob.getBinaryStream(字段); //两种方式
IuputStream in=rs.getBinaryStream(字段);
File file=new File(文件位置等);
OutputStream out=new BufferedOutputStream(new FileOutputStream(file));
byte [] bt=new byte[1024];
for(int=0;i=in.read(bt)>0;){
out.write(bt,0,i);
}
out.close();
in.close();

越努力越幸运~ 加油ヾ(◍°∇°◍)ノ゙
原文地址:https://www.cnblogs.com/utomboy/p/14355884.html