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

MoMo 2021年6月14日21:04:43
评论
227
//  查询语句

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.getAsciiStream("description");

StringBuffer desc = new StringBuffer();

byte[] b = new byte[1024];

for (int n; (n = stream.read(b)) != -1;) {

desc.append(new String(b, 0, n));

}

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

} catch (IOException e) {

e.printStackTrace();

}

}

//  关闭结果集

rs.close();

//  关闭语句

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

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

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

发表评论

匿名网友 填写信息

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