jdbc 读取oracle long raw 字段,里面存的是文本
2024-08-31 23:22:52
jdbc 读取oracle long raw 字段,里面存的是文本
参考:
http://singlewolf.iteye.com/blog/278769
http://blog.csdn.net/restraint/article/details/7190265
http://blog.csdn.net/bq1073100909/article/details/49335491
String sql = "select condition from tbl t where t.a = ? and t.b = ?";
PreparedStatement statement = hebSgConn.prepareStatement(sql);
statement.setString(1, "20170305");
statement.setInt(2, 146897);
ResultSet resultSet = statement.executeQuery();
if (resultSet.next()) {
InputStream inputStream = resultSet.getBinaryStream("condition");
ByteArrayOutputStream infoStream = new ByteArrayOutputStream();
int len = 0;
byte[] bytes = new byte[1024];
try {
while ((len = inputStream.read(bytes)) != -1) {
// 将bcache中读取的input数据写入infoStream
infoStream.write(bytes, 0, len);
}
} catch (IOException e1) {
throw new Exception("输入流读取异常");
} finally {
try {
inputStream.close(); // 输入流关闭
} catch (IOException e) {
throw new Exception("输入流关闭异常");
}
}
try {
String result = infoStream.toString(DEFAULT_ENCODING);
System.out.println(result);
} catch (UnsupportedEncodingException e) {
throw new Exception("输出异常");
}
}
基本上是流操作;
最新文章
- redis 中文字符显示
- Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划
- 这一路走来,冷暖自知 (附算法demos)
- JSON.parse()和eval()区别
- [系统开发] Bind DNS 管理系统
- 使用iTextSharp来填充PDF模板文件
- HDU1372:Knight Moves(经典BFS题)
- 关于一点jeesite
- scalajs_初体验
- java 实现的c当中的几道题
- 201421123042 《Java程序设计》第4周学习总结
- cmd 【已解决】windows连接手机,运行adb devices提示“unauthorized”
- JSP页面传值出现中文乱码的问题
- 2017-11-11 Sa Oct How to open a browser in Python
- C#-变量类型(值类型、引用类型)
- 可变码率(英语:Variable bitrate,简称VBR)介绍
- nginx补丁格式说明(CVE-2016-4450为例)
- 【汇编】SI DI 的用法
- 【mybatis】mysql级联更新两个表或多张表的数据
- python学习之路 一 :编程语言介绍