con = getConnection();
con = JDBCUtil.getDBConnection(JNDINames.DATASOURCE);
    public UserAdminData getNextHardTokenToGenerateInQueue(Admin admin, String alias, int index) throws UnavailableTokenException{      debug(">getNextHardTokenToGenerateInQueue()");      UserAdminData returnval=null;      int issuerid = getHardTokenSession().getHardTokenIssuerId(admin, alias);      if(issuerid != LocalHardTokenSessionBean.NO_ISSUER){        Connection con = null;        PreparedStatement ps = null;        ResultSet rs = null;        try{           // Construct SQL query.            con = getConnection();            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);            // Assemble result.           if(rs.relative(index)){              returnval = new UserAdminData(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));              returnval.setPassword(rs.getString(7));            }            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("<getNextHardTokenToGenerateInQueue()");      return returnval;    }// getNextHardTokenToGenerateInQueue