博客
关于我
Hibernate操作Blob,将Blob转换为String
阅读量:374 次
发布时间:2019-03-05

本文共 764 字,大约阅读时间需要 2 分钟。

public String getScenicCoord(String pk) {
log.debug("根据景区唯一标示获取景区坐标!");
String sql = "select wkt from JQGEO where id = '" + pk + "'";
String result = "";
try {
Connection conn = getSession().connection();
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet set = ps.executeQuery();
if (set.next()) {
Blob blob = set.getBlob(1);
InputStream in = blob.getBinaryStream();
int size = in.available();
byte[] by = new byte[size];
in.read(by);
result = new String(by);
} catch (Exception e) {
log.error("根据景区唯一标示获取景区坐标失败!");
result = null;
try {
throw e;
} catch (Exception e1) {
e1.printStackTrace();
result = null;
}
return result;

转载地址:http://rmiwz.baihongyu.com/

你可能感兴趣的文章
(SDUT 2159)山东省第一届ACM省赛 Ivan comes again! (set集合综合运用)
查看>>
微信js-sdk使用简述(分享,扫码功能等)
查看>>
selenium 的介绍和爬取 jd数据
查看>>
【分享-一键在线抠图】在线免费去除图片背景
查看>>
layui表格checkbox选择全选样式及功能
查看>>
mxsrvs支持thinkphp3.2伪静态
查看>>
mui HTML5 plus 下载文件
查看>>
环信SDK 踩坑记webIM篇(一)
查看>>
通信基础知识
查看>>
DSP开发板准备
查看>>
测试基本
查看>>
c++中istringstream及ostringstream超详细说明
查看>>
c++中ifstream及ofstream超详细说明
查看>>
c++中explicit和mutable关键字探究
查看>>
c语言结构体字节对齐详解
查看>>
linux c/c++面试知识点整理(八)
查看>>
linux网络编程系列(十二)--滑动窗口、拥塞控制、断线重连机制
查看>>
Deep residual learning for image recognition
查看>>
IO控制方式
查看>>
IO控制器
查看>>