Package java.sql

Examples of java.sql.ResultSet.first()


          "SELECT e.id FROM Employee e ORDER BY e.id");

      rs.last();
      int rowCount = rs.getRow();
      idList = new int[rowCount];
      rs.first();

      int i = 0;
      while (rs.next()) {
        idList[i] = rs.getInt(1);
        i++;
View Full Code Here


      /*
       * First, check if they have logged in somewhere else.
       * This is useful for when as server loses its internet connection
       */
      ResultSet data = m_database.query("SELECT * FROM pn_members WHERE id='" + p.getId() "'");
      data.first();
      if(data.getLong("lastLoginTime") == p.getLastLoginTime()) {
        /* Check they are not trading */
        if(p.isTrading()) {
          /* If the trade is still executing, don't save them yet */
          if(!p.getTrade().endTrade())
 
View Full Code Here

       * This needs to be done so it can be attached to the player in the database later.
       */
      ResultSet result = db.query("SELECT * FROM pn_pokemon WHERE originalTrainerName='"  + MySqlManager.parseSQL(p.getOriginalTrainer()) +
          "' AND date='" + MySqlManager.parseSQL(p.getDateCaught()) + "' AND name='" + p.getSpeciesName() + "' AND exp='" +
          String.valueOf(p.getExp()) + "'");
      result.first();
      p.setDatabaseID(result.getInt("id"));
      db.query("UPDATE pn_pokemon SET move0='" + MySqlManager.parseSQL(p.getMove(0).getName()) +
          "', move1='" + (p.getMove(1) == null ? "null" : MySqlManager.parseSQL(p.getMove(1).getName())) +
          "', move2='" + (p.getMove(2) == null ? "null" : MySqlManager.parseSQL(p.getMove(2).getName())) +
          "', move3='" + (p.getMove(3) == null ? "null" : MySqlManager.parseSQL(p.getMove(3).getName())) +
View Full Code Here

        session.write("l1");
        return;
      }
      //Now, check they are not banned
      ResultSet result = m_database.query("SELECT * FROM pn_bans WHERE ip='" + getIp(session) + "'");
      if(result != null && result.first()) {
        //This is player is banned, inform them
        session.write("l4");
        return;
      }
      //Then find the member's information
View Full Code Here

        session.write("l4");
        return;
      }
      //Then find the member's information
      result = m_database.query("SELECT * FROM pn_members WHERE username='" + MySqlManager.parseSQL(username) + "'");
      if(!result.first()){
        //Member doesn't exist, say user or pass wrong. We don't want someone to guess usernames.
        session.write("le");
        return;
      }
      //Check if the password is correct
View Full Code Here

 
    if(m_database.connect(GameServer.getDatabaseHost(), GameServer.getDatabaseUsername(), GameServer.getDatabasePassword())) {
      if(m_database.selectDatabase(GameServer.getDatabaseName())) {
        ResultSet result = m_database.query("SELECT * FROM pn_members WHERE username='" + MySqlManager.parseSQL(username) + "'");
        try {
          if(result.first()){
            // if we got a result, compare their old password to the one we have stored for them
            if(result.getString("password").compareTo(oldPassword) == 0) {
              // old password matches the one on file, therefore they got their old password correct, so it can be changed to their new one
              m_database.query("UPDATE pn_members SET password='" + MySqlManager.parseSQL(newPassword) + "' WHERE username='" + MySqlManager.parseSQL(username) + "'");
              // tell them their password was changed successfully
View Full Code Here

      p.setCoordinatingExp(result.getInt("skCoord"));
      p.setBreedingExp(result.getInt("skBreed"));
      //Retrieve refences to all Pokemon
      int partyId = result.getInt("party");
      ResultSet partyData = m_database.query("SELECT * FROM pn_party WHERE id='" + partyId + "'");
      partyData.first();
     
      ResultSet pokemons = m_database.query("SELECT * FROM pn_pokemon WHERE currentTrainerName='" + p.getName() + "'");
      int boxNumber = 0;
      int boxPosition = 0;
      /* Loop through all Pokemon belonging to this player and add them to their party/box */
 
View Full Code Here

      int s = Integer.parseInt(info[4]);
      /*
       * Check if the user exists
       */
      ResultSet data = m_database.query("SELECT * FROM pn_members WHERE username='" + MySqlManager.parseSQL(info[0]) + "'");
      data.first();
      try {       
        if(data != null && data.getString("username") != null && data.getString("username").equalsIgnoreCase(MySqlManager.parseSQL(info[0]))) {
          session.resumeRead();
          session.resumeWrite();
          session.write("r2");
View Full Code Here

      } catch (Exception e) {}
      /*
       * Check if an account is already registered with the email
       */
      data = m_database.query("SELECT * FROM pn_members WHERE email='" + MySqlManager.parseSQL(info[2]) + "'");
      data.first();
      try {       
        if(data != null && data.getString("email") != null && data.getString("email").equalsIgnoreCase(MySqlManager.parseSQL(info[2]))) {
          session.resumeRead();
          session.resumeWrite();
          session.write("r5");
View Full Code Here

                  + mapX + "', '" + mapY + "', 'false', '0', 'false')");
      /*
       * Retrieve the player's unique id
       */
      data = m_database.query("SELECT * FROM pn_members WHERE username='" + MySqlManager.parseSQL(info[0]) + "'");
      data.first();
      int playerId = data.getInt("id");
      //Player's bag is now created "on the fly" as soon as player gets his first item.
      /*
       * Create the players party
       */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.