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.mohit.program.DAO.impl.ProductDAOImpl.java

@Override
public Product getById(int id) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_product WHERE product_id=?";
    return jdbcTemplate.queryForObject(sql, new Object[] { id }, new RowMapper<Product>() {

        @Override/*from  w w w  .  j  a  v a2 s  .  c  o  m*/
        public Product mapRow(ResultSet rs, int i) throws SQLException {
            Product p = new Product();
            p.setId(rs.getInt("product_id"));
            p.setProductName(rs.getString("product_name"));
            p.setCostPrice(rs.getString("cost_price"));
            p.setSellingPrice(rs.getString("selling_price"));
            p.setQuantityAvailable(rs.getInt("quantity_available"));
            p.setAddedDate(rs.getDate("added_date"));
            p.setModifiedDate(rs.getDate("modified_date"));
            p.setStatus(rs.getBoolean("status"));
            return p;
        }
    });
}

From source file:net.algem.security.UserDaoImpl.java

@Override
public boolean isMemberOnYear(String login, String start, String end) {
    try {//from  www.j av  a  2  s . c o  m
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue("login", login);
        params.addValue("start", new java.sql.Date(GemConstants.DATE_FORMAT.parse(start).getTime()));
        params.addValue("end", new java.sql.Date(GemConstants.DATE_FORMAT.parse(end).getTime()));
        params.addValue("accounts", getMemberShipAccounts());
        //      String debug = login +","+start+","+end+","+getMemberShipAccounts();
        //      LOGGER.log(Level.INFO, debug);
        String query = "SELECT e.paye FROM echeancier2 e JOIN " + TABLE + " l ON (e.adherent = l.idper)"
                + " WHERE l.login = :login AND e.echeance BETWEEN :start AND :end AND e.compte IN(:accounts)";
        List<Boolean> result = namedJdbcTemplate.query(query, params, new RowMapper<Boolean>() {

            @Override
            public Boolean mapRow(ResultSet rs, int i) throws SQLException {
                return rs.getBoolean(1);
            }
        });
        for (Boolean b : result) {
            if (b) {
                return true;
            }
        }
        return false;
    } catch (ParseException | DataAccessException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
        return false;
    }

}

From source file:com.havoc.hotel.admin.dao.impl.CustomerDAOImpl.java

private Customer mapData(ResultSet rs) throws SQLException {
    Customer c = new Customer();
    c.setCustomerId(rs.getInt("customer_id"));
    c.setFirstName(rs.getString("first_name"));
    c.setLastName(rs.getString("last_name"));
    c.setEmail(rs.getString("email"));
    c.setContactNo(rs.getString("contact_no"));
    c.setUsername(rs.getString("username"));
    c.setPassword(rs.getString("password"));
    c.setAddedDate(rs.getDate("added_date"));
    c.setStatus(rs.getBoolean("status"));
    return c;/*from  ww w.ja  v a  2  s  . c o  m*/

}

From source file:com.mohit.program.DAO.impl.ProductDAOImpl.java

@Override
public List<Product> getAll(boolean availability) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_product WHERE 1=1 ";

    if (availability) {
        sql += " AND status=1 ";
    }//w ww.  j  a v a 2s. c  o m

    return jdbcTemplate.query(sql, new RowMapper<Product>() {

        @Override
        public Product mapRow(ResultSet rs, int i) throws SQLException {
            Product p = new Product();
            p.setId(rs.getInt("product_id"));
            p.setProductName(rs.getString("product_name"));
            p.setCostPrice(rs.getString("cost_price"));
            p.setSellingPrice(rs.getString("selling_price"));
            p.setQuantityAvailable(rs.getInt("quantity_available"));
            p.setAddedDate(rs.getDate("added_date"));
            p.setModifiedDate(rs.getDate("modified_date"));
            p.setStatus(rs.getBoolean("status"));
            return p;
        }
    });
}

From source file:fp4f.floorplans.DatabaseLayer.java

HouseItem getHouse(AddressItem selected) {
    HouseItem house = new HouseItem();
    try {//  w  ww.j a v a2  s . c  o  m
        PreparedStatement getter = con.prepareStatement("select * from houses where id = ?");
        getter.setInt(1, selected.HouseId);
        ResultSet rs = getter.executeQuery();

        house.Id = rs.getInt("id");

        house.Address = rs.getString("address");
        house.Phone = rs.getString("phone");

        house.Adults = rs.getInt("adults");
        house.Children = rs.getInt("children");
        house.Elderly = rs.getInt("elderly");
        house.Pets = rs.getInt("pets");
        house.Salvage = rs.getInt("salvage");
        house.Complexity = rs.getInt("complexity");

        house.Weapons = rs.getBoolean("weapons");

        house.Disabilities = rs.getString("disability");
        house.Combustables = rs.getString("combustables");
        house.Community = rs.getString("community");

        house.Floors = getFloors(house.Id);
    } catch (Exception ex) {
        System.out.println(ex);
    }
    return house;
}

From source file:org.esupportail.dining.web.controllers.EditAdminController.java

@RequestMapping
public ModelAndView renderEditAdminView(HttpServletRequest request) throws Exception {

    ModelMap model = new ModelMap();

    User user = this.authenticator.getUser();
    model.put("user", user);

    // try {//from  w w  w . j av  a  2  s .  com

    /* Get all area in the current feed */

    try {
        Set<String> areaList = new HashSet<String>();
        for (Restaurant r : this.feed.getFeed().getRestaurants()) {
            areaList.add(r.getArea());
        }
        model.put("areaList", areaList);
    } catch (Exception e) {
        // Here we go if the URL isn't set.
    }

    String[] areanames = null;
    List<FeedInformation> feedInfoList = new ArrayList<FeedInformation>();
    ResultSet results = null;
    try {
        results = this.dc.executeQuery("SELECT * FROM PATHFLUX");

        while (results.next()) {
            FeedInformation feedInfo = new FeedInformation(results.getInt("id"), results.getString("name"),
                    results.getString("areaname"), results.getString("urlflux"),
                    results.getBoolean("is_default"));
            feedInfoList.add(feedInfo);
        }

    } catch (SQLException e) {
        // URL isn't set yet...
    }

    try {
        for (FeedInformation fi : feedInfoList) {
            if (fi.isDefault()) {
                String areaname = fi.getAreaname();
                areanames = (areaname == null ? "" : areaname).split(",");
            }
        }
    } catch (Exception e) {
        // URL may be set be default area is not
    }
    model.put("feedList", feedInfoList);
    model.put("defaultArea", areanames);

    /* Action urlFeed set urlError if form URL was not well-formed */
    String hasError = request.getParameter("urlError");
    if (hasError != null) {
        model.put("urlError", hasError);
    }

    /* Action setDefaultArea set urlError if form URL was not well-formed */
    String areaSubmit = request.getParameter("areaSubmit");
    if (areaSubmit != null) {
        model.put("areaSubmit", areaSubmit);
    }

    /* From ForceFeedUpdate */
    if (request.getParameter("update") != null) {
        Boolean isUpdated = new Boolean(request.getParameter("update"));
        if (isUpdated.booleanValue()) {
            model.put("updateFeed", "The feed has been correctly updated");
        } else {
            model.put("updateFeed", "The feed is already up to date");
        }
    }
    return new ModelAndView("editadmin", model);
}

From source file:com.leapfrog.academyspring.dao.impl.EnquiryDAOImpl.java

@Override
public List<Enquiry> getAll() {

    return jdbcTemplate.query(SQLConstants.ENQUIRY_GETALL, new RowMapper<Enquiry>() {

        @Override/*  ww  w .  java2 s .c  o  m*/
        public Enquiry mapRow(ResultSet rs, int i) throws SQLException {
            Enquiry enq = new Enquiry();

            enq.setId(rs.getInt("id"));
            enq.setFirstName(rs.getString("first_name"));
            enq.setLastName(rs.getString("last_name"));
            enq.setEmail(rs.getString("email"));
            enq.setContactNo(rs.getString("contact_no"));
            enq.setCourseId(rs.getInt("course_id"));
            enq.setMessage(rs.getString("message"));
            enq.setEnquiryDate(rs.getDate("enquiry_date"));
            enq.setIsRead(rs.getBoolean("is_read"));
            enq.setParentId(rs.getInt("parent_id"));

            return enq;
        }
    });
}

From source file:com.leapfrog.inventorymanagementsystem.dao.impl.SalesDAOImpl.java

@Override
public Sales getById(int id) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_sales WHERE sales_id =?";
    return jdbcTemplate.queryForObject(sql, new Object[] { id }, new RowMapper<Sales>() {

        @Override//from  w  ww.jav a  2 s .c  om
        public Sales mapRow(ResultSet rs, int i) throws SQLException {
            Sales s = new Sales();
            s.setId(rs.getInt("sales_id"));
            s.setProductId(rs.getInt("product_id"));
            s.setSellingPrice(rs.getInt("selling_price"));
            s.setQuantity(rs.getInt("quantity"));
            s.setDiscount(rs.getBigDecimal("discount"));
            s.setTotalCost(rs.getInt("total_cost"));
            s.setSalesDate(rs.getDate("sales_date"));
            s.setPaymentMethod(rs.getString("payment_method"));
            s.setStatus(rs.getBoolean("status"));
            return s;
        }
    });
}

From source file:com.abcd.employeemaven.dao.impl.EmployeeDaoImpl.java

public Employee mapData(ResultSet rs) throws SQLException {
    Employee employee = new Employee();
    employee.setId(rs.getInt("employee_id"));
    employee.setFirstName(rs.getString("employee_first_name"));
    employee.setLastName(rs.getString("employee_last_name"));
    employee.setEmail(rs.getString("email"));
    employee.setAddress(rs.getString("address"));
    employee.setJoinedDate(rs.getDate("joined_date"));
    employee.setModifiedDate(rs.getDate("modified_date"));
    employee.setEffectiveDate(rs.getDate("effective_date"));
    employee.setStatus(rs.getBoolean("status"));
    return employee;
}

From source file:com.leapfrog.inventorymanagementsystem.dao.impl.SalesDAOImpl.java

@Override
public List<Sales> getALL(boolean status) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM tbl_sales WHERE 1=1";

    if (status) {
        sql += " AND status=1 ";
    }/*w ww.  j a  va  2s.co  m*/
    return jdbcTemplate.query(sql, new RowMapper<Sales>() {

        @Override
        public Sales mapRow(ResultSet rs, int i) throws SQLException {
            Sales s = new Sales();
            s.setId(rs.getInt("sales_id"));
            s.setProductId(rs.getInt("product_id"));
            s.setSellingPrice(rs.getInt("selling_price"));
            s.setQuantity(rs.getInt("quantity"));
            s.setDiscount(rs.getBigDecimal("discount"));
            s.setTotalCost(rs.getInt("total_cost"));
            s.setSalesDate(rs.getDate("sales_date"));
            s.setPaymentMethod(rs.getString("payment_method"));
            s.setStatus(rs.getBoolean("status"));

            return s;
        }
    });
}