// 查询语句 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/
评论