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