ps.setInt(3,UserDataLocal.STATUS_NEW); ps.setInt(4,UserDataLocal.STATUS_KEYRECOVERY);
ps.setInt(3,UserDataConstants.STATUS_NEW); ps.setInt(4,UserDataConstants.STATUS_KEYRECOVERY);
    public UserDataVO getNextHardTokenToGenerate(Admin admin, String alias) throws UnavailableTokenException{      debug(">getNextHardTokenToGenerate()");      debug("alias " + alias);      UserDataVO returnval=null;      int issuerid = getHardTokenSession().getHardTokenIssuerId(admin, alias);      debug("issuerid " + issuerid);      if(issuerid != LocalHardTokenSessionBean.NO_ISSUER){        Connection con = null;        ResultSet rs = null;        PreparedStatement ps = null;        try{           // Construct SQL query.        	debug("HERE");            con = JDBCUtil.getDBConnection(JNDINames.DATASOURCE);            ps = con.prepareStatement("select " + USERDATA_COL + " from UserData where hardTokenIssuerId=? and tokenType>? and (status=? or status=?)" );            ps.setInt(1,issuerid);            ps.setInt(2,SecConst.TOKEN_SOFT);            ps.setInt(3,UserDataLocal.STATUS_NEW);            ps.setInt(4,UserDataLocal.STATUS_KEYRECOVERY);            // Execute query.            rs = ps.executeQuery();            // Assemble result.           if(rs.next()){           	  // TODO add support for Extended Information              returnval = new UserDataVO(rs.getString(1), rs.getString(2), rs.getInt(14), rs.getString(3), rs.getString(4), rs.getInt(5), rs.getInt(6)                                               , rs.getInt(10), rs.getInt(11)                                               , new java.util.Date(rs.getLong(8)), new java.util.Date(rs.getLong(9))                                               ,  rs.getInt(12), rs.getInt(13),null);              returnval.setPassword(rs.getString(7));              debug("found user" + returnval.getUsername());            }            if(returnval !=null){              getHardTokenSession().getIsHardTokenProfileAvailableToIssuer(admin, issuerid, returnval);              getLogSession().log(admin, returnval.getCAId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),returnval.getUsername(), null, LogEntry.EVENT_INFO_HARDTOKEN_USERDATASENT,"Userdata sent for token generation to issuer with alias :" + alias);            }        }catch(Exception e){          getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKEN_USERDATASENT,"Error when retrieving next token for issuer with alias: " + alias);          throw new EJBException(e);        } finally {            JDBCUtil.close(con, ps, rs);        }      }      debug("<getNextHardTokenToGenerate()");      return returnval;    }// getNextHardTokenToGenerate