Package java.sql

Examples of java.sql.ResultSet.first()


    long idgame = gameResult.getLong(1);

    // Check database entries for the players in the game.
    // There should be exactly 10 entries, just as usual.
    ResultSet gamePlayerResult = dbStatement.executeQuery("SELECT COUNT(*) FROM game_has_player WHERE game_idgame = " + idgame);
    gamePlayerResult.first();
    assertEquals(10, gamePlayerResult.getLong(1));
    // Each player should have a place in the range 1..10
    ResultSet winnerResult = dbStatement.executeQuery(
        "SELECT place FROM game_has_player LEFT JOIN player_login on (game_has_player.player_idplayer = player_login.id) WHERE game_idgame = " + idgame);
    winnerResult.first();
View Full Code Here


    gamePlayerResult.first();
    assertEquals(10, gamePlayerResult.getLong(1));
    // Each player should have a place in the range 1..10
    ResultSet winnerResult = dbStatement.executeQuery(
        "SELECT place FROM game_has_player LEFT JOIN player_login on (game_has_player.player_idplayer = player_login.id) WHERE game_idgame = " + idgame);
    winnerResult.first();
    for (int i = 0; i < 9; i++) {
      assertTrue(winnerResult.getLong(1) >= 1);
      assertTrue(winnerResult.getLong(1) <= 10);
      winnerResult.next();
    }
View Full Code Here

  @Test
  public void testRunRankingGame() throws Exception {

    Statement dbStatement = dbConn.createStatement();
    ResultSet countBeforeResult = dbStatement.executeQuery("SELECT COUNT(idgame) FROM game");
    countBeforeResult.first();
    long countBefore = countBeforeResult.getLong(1);

    int firstPlayerId = userInit();

    // Waiting for player list update.
View Full Code Here

    // Last player money should be sum of all money.
    assertEquals(10000 * 10, lastPlayerMoney);

    // Check database entry for the game.
    ResultSet countAfterResult = dbStatement.executeQuery("SELECT COUNT(idgame) FROM game");
    countAfterResult.first();
    long countAfter = countAfterResult.getLong(1);
    assertEquals(countBefore + 1, countAfter);

    // Select the latest game.
    ResultSet gameResult = dbStatement.executeQuery("SELECT idgame, name, start_time, end_time FROM game WHERE start_time = (SELECT MAX(start_time) from game)");
View Full Code Here

    long countAfter = countAfterResult.getLong(1);
    assertEquals(countBefore + 1, countAfter);

    // Select the latest game.
    ResultSet gameResult = dbStatement.executeQuery("SELECT idgame, name, start_time, end_time FROM game WHERE start_time = (SELECT MAX(start_time) from game)");
    gameResult.first();
    long idgame = gameResult.getLong(1);
    String dbGameName = gameResult.getString(2);
    assertEquals(dbGameName, gameName);
    java.sql.Timestamp gameStart = gameResult.getTimestamp(3);
    java.sql.Timestamp gameEnd = gameResult.getTimestamp(4);
View Full Code Here

    assertTrue(gameDurationMsec > 10 * 1000); // game duration should be larger than 10 seconds.
    assertTrue(gameDurationMsec < 60 * 60 * 1000); // game duration should be smaller than 1 hour.

    // Check database entries for the players in the game.
    ResultSet gamePlayerResult = dbStatement.executeQuery("SELECT COUNT(*) FROM game_has_player WHERE game_idgame = " + idgame);
    gamePlayerResult.first();
    assertEquals(10, gamePlayerResult.getLong(1));
    // The one who always went all in should have won!
    ResultSet winnerResult = dbStatement.executeQuery(
        "SELECT place FROM game_has_player LEFT JOIN player_login on (game_has_player.player_idplayer = player_login.id) WHERE game_idgame = " + idgame + " AND username = '" + AuthUser + "'");
    winnerResult.first();
View Full Code Here

    gamePlayerResult.first();
    assertEquals(10, gamePlayerResult.getLong(1));
    // The one who always went all in should have won!
    ResultSet winnerResult = dbStatement.executeQuery(
        "SELECT place FROM game_has_player LEFT JOIN player_login on (game_has_player.player_idplayer = player_login.id) WHERE game_idgame = " + idgame + " AND username = '" + AuthUser + "'");
    winnerResult.first();
    assertEquals(1, winnerResult.getLong(1));
  }
}
View Full Code Here

        assertTrue(!rs.next());
        assertTrue(!rs.next());
        assertTrue(!rs.next());
        assertTrue(!rs.next());
        assertTrue(!rs.previous());
        assertTrue(!rs.first());
        assertTrue(!rs.last());
        assertEquals(0, rs.getRow());
        assertTrue(!rs.absolute(1));
        assertTrue(!rs.relative(1));
        assertTrue(!rs.isBeforeFirst());
View Full Code Here

        catch (SQLException e)
        {
        }
        try
        {
            rs.first();
            fail("first() on a TYPE_FORWARD_ONLY resultset did not throw an exception");
        }
        catch (SQLException e)
        {
        }
View Full Code Here

    {
        Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        ResultSet rs = stmt.executeQuery("SELECT * FROM testrs where id=100");
        rs.beforeFirst();
        rs.afterLast();
        assertTrue(!rs.first());
        assertTrue(!rs.last());
        assertTrue(!rs.next());
    }

    public void testMaxFieldSize() throws SQLException
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.