List of usage examples for java.sql ResultSet getInt
int getInt(String columnLabel) throws SQLException;
ResultSet
object as an int
in the Java programming language. From source file:org.ff4j.store.rowmapper.FeatureRowMapper.java
/** {@inheritDoc} */ @Override/*from w w w. j a v a 2 s. c om*/ public Feature mapRow(ResultSet rs, int rowNum) throws SQLException { String featUid = rs.getString(COL_FEAT_UID); Feature f = new Feature(featUid, rs.getInt(COL_FEAT_ENABLE) > 0); f.setDescription(rs.getString(COL_FEAT_DESCRIPTION)); f.setGroup(rs.getString(COL_FEAT_GROUPNAME)); // Build Flipping Strategy From DataBase String strategy = rs.getString(COL_FEAT_STRATEGY); if (strategy != null && !"".equals(strategy)) { Map<String, String> initParams = MappingUtil.toMap(rs.getString(COL_FEAT_EXPRESSION)); FlippingStrategy flipStrategy = MappingUtil.instanceFlippingStrategy(featUid, strategy, initParams); f.setFlippingStrategy(flipStrategy); } return f; }
From source file:jp.yustam.batch.SampleBatchApplication.java
@Bean protected Tasklet tasklet() { return new Tasklet() { @Override//from w w w.jav a2s. c o m public RepeatStatus execute(StepContribution contribution, ChunkContext context) throws SQLException { System.out.println("Hello, world!"); System.out.println(config.getHost()); System.out.println(config.getPort()); String url = String.format("jdbc:postgresql://%s:%d/", config.getHost(), config.getPort()); Properties props = new Properties(); props.setProperty("user", "postgres"); // props.setProperty("password", "secret"); // props.setProperty("ssl", "true"); Connection conn = DriverManager.getConnection(url, props); Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery("SELECT * FROM company;"); while (rs.next()) { System.out.printf("%d %d %s\n", rs.getInt("id"), rs.getInt("code"), rs.getString("name")); } return RepeatStatus.FINISHED; } }; }
From source file:lydichris.smashbracket.persistence.TournamentMapper.java
@Override public Tournament mapRow(ResultSet rs, int rowNum) throws SQLException { Tournament tournament = new Tournament(rs.getString("uuid"), rs.getString("name"), rs.getTimestamp("start_time"), rs.getInt("size_limit"), rs.getString("location"), rs.getString("game"), rs.getString("host"), TournamentType.fromString(rs.getString("format")), rs.getString("description"), rs.getInt("is_bracket_visible") == 1); return tournament; }
From source file:com.leapfrog.inventorymanagementsystem.dao.impl.SupplierDAOImpl.java
@Override public List<Supplier> getALL() throws SQLException, ClassNotFoundException { String sql = "SELECT * FROM tbl_supplier"; return jdbcTemplate.query(sql, new RowMapper<Supplier>() { @Override/* www . jav a 2s .c o m*/ public Supplier mapRow(ResultSet rs, int i) throws SQLException { Supplier s = new Supplier(); s.setId(rs.getInt("supplier_id")); s.setSupplierName(rs.getString("supplier_name")); s.setAddress(rs.getString("address")); s.setContact(rs.getString("contact")); s.setEmail(rs.getString("email")); s.setAddedDate(rs.getDate("added_date")); s.setStatus(rs.getBoolean("status")); return s; } }); }
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. j a va 2 s. c o m 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.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 ww 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:com.havoc.hotel.admin.dao.impl.CommentsDAOImpl.java
private Comments mapData(ResultSet rs) throws SQLException { Comments comments = new Comments(); comments.setCommentsId(rs.getInt("comment_id")); Customer customer = new Customer(); customer.setCustomerId(rs.getInt("customer_id")); customer.setFirstName(rs.getString("first_name")); customer.setLastName(rs.getString("last_name")); customer.setUsername(rs.getString("username")); comments.setCustomer(customer);/*from w ww. j a v a 2s. c o m*/ comments.setMessage(rs.getString("message")); return comments; }
From source file:com.javacodegags.waterflooding.model.CaptionImplemented.java
@Override public List<Caption> list() { String sql = "SELECT * FROM caption"; List<Caption> listCaption = jdbcTemplate.query(sql, new RowMapper<Caption>() { @Override// ww w . ja va 2s.c om public Caption mapRow(ResultSet rs, int rowNum) throws SQLException { Caption caption = new Caption(); caption.setId(rs.getInt("id")); caption.setName(rs.getString("name")); return caption; } }); return listCaption; }
From source file:com.beezas.dao.TicketExtractor.java
public Ticket extractData(ResultSet resultSet) throws SQLException, DataAccessException { Ticket ticket = new Ticket(); // ticket.setTicketDate(resultSet.getString(1)); ticket.setId(resultSet.getInt("ticket_id")); ticket.setTicketType(resultSet.getString("ticket_type")); ticket.setTotalTickets(resultSet.getInt("total_tickets")); // ticket.setId(resultSet.getInt(1)); // ticket.setTicketType(resultSet.getString(2)); // ticket.setTotalTickets(resultSet.getInt(3)); System.out.println("type is :" + ticket.getTicketType()); System.out.println("total tickets are :" + ticket.getTotalTickets()); return ticket; }
From source file:ru.org.linux.spring.dao.DeleteInfoDao.java
public List<DeleteInfoStat> getRecentStats() { return jdbcTemplate.query( "select * from( select reason, count(*), sum(bonus) from del_info where deldate>CURRENT_TIMESTAMP-'1 day'::interval and bonus is not null group by reason) as s where sum!=0 order by reason", new RowMapper<DeleteInfoStat>() { @Override/*from w ww . j a v a2 s . c om*/ public DeleteInfoStat mapRow(ResultSet rs, int rowNum) throws SQLException { return new DeleteInfoStat(rs.getString("reason"), rs.getInt("count"), rs.getInt("sum")); } }); }