问题描述
public boolean isExists(Operator operator) {Connection conn = null;PreparedStatement stmt = null;boolean tmp = false;try {conn = OracleDAOFactory.getConnection(); //conn = OracleDAOFactory.getConnection();stmt = conn.prepareStatement(GET_AN_OPERATOR);stmt.setString(1, operator.getOperator_ID());stmt.setString(2, operator.getOperator_Pwd());System.out.println(operator.getOperator_ID() + " && "+ operator.getOperator_Pwd());ResultSet rs = stmt.executeQuery();if (rs.next()) { //执行不到这里...tmp = true; }}catch (SQLException e) {tmp = false;} finally {OracleDAOFactory.closeStatement(stmt);OracleDAOFactory.closeConnection(conn);}return tmp;}
解决方案
代码没看出有什么毛病,可能是SQL语句的事,请楼主检查下stmt = conn.prepareStatement(GET_AN_OPERATOR); 在创建PreparedStatement对象时传入的sql语句(不知道GET_AN_OPERATOR是个什么常量),在看下stmt.setString(1, operator.getOperator_ID()); stmt.setString(2, operator.getOperator_Pwd()); 设置值的时候顺序是否正确
解决方案二:
sql文单独执行过,并确认有结果么?debug状态下结果集当中有数据么??重新编译、发布一下