达梦(DM)数据库JDBC Stream 采用 getBinaryStream 获取流

MoMo 2021年6月14日21:03:06
评论
204
//  查询语句

String sql = "SELECT description FROM production.product WHERE productid=1";

//  创建语句对象

Statement stmt = conn.createStatement();

//  执行查询

ResultSet rs = stmt.executeQuery(sql);

//  显示结果集

while (rs.next()) {

try {

InputStream stream = rs.getBinaryStream("description");

ByteArrayOutputStream baos = new ByteArrayOutputStream();

int num = -1;

while ((num = stream.read()) != -1) {

baos.write(num);

}

System.out.println(baos.toString());

} catch (IOException e) {

e.printStackTrace();

}

}

//  关闭结果集

rs.close();

//  关闭语句

stmt.close();
https://xpanx.com/
MoMo
  • 本文由 发表于 2021年6月14日21:03:06
  • 转载请务必保留本文链接:https://xpanx.com/2962.html
书海的搬用工(记住它并且理解它) 读书

书海的搬用工(记住它并且理解它)

每日一书# #六一大人今天的读书笔记# 读完,兴奋10秒,,好,收!我知道好的东西不是读了就可以理解它,也不是读完就可以拥有它,更不是兴奋了就可以“为所欲为”,希望像先贤一样,笃慎自守。运用...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: