Example usage for java.sql ResultSet getBoolean

List of usage examples for java.sql ResultSet getBoolean

Introduction

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

Prototype

boolean getBoolean(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a boolean in the Java programming language.

Usage

From source file:com.l2jfree.gameserver.communitybbs.Manager.AuctionBBSManager.java

public FastList<LotList> getLots() {
    FastList<LotList> _lots = new FastList<LotList>();
    java.sql.Connection con = null;
    try {/*  ww w .  j av  a  2 s. co m*/
        con = L2DatabaseFactory.getInstance().getConnection(con);
        PreparedStatement statement = con.prepareStatement("SELECT * FROM auction_lots ORDER BY endDate");
        ResultSet result = statement.executeQuery();
        while (result.next()) {
            LotList lot = new LotList();
            lot.lotId = result.getInt("lotId");
            lot.ownerId = result.getInt("ownerId");
            lot.itemId = result.getInt("itemId");
            lot.objectId = result.getInt("objectId");
            lot.count = result.getLong("count");
            lot.enchantLevel = result.getInt("enchantLevel");
            lot.currency = result.getInt("currency");
            lot.startingBid = result.getInt("startingBid");
            lot.bidIncrement = result.getInt("bidIncrement");
            lot.buyNow = result.getInt("buyNow");
            lot.endDate = result.getLong("endDate");
            lot.endDateFormated = new SimpleDateFormat("MMM dd, HH:mm")
                    .format(new Date(result.getLong("endDate")));
            lot.isProcessed = result.getBoolean("processed");
            _lots.add(lot);
        }
        result.close();
        statement.close();
    } catch (Exception e) {
        _log.warn("", e);
    } finally {
        L2DatabaseFactory.close(con);
    }
    return _lots;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlISOCountryTable.java

public void deleteISOCountryByNameIdx(CFSecurityAuthorization Authorization, String argName) {
    final String S_ProcName = "deleteISOCountryByNameIdx";
    ResultSet resultSet = null;
    try {/*from  w  w w  .  j  av  a  2  s.  com*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName()
                + ".sp_delete_iso_cntry_by_nameidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByNameIdx == null) {
            stmtDeleteByNameIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByNameIdx.setString(argIdx++, argName);
        resultSet = stmtDeleteByNameIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:fetchBookDetails.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request//from w ww  .  j  ava  2 s . c o  m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    //processRequest(request, response);
    try {

        System.out.println("Inside try 1");
        Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
        //setting up connection
        String dbURL = "jdbc:derby://localhost:1527/autolib_db_test";
        Connection conn = DriverManager.getConnection(dbURL, "ishtiaq", "ishtiaq");
        Statement stmt = null;
        ResultSet rslt = null;

        if (conn == null) {
            System.out.println("Connection Failed");
        }

        stmt = conn.createStatement();

        String bookId = request.getParameter("book"); // pass this book value from displayBookDetails function
        String buyBook = request.getParameter("buy"); // pass this book value from displayBookDetails function

        String sqlQry = "";
        if (buyBook.equals("YES")) { //if a book is selected to be bought
            Integer bookQty = Integer.parseInt(request.getParameter("qty")); // pass this book value from displayBookDetails function          
            sqlQry = "update books_tbl set qty = qty - " + bookQty.toString() + " where id = " + bookId + ""; //reducing quantity by bookQty which increments by 1 on every click 
            stmt.execute(sqlQry); //executing the update query
        }
        System.out.println("SEARCH Book id   " + bookId);
        //query to return book details by giving the ID value
        sqlQry = "SELECT * FROM  books_tbl where id = " + bookId + "";
        rslt = stmt.executeQuery(sqlQry);
        //creating JSON object, array object and a jason variable
        JSONObject jObj = new JSONObject();
        JSONArray bookArr = new JSONArray();
        JSONObject bookData;

        try {
            System.out.println("Inside Try");

            //adding ID, name, author, price, topic, available and qty to bookData by using put
            while (rslt.next()) {
                bookData = new JSONObject();
                bookData.put("id", rslt.getInt("id"));
                bookData.put("name", rslt.getString("bookname"));
                bookData.put("author", rslt.getString("author"));
                bookData.put("price", rslt.getInt("price"));
                bookData.put("topic", rslt.getString("topic"));
                bookData.put("available", rslt.getBoolean("available"));
                bookData.put("qty", rslt.getInt("qty"));

                bookArr.put(bookData); //putting all bookdata in book array
            }

            jObj.put("Books", bookArr); //adding book array content to string named "Books"
        } catch (JSONException jse) {

        }
        response.setContentType("application/json");
        response.getWriter().write(jObj.toString());

        //closing connection
        if (!stmt.isClosed())
            stmt.close();

        if (!rslt.isClosed())
            rslt.close();
    } catch (Exception e) {
        //return null;
    }

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstPgSql.CFAstPgSqlSysClusterTable.java

public void deleteSysCluster(CFAstAuthorization Authorization, CFAstSysClusterBuff Buff) {
    final String S_ProcName = "deleteSysCluster";
    ResultSet resultSet = null;
    try {//from  w  ww  . j  ava2  s.co m
        Connection cnx = schema.getCnx();
        int SingletonId = Buff.getRequiredSingletonId();

        String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_sysclus( ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByPKey == null) {
            stmtDeleteByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByPKey.setInt(argIdx++, SingletonId);
        stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
        ;
        resultSet = stmtDeleteByPKey.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:com.sfs.whichdoctor.analysis.RevenueAnalysisDAOImpl.java

/**
 * Load debit.//from  ww  w  .j a  va  2  s . c o  m
 *
 * @param rs the rs
 *
 * @return the debit bean
 */
private DebitBean loadDebit(final ResultSet rs) {

    DebitBean debit = null;
    try {
        debit = new DebitBean();
        debit.setGUID(rs.getInt("InvoiceGUID"));
        debit.setNumber(rs.getString("InvoiceNo"));
        debit.setAbbreviation(rs.getString("InvoiceAbbreviation"));
        debit.setDescription(rs.getString("InvoiceDescription"));
        try {
            debit.setIssued(rs.getDate("InvoiceIssued"));
        } catch (SQLException e) {
            debit.setIssued(null);
        }
        if (rs.getInt("InvoicePersonGUID") > 0) {
            // Member exists so load details
            PersonBean person = new PersonBean();
            person.setGUID(rs.getInt("InvoicePersonGUID"));
            person.setPersonIdentifier(rs.getInt("InvoicePersonIdentifier"));
            person.setPreferredName(rs.getString("InvoicePreferredName"));
            person.setLastName(rs.getString("InvoiceLastName"));

            debit.setPerson(person);
        }
        if (rs.getInt("InvoiceOrganisationGUID") > 0) {
            // Organisation exists so load details
            OrganisationBean organisation = new OrganisationBean();
            organisation.setGUID(rs.getInt("InvoiceOrganisationGUID"));
            organisation.setName(rs.getString("InvoiceOrganisation"));
            debit.setOrganisation(organisation);
        }
        debit.setValue(rs.getDouble("InvoiceValue"));
        debit.setNetValue(rs.getDouble("InvoiceNetValue"));
        debit.setGSTRate(rs.getDouble("InvoiceGSTRate"));
        debit.setCancelled(rs.getBoolean("InvoiceCancelled"));

    } catch (SQLException sqe) {
        dataLogger.error("Error loading debit details: " + sqe.getMessage());
    }
    return debit;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlMimeTypeTable.java

public void deleteMimeType(CFSecurityAuthorization Authorization, CFInternetMimeTypeBuff Buff) {
    final String S_ProcName = "deleteMimeType";
    ResultSet resultSet = null;
    try {/*from   ww  w .  ja  va2s . c om*/
        Connection cnx = schema.getCnx();
        int MimeTypeId = Buff.getRequiredMimeTypeId();

        String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_mimetype( ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByPKey == null) {
            stmtDeleteByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByPKey.setInt(argIdx++, MimeTypeId);
        stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
        ;
        resultSet = stmtDeleteByPKey.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlServiceTypeTable.java

public void deleteServiceType(CFSecurityAuthorization Authorization, CFSecurityServiceTypeBuff Buff) {
    final String S_ProcName = "deleteServiceType";
    ResultSet resultSet = null;
    try {/*  w w w  .j a v  a2 s.c o  m*/
        Connection cnx = schema.getCnx();
        int ServiceTypeId = Buff.getRequiredServiceTypeId();

        String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_svctype( ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByPKey == null) {
            stmtDeleteByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByPKey.setInt(argIdx++, ServiceTypeId);
        stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
        ;
        resultSet = stmtDeleteByPKey.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlISOCountryTable.java

public void deleteISOCountryByNameIdx(CFAccAuthorization Authorization, String argName) {
    final String S_ProcName = "deleteISOCountryByNameIdx";
    ResultSet resultSet = null;
    try {/*from w  w  w . jav a 2  s  . co m*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_iso_cntry_by_nameidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByNameIdx == null) {
            stmtDeleteByNameIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByNameIdx.setString(argIdx++, argName);
        resultSet = stmtDeleteByNameIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlISOCountryTable.java

public void deleteISOCountryByNameIdx(CFAstAuthorization Authorization, String argName) {
    final String S_ProcName = "deleteISOCountryByNameIdx";
    ResultSet resultSet = null;
    try {/*from  w  ww  .  ja v  a2 s  .com*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_iso_cntry_by_nameidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByNameIdx == null) {
            stmtDeleteByNameIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByNameIdx.setString(argIdx++, argName);
        resultSet = stmtDeleteByNameIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlISOCountryTable.java

public void deleteISOCountryByNameIdx(CFAstAuthorization Authorization, String argName) {
    final String S_ProcName = "deleteISOCountryByNameIdx";
    ResultSet resultSet = null;
    try {/*from  w w w .jav  a2 s .c om*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName()
                + ".sp_delete_iso_cntry_by_nameidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByNameIdx == null) {
            stmtDeleteByNameIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByNameIdx.setString(argIdx++, argName);
        resultSet = stmtDeleteByNameIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}