Example usage for java.sql ResultSet getFetchSize

List of usage examples for java.sql ResultSet getFetchSize

Introduction

In this page you can find the example usage for java.sql ResultSet getFetchSize.

Prototype

int getFetchSize() throws SQLException;

Source Link

Document

Retrieves the fetch size for this ResultSet object.

Usage

From source file:com.alibaba.wasp.jdbc.TestJdbcResultSet.java

@Test
public void testInt() throws SQLException {
    trace("test INT");
    ResultSet rs;
    Object o;//from   ww  w  .ja v a  2s  .  co  m
    stat = conn.createStatement();
    stat.execute("INSERT INTO test (column1,column2,column3) VALUES(31,-1, 'testInt')");
    stat.execute("INSERT INTO test (column1,column2,column3) VALUES(32,0, 'testInt')");
    stat.execute("INSERT INTO test (column1,column2,column3) VALUES(33,1, 'testInt')");
    stat.execute("INSERT INTO test (column1,column2,column3) VALUES(34," + Integer.MAX_VALUE + ", 'testInt')");
    stat.execute("INSERT INTO test (column1,column2,column3) VALUES(35," + Integer.MIN_VALUE + ", 'testInt')");
    stat.execute("INSERT INTO test (column1,column2,column3) VALUES(36,0, 'testInt')");
    stat.execute("INSERT INTO test (column1,column2,column3) VALUES(37,0, 'testInt')");
    // this should not be read - maxrows=6

    // MySQL compatibility (is this required?)
    rs = stat.executeQuery("SELECT column1,column2,column3 FROM test where column3='testInt' ORDER BY column1");
    // MySQL compatibility
    assertEquals(1, rs.findColumn("column1"));
    assertEquals(2, rs.findColumn("column2"));

    ResultSetMetaData meta = rs.getMetaData();
    assertEquals(3, meta.getColumnCount());

    assertTrue(rs.getRow() == 0);

    rs.next();
    trace("default fetch size=" + rs.getFetchSize());
    // 0 should be an allowed value (but it's not defined what is actually
    // means)
    rs.setFetchSize(1);
    assertThrows(SQLErrorCode.INVALID_VALUE_2, rs).setFetchSize(-1);
    // fetch size 100 is bigger than maxrows - not allowed
    rs.setFetchSize(6);

    assertTrue(rs.getRow() == 1);
    assertEquals(2, rs.findColumn("COLUMN2"));
    assertEquals(2, rs.findColumn("column2"));
    assertEquals(2, rs.findColumn("Column2"));
    assertEquals(1, rs.findColumn("COLUMN1"));
    assertEquals(1, rs.findColumn("column1"));
    assertEquals(1, rs.findColumn("Column1"));
    assertEquals(1, rs.findColumn("colUMN1"));
    assertTrue(rs.getInt(2) == -1 && !rs.wasNull());
    assertTrue(rs.getInt("COLUMN2") == -1 && !rs.wasNull());
    assertTrue(rs.getInt("column2") == -1 && !rs.wasNull());
    assertTrue(rs.getInt("Column2") == -1 && !rs.wasNull());
    assertTrue(rs.getString("Column2").equals("-1") && !rs.wasNull());

    o = rs.getObject("column2");
    trace(o.getClass().getName());
    assertTrue(o instanceof Long);
    assertTrue(((Long) o).longValue() == -1);
    o = rs.getObject(2);
    trace(o.getClass().getName());
    assertTrue(o instanceof Long);
    assertTrue(((Long) o).longValue() == -1);
    assertTrue(rs.getBoolean("Column2"));
    assertTrue(rs.getByte("Column2") == (byte) -1);
    assertTrue(rs.getShort("Column2") == (short) -1);
    assertTrue(rs.getLong("Column2") == -1);
    assertTrue(rs.getFloat("Column2") == -1.0);
    assertTrue(rs.getDouble("Column2") == -1.0);

    assertTrue(rs.getString("Column2").equals("-1") && !rs.wasNull());
    assertTrue(rs.getInt("COLUMN1") == 31 && !rs.wasNull());
    assertTrue(rs.getInt("column1") == 31 && !rs.wasNull());
    assertTrue(rs.getInt("Column1") == 31 && !rs.wasNull());
    assertTrue(rs.getInt(1) == 31 && !rs.wasNull());
    rs.next();
    assertTrue(rs.getRow() == 2);
    assertTrue(rs.getInt(2) == 0 && !rs.wasNull());
    assertTrue(!rs.getBoolean(2));
    assertTrue(rs.getByte(2) == 0);
    assertTrue(rs.getShort(2) == 0);
    assertTrue(rs.getLong(2) == 0);
    assertTrue(rs.getFloat(2) == 0.0);
    assertTrue(rs.getDouble(2) == 0.0);
    assertTrue(rs.getString(2).equals("0") && !rs.wasNull());
    assertTrue(rs.getInt(1) == 32 && !rs.wasNull());
    rs.next();
    assertTrue(rs.getRow() == 3);
    assertTrue(rs.getInt("COLUMN1") == 33 && !rs.wasNull());
    assertTrue(rs.getInt("COLUMN2") == 1 && !rs.wasNull());
    rs.next();
    assertTrue(rs.getRow() == 4);
    assertTrue(rs.getInt("COLUMN1") == 34 && !rs.wasNull());
    assertTrue(rs.getInt("COLUMN2") == Integer.MAX_VALUE && !rs.wasNull());
    rs.next();
    assertTrue(rs.getRow() == 5);
    assertTrue(rs.getInt("column1") == 35 && !rs.wasNull());
    assertTrue(rs.getInt("column2") == Integer.MIN_VALUE && !rs.wasNull());
    assertTrue(rs.getString(1).equals("35") && !rs.wasNull());
    rs.next();
    assertTrue(rs.getRow() == 6);
    assertTrue(rs.getInt("column1") == 36 && !rs.wasNull());
    assertTrue(rs.getInt("column2") == 0 && !rs.wasNull());
    assertTrue(rs.getInt(2) == 0 && !rs.wasNull());
    assertTrue(rs.getInt(1) == 36 && !rs.wasNull());
    assertTrue(rs.getString(1).equals("36") && !rs.wasNull());
    assertTrue(rs.getString(2).equals("0") && !rs.wasNull());
    assertTrue(!rs.wasNull());
    // assertFalse(rs.next());
    // assertEquals(0, rs.getRow());
    // there is one more row, but because of setMaxRows we don't get it
}

From source file:com.github.woonsan.jdbc.jcr.impl.JcrJdbcResultSetTest.java

@Test
public void testResultSetOptions() throws Exception {
    Statement statement = getConnection().createStatement();
    ResultSet rs = statement.executeQuery(SQL_EMPS);

    assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());
    rs.setFetchDirection(ResultSet.FETCH_FORWARD);
    assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());

    try {/*ww  w .ja v a  2s.  c  o m*/
        rs.setFetchDirection(ResultSet.FETCH_REVERSE);
        fail();
    } catch (SQLException ignore) {
    }

    assertEquals(ResultSet.FETCH_FORWARD, rs.getFetchDirection());

    rs.setFetchSize(100);
    assertEquals(100, rs.getFetchSize());

    rs.close();
    statement.close();
}

From source file:com.skilrock.lms.coreEngine.accMgmt.common.PWTPlayerHelper.java

/**
 * This method is used to get verified Tickets for the VIRN code.
 * /*w w  w. j  ava  2  s . com*/
 * @param virnCode
 * @param gameId
 * @return boolean
 * @throws LMSException
 */

public boolean getverifyPwtTickets(String virnCode, int gameId, int gameNbr) throws LMSException {

    List<PwtBean> pwtList = new ArrayList();

    String encodedVirnCode = getEncodedVirnCode(virnCode);
    logger.debug("---((((((::" + encodedVirnCode);

    Connection connection = null;
    // Statement statement = null;
    PreparedStatement statement = null;
    Statement statement1 = null;
    // Statement statement2 = null;
    // Statement statement3 = null;

    ResultSet resultSet = null;
    ResultSet resultSet1 = null;
    // ResultSet resultSet2 = null;
    // ResultSet resultSet3 = null;

    boolean isVerified = false;
    PwtBean pwtBean = new PwtBean();
    // StringBuffer query = new StringBuffer();

    try {

        connection = DBConnect.getConnection();

        /*
         * //to check virn for temporary table
         * 
         * String queryTOChqPwtTemptable="select * from st_se_tmp_pwt_inv
         * where virn_code='"+encodedVirnCode+"' and game_id="+gameId;
         * logger.debug("Query for pwt temporary table::
         * "+queryTOChqPwtTemptable);
         * statement2=connection.createStatement();
         * resultSet2=statement2.executeQuery(queryTOChqPwtTemptable);
         * 
         * if(!resultSet2.next()){
         */

        /*
         * statement = connection.createStatement();
         * query.append(QueryManager.getST1PWTCheckQuery()); query.append("
         * game_id = "); query.append("" + gameId); query.append(" and
         * virn_code='"); query.append(encodedVirnCode); query.append("'");
         */

        statement = connection.prepareStatement(QueryManager.getST1PWTCheckQuery());
        statement.setInt(1, gameNbr);
        statement.setInt(2, gameId);
        statement.setString(3, encodedVirnCode);

        logger.debug("GameId:" + gameId);
        // logger.debug("Query:: " + query);
        resultSet = statement.executeQuery();
        logger.debug("ResultSet:" + resultSet + "---" + resultSet.getFetchSize());

        String vCode = null;
        String pwtAmount = null;
        String prizeLevel = null;
        String prizeStaus = null;
        String directPlrTempTableStatus = null;
        boolean directPlrTempTableFlag = false;
        if (resultSet.next()) {

            vCode = resultSet.getString(TableConstants.SPI_VIRN_CODE);
            logger.debug("Vcode:" + vCode);
            pwtAmount = resultSet.getString(TableConstants.SPI_PWT_AMT);
            prizeLevel = resultSet.getString(TableConstants.SPI_PRIZE_LEVEL);
            prizeStaus = resultSet.getString("status");

            if (prizeStaus.equalsIgnoreCase("CLAIM_RET")) {

                String orgnameRet = null;
                String receiptNumber = null;
                Timestamp receiptTime = null;
                statement1 = connection.createStatement();
                // String retDetailsQuery="select name from
                // st_lms_organization_master where organization_id in
                // (select retailer_org_id from st_se_agent_pwt where
                // virn_code='"+vCode+"' and game_id="+gameId+")";
                String retDetailsQuery = "select a.name,c.generated_id,e.transaction_date from st_lms_organization_master a,st_se_agent_pwt b,st_lms_agent_receipts c,st_lms_agent_transaction_master e where b.virn_code='"
                        + vCode + "' and b.game_id=" + gameId
                        + " and a.organization_id=b.retailer_org_id and b.transaction_id=e.transaction_id and c.receipt_id=(select receipt_id from st_lms_agent_receipts_trn_mapping where transaction_id=e.transaction_id)";
                logger.debug("query for get org name " + retDetailsQuery);
                resultSet1 = statement1.executeQuery(retDetailsQuery);
                while (resultSet1.next()) {
                    orgnameRet = resultSet1.getString("name");
                    receiptNumber = resultSet1.getString("generated_id");
                    receiptTime = resultSet1.getTimestamp("transaction_date");
                }

                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                // pwtBean.setMessage("Already Paid by Agent for retailer
                // "+orgnameRet+".it is to be paid as PWT from Agent,not as
                // Direct Player PWT");
                // pwtBean.setMessage("Already Paid to Retailer :" +
                // orgnameRet+" with receipt number :"+receiptNumber+" on
                // "+receiptTime);
                pwtBean.setMessage("Already Paid to Retailer: " + orgnameRet + " on Voucher Number: "
                        + receiptNumber + " at " + receiptTime);
                pwtBean.setMessageCode("112101");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;

            } else if (prizeStaus.equalsIgnoreCase("CLAIM_AGT_TEMP")) {

                String orgname = null;
                String receiptNumber = null;
                Timestamp receiptTime = null;
                statement1 = connection.createStatement();
                // String agtDetailsQuery="select name from
                // st_lms_organization_master where organization_id in
                // (select agent_org_id from st_se_bo_pwt where
                // virn_code='"+vCode+"' and game_id="+gameId+")";
                String agtDetailsQuery = "select a.receipt_id,a.date_entered ,b.name from st_se_tmp_pwt_inv a,st_lms_organization_master b  where virn_code='"
                        + vCode + "' and game_id=" + gameId
                        + " and organization_id=(select organization_id from st_lms_user_master where user_id=a.user_id)";
                logger.debug("query for get org name " + agtDetailsQuery);
                resultSet1 = statement1.executeQuery(agtDetailsQuery);
                while (resultSet1.next()) {
                    orgname = resultSet1.getString("name");
                    receiptNumber = resultSet1.getString("receipt_id");
                    receiptTime = resultSet1.getTimestamp("date_entered");
                }

                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                // pwtBean.setMessage("Already Verified in Bulk Receipt at
                // BO, Fianl Payment Pending ");
                // pwtBean.setMessage("Already Verified in Bulk Receipt at
                // BO for agent: "+orgname+",Receipt number:
                // "+receiptNumber+" on "+receiptTime+", Fianl Payment
                // Pending");
                pwtBean.setMessage("Already Verified in Bulk Receipt at BO for agent: " + orgname
                        + " on Bulk Receipt Number: " + receiptNumber + " at " + receiptTime
                        + ", Final Payment Pending");
                pwtBean.setMessageCode("112102");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;

            } else if (prizeStaus.equalsIgnoreCase("CLAIM_RET_AGT_TEMP")) {

                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("Already Verified in Bulk Receipt at BO, Fianl Payment Pending");
                pwtBean.setMessageCode("112103");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;

            } else if (prizeStaus.equalsIgnoreCase("CLAIM_AGT")) {

                String orgname = null;
                String receiptNumber = null;
                Timestamp receiptTime = null;
                statement1 = connection.createStatement();
                // String agtDetailsQuery="select name from
                // st_lms_organization_master where organization_id in
                // (select agent_org_id from st_se_bo_pwt where
                // virn_code='"+vCode+"' and game_id="+gameId+")";
                String agtDetailsQuery = "select a.name,c.generated_id,e.transaction_date from st_lms_organization_master a,st_se_bo_pwt b,st_lms_bo_receipts c,st_lms_bo_transaction_master e where b.virn_code='"
                        + vCode + "' and b.game_id=" + gameId
                        + " and a.organization_id=b.agent_org_id and b.transaction_id=e.transaction_id and c.receipt_id=(select receipt_id from st_lms_bo_receipts_trn_mapping where transaction_id=e.transaction_id)";
                logger.debug("query for get org name " + agtDetailsQuery);
                resultSet1 = statement1.executeQuery(agtDetailsQuery);
                while (resultSet1.next()) {
                    orgname = resultSet1.getString("name");
                    receiptNumber = resultSet1.getString("generated_id");
                    receiptTime = resultSet1.getTimestamp("transaction_date");
                }

                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                // pwtBean.setMessage("Already paid to Agent:: "+orgname);
                // pwtBean.setMessage("Already Paid to Agent :" + orgname+"
                // with receipt number :"+receiptNumber+" on "+receiptTime);
                pwtBean.setMessage("Already Paid to Agent: " + orgname + " on Voucher Number: " + receiptNumber
                        + " at " + receiptTime);
                pwtBean.setMessageCode("112104");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;
            } else if (prizeStaus.equalsIgnoreCase("CLAIM_PLR_TEMP")) {

                String playerFirstName = null;
                String playerLastName = null;
                String playercity = null;
                String receiptNumber = null;
                Timestamp receiptTime = null;
                statement1 = connection.createStatement();
                // String plrDetailsQuery="select first_name,last_name,city
                // from st_lms_player_master where player_id in (select
                // player_id from st_se_direct_player_pwt where
                // virn_code='"+vCode+"' and game_id="+gameId+")";
                String plrDetailsQuery = "select a.pwt_receipt_id,a.transaction_date,b.first_name,b.last_name,b.city from st_se_direct_player_pwt_temp_receipt a,st_lms_player_master b where a.virn_code='"
                        + vCode + "' and a.game_id=" + gameId + " and b.player_id=a.player_id";
                logger.debug("query for get player name " + plrDetailsQuery);
                resultSet1 = statement1.executeQuery(plrDetailsQuery);
                while (resultSet1.next()) {
                    playerFirstName = resultSet1.getString("first_name");
                    playerLastName = resultSet1.getString("last_name");
                    playercity = resultSet1.getString("city");
                    receiptNumber = resultSet1.getString("pwt_receipt_id");
                    receiptTime = resultSet1.getTimestamp("transaction_date");
                }

                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                // pwtBean.setMessage("Already Verified and in process for
                // Direct Player PWT");
                // pwtBean.setMessage("Already in Process for Direct Player
                // PWT for Player: "+playerFirstName+" "+playerLastName+"
                // "+playercity+" with temporary Receipt Number:
                // "+receiptNumber+" issued on
                // "+receiptTime+",Payment/Approval Pending");
                pwtBean.setMessage("Already in Process for Direct Player PWT for Player: " + playerFirstName
                        + " " + playerLastName + "," + playercity + " on Temporary Receipt Number: "
                        + receiptNumber + " issued on " + receiptTime + ",Payment/Approval Pending");
                pwtBean.setMessageCode("112105");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;

            } else if (prizeStaus.equalsIgnoreCase("CLAIM_PLR")) {
                String playerFirstName = null;
                String playerLastName = null;
                String playercity = null;
                String receiptNumber = null;
                Timestamp receiptTime = null;
                statement1 = connection.createStatement();
                // String plrDetailsQuery="select first_name,last_name,city
                // from st_lms_player_master where player_id in (select
                // player_id from st_se_direct_player_pwt where
                // virn_code='"+vCode+"' and game_id="+gameId+")";
                String plrDetailsQuery = "select b.first_name,b.last_name,b.city,a.transaction_date,c.generated_id from st_se_direct_player_pwt a,st_lms_player_master b,st_lms_bo_receipts c where a.virn_code='"
                        + vCode + "' and a.game_id=" + gameId
                        + " and a.player_id=b.player_id and c.receipt_id=(select receipt_id from st_lms_bo_receipts_trn_mapping where transaction_id=a.transaction_id)";
                logger.debug("query for get player name " + plrDetailsQuery);
                resultSet1 = statement1.executeQuery(plrDetailsQuery);
                while (resultSet1.next()) {
                    playerFirstName = resultSet1.getString("first_name");
                    playerLastName = resultSet1.getString("last_name");
                    playercity = resultSet1.getString("city");
                    receiptNumber = resultSet1.getString("generated_id");
                    receiptTime = resultSet1.getTimestamp("transaction_date");
                }

                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                // pwtBean.setMessage("Already paid as Direct Player PWT to
                // Player " +playerFirstName+ " " +playerLastName+" "+
                // playercity);
                // pwtBean.setMessage("Already Paid as Direct Player PWT to
                // Player: "+playerFirstName+" "+playerLastName+ " "
                // +playercity+" with receipt "+receiptNumber+" on
                // "+receiptTime);
                pwtBean.setMessage("Already Paid as Direct Player PWT to Player: " + playerFirstName + " "
                        + playerLastName + "," + playercity + " on Voucher Number " + receiptNumber + " at "
                        + receiptTime);
                pwtBean.setMessageCode("112106");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;

            } else if (prizeStaus.equalsIgnoreCase("CLAIM_PLR_RET")) {
                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("This Virn has been paid to Player but not claimed by retailer ");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;

            } else if (prizeStaus.equalsIgnoreCase("CLAIM_RET_TEMP")) {
                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("Already Verified in Bulk Receipt at Agent, Fianl Payment Pending");
                pwtBean.setMessageCode("112107");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;
            } else if (prizeStaus.equalsIgnoreCase("CLAIM_PLR_RET_TEMP")) {
                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("Already Verified in Bulk Receipt at Agent, Fianl Payment Pending");
                pwtBean.setMessageCode("112108");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;
            } else if (prizeStaus.equalsIgnoreCase("UNCLM_PWT")) {

                pwtBean.setValid(true);
                pwtBean.setPwtAmount(pwtAmount);
                pwtBean.setHighLevel(true);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("Register Player for further Process");
                pwtBean.setMessageCode("111101");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = true;

            } else if (prizeStaus.equalsIgnoreCase("UNCLM_CANCELLED")) {

                pwtBean.setValid(true);
                pwtBean.setPwtAmount(pwtAmount);
                pwtBean.setHighLevel(true);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("Register Player for further Process");
                pwtBean.setMessageCode("111103");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = true;

            } else if (prizeStaus.equalsIgnoreCase("CANCELLED_PERMANEMT")) {
                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("Tampered/Damaged/Defaced VIRN as noted at BO");
                pwtBean.setMessageCode("112109");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;
            } else {
                pwtBean.setValid(false);
                pwtBean.setHighLevel(false);
                pwtBean.setVirnCode(virnCode);
                pwtBean.setMessage("This Virn is Fake ");
                pwtList.add(pwtBean);
                setPwtList(pwtList);
                isVerified = false;

            }

        } else {
            pwtBean.setValid(false);
            pwtBean.setHighLevel(false);
            pwtBean.setVirnCode(virnCode);
            pwtBean.setMessage("No Prize");
            pwtBean.setMessageCode("112111");
            pwtList.add(pwtBean);
            setPwtList(pwtList);
            isVerified = false;
        }

        /*
         * 
         * if(prizeStaus.equalsIgnoreCase("UNCLM_PWT")){
         * 
         * //check if it is in direct player temp table String
         * directPlrTempTableChq="select status from
         * st_se_direct_player_pwt_temp_receipt where virn_code='"+vCode+"'
         * and game_id="+gameId; logger.debug("Query for direct player temp
         * table table:: "+directPlrTempTableChq);
         * statement3=connection.createStatement();
         * resultSet3=statement3.executeQuery(directPlrTempTableChq);
         * while(resultSet3.next()){ directPlrTempTableFlag=true;
         * directPlrTempTableStatus=resultSet3.getString("status"); }
         * if(directPlrTempTableFlag==true &&
         * directPlrTempTableStatus.equals("CANCEL")){
         * pwtBean.setValid(true); pwtBean.setPwtAmount(pwtAmount);
         * pwtBean.setHighLevel(true); pwtBean.setVirnCode(virnCode);
         * pwtBean.setMessage("Valid Ticket && this ticket has been
         * cancelled by BO previously So Please Check it Again");
         * pwtList.add(pwtBean); setPwtList(pwtList); isVerified=true;
         * 
         * }else if(directPlrTempTableStatus==null){ pwtBean.setValid(true);
         * pwtBean.setPwtAmount(pwtAmount); pwtBean.setHighLevel(true);
         * pwtBean.setVirnCode(virnCode); pwtBean.setMessage("Valid
         * Ticket"); pwtList.add(pwtBean); setPwtList(pwtList);
         * isVerified=true; }else
         * if(directPlrTempTableStatus.equals("PND_PWT")){
         * pwtBean.setValid(false); pwtBean.setHighLevel(false);
         * pwtBean.setVirnCode(virnCode); pwtBean.setMessage("This Ticket
         * has been verified for Direct Player PWT table so go for PWT
         * Payments"); pwtList.add(pwtBean); setPwtList(pwtList);
         * isVerified=false; }
         * 
         * 
         * }else if(prizeStaus.equalsIgnoreCase("CLAIM_PLR")){
         * 
         * 
         * String playerFirstName=null; String playerLastName=null; String
         * playercity=null; statement1=connection.createStatement(); String
         * plrDetailsQuery="select first_name,last_name,city from
         * st_lms_player_master where player_id in (select player_id from
         * st_se_direct_player_pwt where virn_code='"+vCode+"' and
         * game_id="+gameId+")"; logger.debug("query for get player name " +
         * plrDetailsQuery);
         * resultSet1=statement1.executeQuery(plrDetailsQuery);
         * while(resultSet1.next()){ playerFirstName=
         * resultSet1.getString("first_name"); playerLastName=
         * resultSet1.getString("last_name"); playercity=
         * resultSet1.getString("city"); }
         * 
         * 
         * pwtBean.setValid(false); pwtBean.setHighLevel(false);
         * pwtBean.setVirnCode(virnCode); pwtBean.setMessage("This Virn has
         * been paid By BO to Player:: " +playerFirstName+ " "
         * +playerLastName+" "+ playercity); pwtList.add(pwtBean);
         * setPwtList(pwtList); isVerified=false; }else
         * if(prizeStaus.equalsIgnoreCase("CLAIM_AGT")){
         * 
         * 
         * String orgname=null; statement1=connection.createStatement();
         * String agtDetailsQuery="select name from
         * st_lms_organization_master where organization_id in (select
         * agent_org_id from st_se_bo_pwt where virn_code='"+vCode+"' and
         * game_id="+gameId+")"; logger.debug("query for get org name " +
         * agtDetailsQuery);
         * resultSet1=statement1.executeQuery(agtDetailsQuery);
         * while(resultSet1.next()){ orgname= resultSet1.getString("name"); }
         * 
         * 
         * pwtBean.setValid(false); pwtBean.setHighLevel(false);
         * pwtBean.setVirnCode(virnCode); pwtBean.setMessage("This Virn has
         * been paid to Agent:: "+orgname+ " by BO"); pwtList.add(pwtBean);
         * setPwtList(pwtList); isVerified=false;
         * 
         * }else if(prizeStaus.equalsIgnoreCase("CLAIM_RET")){
         * 
         * String orgnameRet=null; statement1=connection.createStatement();
         * String retDetailsQuery="select name from
         * st_lms_organization_master where organization_id in (select
         * retailer_org_id from st_se_agent_pwt where virn_code='"+vCode+"'
         * and game_id="+gameId+")"; logger.debug("query for get org name " +
         * retDetailsQuery);
         * resultSet1=statement1.executeQuery(retDetailsQuery);
         * while(resultSet1.next()){ orgnameRet=
         * resultSet1.getString("name"); }
         * 
         * 
         * pwtBean.setValid(false); pwtBean.setHighLevel(false);
         * pwtBean.setVirnCode(virnCode); pwtBean.setMessage("This Virn has
         * been paid to Retailer:: "+orgnameRet+" by Agent");
         * pwtList.add(pwtBean); setPwtList(pwtList); isVerified=false; } } }
         * else{ pwtBean.setValid(false); pwtBean.setHighLevel(false);
         * pwtBean.setVirnCode(virnCode); pwtBean.setMessage("This Virn has
         * been verified for temporary table"); pwtList.add(pwtBean);
         * setPwtList(pwtList); isVerified=false; }
         */

    }

    catch (SQLException e) {
        logger.error("Exception: " + e);
        e.printStackTrace();
        throw new LMSException(e);
    } finally {

        try {

            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException se) {
            logger.error("Exception: " + se);
            se.printStackTrace();
            throw new LMSException(se);
        }
    }

    return isVerified;

}

From source file:org.easyrec.store.dao.web.impl.LoaderDAOMysqlImpl.java

private void update_0_98() {

    logger.info("executing 'update_0_98()'...");

    final String profileTableName = "profile";
    final String itemTableName = "item";
    final String itemTypeTableName = "itemtype";
    final String assocTypeTableName = "assoctype";
    final String sourceTypeTableName = "sourcetype";

    final String itemColumnTenantID = "tenantId";
    final String itemColumnItemID = "itemid";
    final String itemColumnItemType = "itemtype";
    final String itemColumnProfileData = "profileData";
    final String itemColumnChangeDate = "changedate";
    final String itemColumnActive = "active";

    final String profileColumnTenantID = "tenantId";
    final String profileColumnItemID = "itemId";
    final String profileColumnItemTypeID = "itemTypeId";
    final String profileColumnProfileData = "profileData";
    final String profileColumnChangeData = "changeDate";
    final String profileColumnActive = "active";

    final String itemTypeColumnTenantID = "tenantId";
    final String itemTypeColumnName = "name";
    final String itemTypeColumnID = "id";

    final String assocTypeTenantID = "tenantId";
    final String assocTypeName = "name";
    final String assocTypeID = "id";
    final String assocTypeVisible = "visible";

    final String sourceTypeColumnId = "id";
    final String sourceTypeColumnTenantId = "tenantId";
    final String sourceTypeColumnName = "name";

    /* Create a hashmap with the itemTypeNames as values and the
     * tenantId and itemTypeId as key.//from   w  w w.  j  a va2s .c o  m
     */
    logger.info("creating a hashmap with itemTypeNames...");
    final HashMap<String, String> itemTypeList = new HashMap<String, String>();
    getJdbcTemplate().query("SELECT * FROM " + itemTypeTableName, new RowCallbackHandler() {
        public void processRow(ResultSet resultSet) throws SQLException {
            int tenantId = resultSet.getInt(itemTypeColumnTenantID);
            int itemTypeId = resultSet.getInt(itemTypeColumnID);
            String itemTypeName = resultSet.getString(itemTypeColumnName);
            itemTypeList.put(String.valueOf(tenantId) + "," + String.valueOf(itemTypeId), itemTypeName);
        }
    });

    /*
     * For each entry in the profile table look for an entry with the same key in the
     * item table. If the item table has no entry, create it else update the entry with
     * the values from the profile table.
     */
    logger.info("executing 'update_0_98()'...");
    getJdbcTemplate().query("SELECT * FROM " + profileTableName, new RowCallbackHandler() {
        public void processRow(ResultSet resultSet) throws SQLException {

            final int tenantId = resultSet.getInt(profileColumnTenantID);
            final int itemId = resultSet.getInt(profileColumnItemID);
            int itemTypeId = resultSet.getInt(profileColumnItemTypeID);
            String tempProfileData = resultSet.getString(profileColumnProfileData);
            if (tempProfileData == null) {
                tempProfileData = "null";
            } else {
                tempProfileData = "'" + tempProfileData + "'";
            }
            final String profileData = tempProfileData;
            final String itemTypeName = "'"
                    + itemTypeList.get(String.valueOf(tenantId) + "," + String.valueOf(itemTypeId)) + "'";

            /*
             * A "0000-00-00 00:00:00" value in the table is returned as null and
             * must therefore a null value must be changed back to "0000-00-00 00:00:00"
             * before updating the table.
             */

            String tempChangeDate = resultSet.getString(profileColumnChangeData);
            if (tempChangeDate == null) {
                tempChangeDate = "0000-00-00 00:00:00";
            }
            final String changeDate = "'" + tempChangeDate + "'";
            final boolean active = resultSet.getBoolean(profileColumnActive);

            final String sqlItemUpdate = " WHERE " + itemColumnItemID + " = " + itemId + " AND "
                    + itemColumnTenantID + " = " + tenantId + " AND " + itemColumnItemType + " like "
                    + itemTypeName;

            final String sqlItemToUpdate = "FROM " + itemTableName + sqlItemUpdate;
            getJdbcTemplate().query("SELECT COUNT(*) " + sqlItemToUpdate, new RowCallbackHandler() {
                public void processRow(ResultSet resultSet) throws SQLException {
                    if (resultSet.getInt(1) == 0) { // The profile is not in the item table -> create one.
                        String sqlInsertStatement = "INSERT INTO " + itemTableName + " SET " + itemColumnItemID
                                + " = " + String.valueOf(itemId) + ", " + itemColumnTenantID + " = "
                                + String.valueOf(tenantId) + ", " + itemColumnItemType + " = " + itemTypeName
                                + ", " + itemColumnProfileData + " = " + profileData + ", "
                                + itemColumnChangeDate + " = " + changeDate + ", " + itemColumnActive + " = "
                                + String.valueOf(active);
                        logger.info("executing: " + sqlInsertStatement);
                        getJdbcTemplate().execute(sqlInsertStatement);
                    } else { // The profile has already an entry in the item table -> just updating.
                        getJdbcTemplate().query("SELECT * " + sqlItemToUpdate, new RowCallbackHandler() {
                            public void processRow(ResultSet resultSet) throws SQLException {

                                logger.info("updating item: " + resultSet.getString(itemColumnItemID));
                                getJdbcTemplate().execute("UPDATE " + itemTableName + " SET "
                                        + itemColumnProfileData + " = " + profileData + ", "
                                        + itemColumnChangeDate + " = " + changeDate + " " + sqlItemUpdate);
                            }
                        });
                    }
                }
            });
        }
    });

    getJdbcTemplate().execute("DROP TABLE " + profileTableName);

    /**
     * create association type PROFILE_SIMILARITY for the profileDuke plugin
     */

    // get list of tenantIDs in the assoctype table
    logger.info("inserting PROFILE_SIMILARITY assoc Type");
    String sql = "SELECT DISTINCT " + assocTypeTenantID + " FROM " + assocTypeTableName;
    logger.info("fireing: " + sql);
    final List<Integer> tenantIDList = new ArrayList<Integer>();
    getJdbcTemplate().query(sql, new RowCallbackHandler() {
        public void processRow(ResultSet resultSet) throws SQLException {
            int tenantIdx = resultSet.getInt(assocTypeTenantID);
            logger.info("found tenant " + tenantIdx);
            logger.info("found " + resultSet.getFetchSize() + " results");
            int tenantId = resultSet.getInt(assocTypeTenantID);
            logger.info("found tenant " + tenantId);
            tenantIDList.add(tenantId);
        }
    });

    // get the max id of each tenant and add a PROFILE_SIMILARITY association type and
    // a sourceType for the plugins with the new versions.
    Integer maxAssocTypeId;
    Integer maxSourceTypeId;
    for (final Integer tenantId : tenantIDList) {

        // association type
        maxAssocTypeId = getJdbcTemplate().queryForInt("SELECT MAX(id) FROM " + assocTypeTableName + " WHERE "
                + assocTypeTableName + "." + assocTypeTenantID + " = " + tenantId);

        sql = "INSERT INTO " + assocTypeTableName + " (" + assocTypeTenantID + ", " + assocTypeName + ", "
                + assocTypeID + ", " + assocTypeVisible + ") VALUES (" + tenantId + ", \"PROFILE_SIMILARITY\", "
                + (maxAssocTypeId + 1) + ", 1)";

        getJdbcTemplate().execute(sql);

        // sourceType
        maxSourceTypeId = getJdbcTemplate()
                .queryForInt("SELECT MAX(" + sourceTypeColumnId + ") FROM " + sourceTypeTableName + " WHERE "
                        + sourceTypeTableName + "." + sourceTypeColumnTenantId + " = " + tenantId);

        sql = "INSERT INTO " + sourceTypeTableName + " (" + sourceTypeColumnTenantId + ", "
                + sourceTypeColumnName + ", " + sourceTypeColumnId + ") VALUES (" + tenantId
                + ", \"http://www.easyrec.org/plugins/slopeone/0.98\", " + (maxSourceTypeId + 1) + ")";
        getJdbcTemplate().execute(sql);
        sql = "INSERT INTO " + sourceTypeTableName + " (" + sourceTypeColumnTenantId + ", "
                + sourceTypeColumnName + ", " + sourceTypeColumnId + ") VALUES (" + tenantId
                + ", \"http://www.easyrec.org/plugins/ARM/0.98\", " + (maxSourceTypeId + 2) + ")";
        getJdbcTemplate().execute(sql);
    }

    // update the pluginVersion on the plugin_configuration table
    sql = "UPDATE plugin_configuration SET pluginVersion = '0.98'\n"
            + "WHERE pluginId = 'http://www.easyrec.org/plugins/ARM' OR pluginId = 'http://www.easyrec.org/plugins/slopeone'";
    getJdbcTemplate().execute(sql);
}

From source file:com.comcast.oscar.dictionary.DictionarySQLQueries.java

/**
        /*from   w  ww  .ja  v  a  2  s.co m*/
+------------------------------+----------------------+------+-----+---------+----------------+
| Field                        | Type                 | Null | Key | Default | Extra          |
+------------------------------+----------------------+------+-----+---------+----------------+
| ID                           | int(10) unsigned     | NO   | PRI | NULL    | auto_increment | 
| TYPE                         | smallint(5) unsigned | NO   |     | NULL    |                | 
| PARENT_ID                    | int(10) unsigned     | YES  |     | NULL    |                | 
| TLV_NAME                     | varchar(50)          | NO   |     | NULL    |                | 
| TLV_DESCRIPTION              | text                 | NO   |     | NULL    |                | 
| LENGTH_MIN                   | smallint(5) unsigned | NO   |     | NULL    |                | 
| LENGTH_MAX                   | smallint(5) unsigned | NO   |     | NULL    |                | 
| DATA_TYPE                    | varchar(50)          | YES  |     | NULL    |                | 
| BYTE_LENGTH                  | tinyint(3) unsigned  | NO   |     | NULL    |                | 
| DB_TBL_COL_SUPPORTED_VERSIONS       | varchar(50)          | NO   |     | NULL    |                | 
+------------------------------+----------------------+------+-----+---------+----------------+
<p>
 * @param iRowID
 * @param iParentID
 * @param aliTlvEncodeHistory
        
        
 * @return JSONObject
 * @throws JSONException */
private JSONObject recursiveTlvDefinitionBuilder(Integer iRowID, Integer iParentID,
        ArrayList<Integer> aliTlvEncodeHistory) throws JSONException {

    boolean localDebug = Boolean.FALSE;

    Statement parentCheckStatement = null, getRowDefinitionStatement = null;

    ResultSet resultSetParentCheck = null, resultSetGetRowDefinition = null;

    if (debug | localDebug)
        System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(START) -> "
                + "aliTlvEncodeHistory: " + aliTlvEncodeHistory);

    String sqlQuery;

    JSONObject tlvJsonObj = null;

    // This query will check for child rows that belong to a parent row
    String sParentCheckQuery = "SELECT " + "   ID ," + "   TYPE ," + "   TLV_NAME," + "   PARENT_ID " + "FROM "
            + this.sDictionaryTableName + " " + "WHERE " + "   PARENT_ID = '" + iRowID + "'";

    try {

        //Create statement
        parentCheckStatement = commSqlConnection.createStatement();

        //Get Result Set of Query
        resultSetParentCheck = parentCheckStatement.executeQuery(sParentCheckQuery);

    } catch (SQLException e) {
        e.printStackTrace();
    }

    /* ******************************************************************************************************
     * If resultSet return an empty, this means that the row does not have a child and is not a Major TLV
     * *****************************************************************************************************/

    try {

        if (/*(SqlConnection.getRowCount(resultSetParentCheck) == 0) && */ (iParentID != TOP_LEVEL_TLV)) {

            // This query will check for child rows that belong to a parent row
            sqlQuery = "SELECT * FROM " + this.sDictionaryTableName + " " + "   WHERE ID = '" + iRowID + "'";

            if (debug | localDebug)
                System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(SUB-TLV-BEFORE) -> "
                        + "ROW-ID: " + iRowID);

            //Create statement to get Rows from ROW ID's
            getRowDefinitionStatement = commSqlConnection.createStatement();

            //Get Result Set
            resultSetGetRowDefinition = getRowDefinitionStatement.executeQuery(sqlQuery);

            //Advance to next index in result set, this is needed
            resultSetGetRowDefinition.next();

            /*************************************************
             *             Assemble JSON OBJECT
             *************************************************/

            tlvJsonObj = new JSONObject();

            tlvJsonObj.put(Dictionary.TYPE, resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_TYPE));
            tlvJsonObj.put(Dictionary.TLV_NAME,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_TLV_NAME));
            tlvJsonObj.put(Dictionary.TLV_DESCRIPTION,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_TLV_DESCRIPTION));
            tlvJsonObj.put(Dictionary.LENGTH_MIN,
                    resultSetGetRowDefinition.getInt(Dictionary.DB_TBL_COL_LENGTH_MIN));
            tlvJsonObj.put(Dictionary.LENGTH_MAX,
                    resultSetGetRowDefinition.getInt(Dictionary.DB_TBL_COL_LENGTH_MAX));
            tlvJsonObj.put(Dictionary.SUPPORTED_VERSIONS,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_SUPPORTED_VERSIONS));
            tlvJsonObj.put(Dictionary.DATA_TYPE,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_DATA_TYPE));
            tlvJsonObj.put(Dictionary.ARE_SUBTYPES, false);
            tlvJsonObj.put(Dictionary.BYTE_LENGTH,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_BYTE_LENGTH));

            if (checkForChild(iRowID)) {

                if (debug | localDebug)
                    System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(SUB-TLV-BEFORE) -> "
                            + "ROW-ID: " + iRowID + " -> CHILD-FOUND");

                aliTlvEncodeHistory.add(resultSetGetRowDefinition.getInt("TYPE"));

            } else {

                if (debug | localDebug)
                    System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(SUB-TLV-BEFORE) -> "
                            + "ROW-ID: " + iRowID + " -> CHILD-NOT-FOUND");

                tlvJsonObj.put(Dictionary.PARENT_TYPE_LIST, aliTlvEncodeHistory);

                return tlvJsonObj;
            }

            if (debug | localDebug)
                System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(SUB-TLV-BEFORE) -> "
                        + "aliTlvEncodeHistory: " + aliTlvEncodeHistory);

            tlvJsonObj.put(Dictionary.PARENT_TYPE_LIST, aliTlvEncodeHistory);

            aliTlvEncodeHistory.remove(aliTlvEncodeHistory.size() - 1);

            if (debug | localDebug)
                System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(SUB-TLV-AFTER) -> "
                        + " aliTlvEncodeHistory: " + aliTlvEncodeHistory);

            if (debug | localDebug)
                System.out.println(
                        "DictionarySQLQueries.recursiveTlvDefinitionBuilder(SUB-TLV) " + tlvJsonObj.toString());

        } else if (iParentID == TOP_LEVEL_TLV) {

            // This query will check for child rows that belong to a parent row
            sqlQuery = "SELECT * FROM " + this.sDictionaryTableName + "   WHERE ID = '" + iRowID + "'";

            getRowDefinitionStatement = commSqlConnection.createStatement();

            resultSetGetRowDefinition = getRowDefinitionStatement.executeQuery(sqlQuery);

            /*************************************************
             *             Assemble JSON OBJECT
             *************************************************/

            tlvJsonObj = new JSONObject();

            if (!resultSetGetRowDefinition.next()) {
                return tlvJsonObj;
            }

            tlvJsonObj.put(Dictionary.TYPE, resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_TYPE));
            tlvJsonObj.put(Dictionary.TLV_NAME,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_TLV_NAME));
            tlvJsonObj.put(Dictionary.TLV_DESCRIPTION,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_TLV_DESCRIPTION));
            tlvJsonObj.put(Dictionary.LENGTH_MIN,
                    resultSetGetRowDefinition.getInt(Dictionary.DB_TBL_COL_LENGTH_MIN));
            tlvJsonObj.put(Dictionary.LENGTH_MAX,
                    resultSetGetRowDefinition.getInt(Dictionary.DB_TBL_COL_LENGTH_MAX));
            tlvJsonObj.put(Dictionary.SUPPORTED_VERSIONS,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_SUPPORTED_VERSIONS));
            tlvJsonObj.put(Dictionary.DATA_TYPE,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_DATA_TYPE));
            tlvJsonObj.put(Dictionary.ARE_SUBTYPES, false);
            tlvJsonObj.put(Dictionary.BYTE_LENGTH,
                    resultSetGetRowDefinition.getString(Dictionary.DB_TBL_COL_BYTE_LENGTH));

            aliTlvEncodeHistory.add(resultSetGetRowDefinition.getInt(Dictionary.DB_TBL_COL_TYPE));
            tlvJsonObj.put(Dictionary.PARENT_TYPE_LIST, aliTlvEncodeHistory);

            if (debug | localDebug)
                System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(TOP_LEVEL_TLV) "
                        + tlvJsonObj.toString());

        }

        if ((SqlConnection.getRowCount(sParentCheckQuery) > 0)) {

            if (debug | localDebug)
                System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(END) -> "
                        + "resultSetParentCheck Fetch Size: " + resultSetParentCheck.getFetchSize() + " -> " +
                        //"SqlConnection.getRowCount: " + SqlConnection.getRowCount(resultSetParentCheck) + " -> " +
                        "aliTlvEncodeHistory: " + aliTlvEncodeHistory);

            try {

                Integer iParentIdTemp = null;

                JSONArray tlvJsonArray = new JSONArray();

                while (resultSetParentCheck.next()) {

                    iParentIdTemp = resultSetParentCheck.getInt(Dictionary.DB_TBL_COL_PARENT_ID);

                    aliTlvEncodeHistory.add(resultSetParentCheck.getInt(Dictionary.DB_TBL_COL_TYPE));

                    if (debug | localDebug)
                        System.out.println("DictionarySQLQueries.recursiveTlvDefinitionBuilder(FINAL) -> "
                                + "resultSetParentCheck Fetch Size: " + resultSetParentCheck.getFetchSize()
                                + " -> " + "aliTlvEncodeHistory: " + aliTlvEncodeHistory);

                    //Keep processing each row using recursion until you get to to the bottom of the tree
                    tlvJsonArray.put(recursiveTlvDefinitionBuilder(resultSetParentCheck.getInt("ID"),
                            iParentIdTemp, aliTlvEncodeHistory));

                    aliTlvEncodeHistory.remove(aliTlvEncodeHistory.size() - 1);

                }

                //Get Parent Definition
                tlvJsonObj = getRowDefinitionViaRowId(iParentIdTemp);

                tlvJsonObj.put(Dictionary.SUBTYPE_ARRAY, tlvJsonArray);

            } catch (SQLException e) {

                e.printStackTrace();
            }
        }

    } catch (SQLException e) {

        e.printStackTrace();
    }

    return tlvJsonObj;
}

From source file:com.github.woonsan.jdbc.jcr.impl.JcrJdbcResultSetTest.java

@SuppressWarnings("deprecation")
@Test//w  w w . j  a v  a  2  s .  co m
public void testResultSetWhenClosed() throws Exception {
    Statement statement = getConnection().createStatement();
    ResultSet rs = statement.executeQuery(SQL_EMPS);

    rs.close();

    try {
        rs.isBeforeFirst();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.isAfterLast();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.isFirst();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.isLast();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.beforeFirst();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.afterLast();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.first();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.last();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.next();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getRow();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getType();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getConcurrency();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.rowUpdated();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.rowDeleted();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.rowInserted();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getStatement();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.wasNull();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getString(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getString("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBoolean(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBoolean("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getByte(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getByte("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getShort(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getShort("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getInt(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getInt("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getLong(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getLong("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getFloat(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getFloat("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDouble(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDouble("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBigDecimal(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBigDecimal("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBytes(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBytes("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate(1, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getDate("col1", null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime(1, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTime("col1", null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp(1, null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getTimestamp("col1", null);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getAsciiStream(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getAsciiStream("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getUnicodeStream(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getUnicodeStream("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBinaryStream(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getBinaryStream("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getCharacterStream(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getCharacterStream("col1");
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getMetaData();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.setFetchDirection(1);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getFetchDirection();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.setFetchSize(100);
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getFetchSize();
        fail();
    } catch (SQLException ignore) {
    }

    try {
        rs.getHoldability();
        fail();
    } catch (SQLException ignore) {
    }

    statement.close();
}