当前位置:Gxlcms > 数据库问题 > jdbc 读取oracle long raw 字段,里面存的是文本

jdbc 读取oracle long raw 字段,里面存的是文本

时间:2021-07-01 10:21:17 帮助过:14人阅读

= 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("输出异常"); } }

基本上是流操作;

 

jdbc 读取oracle long raw 字段,里面存的是文本

标签:try   .com   tin   sdn   jdbc   catch   pre   resultset   port   

人气教程排行