--判断指定学号的学生信息记录是否存在 create or replace procedure find_stu(p_sno in char, p_find out char) as begin select sno into p_find from student where sno = p_sno; end find_stu; cs = conn.prepareCall("{ call find_stu(?,?) }"); cs.setString(1, sno); cs.registerOutParameter(2, Types.CHAR); cs.execute(); System.out.println("查询的学号为:" + cs.getString(2)); 当student表中存在sno为:2020001的学生时,能查到sno; 如果不存在sno为:2020999时,执行发生异常,报错: 严重: null java.sql.SQLException: ORA-01403: 未找到任何数据 ORA-06512: 在 "HR.FIND_STU", line 4 ORA-06512: 在 line 1 使用以下方法时,无论学号是否存在,都能正确执行不报错,怎样才能达到下面的效果? String sql = "select sno from student where sno=?"; psmt = conn.prepareStatement(sql); psmt.setString(1, sno); rs = psmt.executeQuery(); if (rs.next()) { return true; }