List of usage examples for java.sql ResultSet getDouble
double getDouble(String columnLabel) throws SQLException;
ResultSet
object as a double
in the Java programming language. From source file:com.imagelake.control.PaymentPreferenceDAOImp.java
@Override public List<PaymentPreferences> getUserEarningHistory(int user_id) { List<PaymentPreferences> li = new ArrayList<PaymentPreferences>(); try {/* w ww. ja va 2s . c o m*/ String sql = "SELECT * FROM payment_preferences WHERE user_id=?"; PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql); ps.setInt(1, user_id); ResultSet rs = ps.executeQuery(); while (rs.next()) { PaymentPreferences pp = new PaymentPreferences(); pp.setAcc_type(rs.getInt(5)); pp.setAdm_id(rs.getInt(6)); pp.setAmount(rs.getDouble(7)); pp.setConf_date(rs.getString(4)); pp.setDate(rs.getString(3)); pp.setPpid(rs.getInt(1)); pp.setState(rs.getInt(8)); pp.setUser_id(rs.getInt(2)); System.out.println("getting..."); li.add(pp); } } catch (Exception e) { e.printStackTrace(); } return li; }
From source file:com.imagelake.control.PaymentPreferenceDAOImp.java
@Override public List<PaymentPreferences> getUserEarnedHistory(int uid, int state) { ArrayList<PaymentPreferences> li = new ArrayList<PaymentPreferences>(); try {/*from w w w. ja va 2 s . c o m*/ String sql = "SELECT * FROM payment_preferences WHERE user_id=? AND state=?"; PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql); ps.setInt(1, uid); ps.setInt(2, state); ResultSet rs = ps.executeQuery(); while (rs.next()) { PaymentPreferences pp = new PaymentPreferences(); pp.setAcc_type(rs.getInt(5)); pp.setAdm_id(rs.getInt(6)); pp.setAmount(rs.getDouble(7)); pp.setConf_date(rs.getString(4)); pp.setDate(rs.getString(3)); pp.setPpid(rs.getInt(1)); pp.setState(rs.getInt(8)); pp.setUser_id(rs.getInt(2)); System.out.println("getting..."); li.add(pp); } } catch (Exception e) { e.printStackTrace(); } return li; }
From source file:com.arcane.dao.Impl.PatternDaoImpl.java
@Override public HeadnShoulder getHeadnShoulder(String id) { //return requested head and shoulder pattern LOG.info("Returning requested head and shoulder pattern", id); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "SELECT * from headnshoulder where id=" + id; List<HeadnShoulder> headnshoulder = jdbcTemplate.query(sql, new RowMapper<HeadnShoulder>() { @Override//from w w w .j av a 2s . c om public HeadnShoulder mapRow(ResultSet rs, int rowNumber) throws SQLException { HeadnShoulder headnshoulder1 = new HeadnShoulder(); headnshoulder1.setBreakPointPrice(rs.getDouble("breakPointPrice")); headnshoulder1.setFirstMaxPrice(rs.getDouble("firstMaxPrice")); headnshoulder1.setSecondMaxPrice(rs.getDouble("secondMaxPrice")); headnshoulder1.setThirdMaxPrice(rs.getDouble("thirdMaxPrice")); headnshoulder1.setFirstMinPrice(rs.getDouble("firstMinPrice")); headnshoulder1.setSecondMinPrice(rs.getDouble("secondMinPrice")); headnshoulder1.setBreakPoint(rs.getString("breakPoint")); headnshoulder1.setFirstMax(rs.getString("firstMax")); headnshoulder1.setSecondMax(rs.getString("secondMax")); headnshoulder1.setThirdMax(rs.getString("thirdMax")); headnshoulder1.setFirstMin(rs.getString("firstMin")); headnshoulder1.setSecondMin(rs.getString("secondMin")); return headnshoulder1; } }); return headnshoulder.get(0); }
From source file:nl.tudelft.stocktrader.derby.DerbyOrderDAO.java
public Holding getHolding(int holdingId) throws DAOException { Holding holding = null;/*from w ww .j av a 2 s . com*/ PreparedStatement selectHoldingStat = null; try { selectHoldingStat = sqlConnection.prepareStatement(SQL_SELECT_HOLDING); selectHoldingStat.setInt(1, holdingId); ResultSet rs = selectHoldingStat.executeQuery(); if (rs.next()) { try { holding = new Holding(rs.getInt(1), rs.getDouble(2), rs.getBigDecimal(3), StockTraderUtility.convertToCalendar(rs.getDate(4)), rs.getString(5), rs.getInt(6)); return holding; } finally { try { rs.close(); } catch (Exception e) { logger.debug("", e); } } } } catch (SQLException e) { throw new DAOException("An Exception is thrown during selecting a holding entry", e); } finally { if (selectHoldingStat != null) { try { selectHoldingStat.close(); } catch (SQLException e) { logger.debug("", e); } } } return holding; }
From source file:dk.dma.msinm.legacy.msi.service.LegacyMsiImportService.java
private Double getDouble(ResultSet rs, String key) throws SQLException { Double val = rs.getDouble(key); return rs.wasNull() ? null : val; }
From source file:pl.edu.agh.samm.db.impl.mapper.MeasurementValueRowMapper.java
@Override public MeasurementValue mapRow(ResultSet rs, int arnrg1) throws SQLException { MeasurementValue mv = new MeasurementValue(); mv.setCapabilityUri(rs.getString("capability_uri")); mv.setId(rs.getLong("id")); mv.setInstanceUri(rs.getString("instance_uri")); mv.setTimestamp(new Date(rs.getTimestamp("timestamp").getTime())); // FIXME // why// www . j a v a2s.c o m // the // heck // is // has // to // be // like // that? // HSQL's // fault? mv.setValue(rs.getDouble("value")); return mv; }
From source file:com.carfinance.module.vehiclemanage.domain.VehicleMaintailRowMapper.java
public VehicleMaintail mapRow(ResultSet rs, int arg1) throws SQLException { VehicleMaintail vehicleMaintail = new VehicleMaintail(); vehicleMaintail.setId(rs.getLong("id")); vehicleMaintail.setCarframe_no(rs.getString("carframe_no")); vehicleMaintail.setEngine_no(rs.getString("engine_no")); vehicleMaintail.setLicense_plate(rs.getString("license_plate")); vehicleMaintail.setMaintain_date(rs.getDate("maintain_date")); vehicleMaintail.setMaintain_content(rs.getString("maintain_content")); vehicleMaintail.setMaintain_price(rs.getDouble("maintain_price")); vehicleMaintail.setCurrent_km(rs.getLong("current_km")); vehicleMaintail.setNext_maintain_km(rs.getLong("next_maintain_km")); vehicleMaintail.setUser_id(rs.getLong("user_id")); vehicleMaintail.setUser_name(rs.getString("user_name")); vehicleMaintail.setCreate_by(rs.getLong("create_by")); vehicleMaintail.setCreate_at(rs.getDate("create_at")); vehicleMaintail.setUpdate_by(rs.getLong("update_by")); vehicleMaintail.setUpdate_at(rs.getDate("update_at")); return vehicleMaintail; }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.LocalityGeoBoundsChecker2.java
/** * /* w ww. j a va2 s . c o m*/ */ public void processLocalities() { load(); String sql = "SELECT HighestChildNodeNumber, NodeNumber FROM geography WHERE GeographyCode = 'US' AND GeographyTreeDefID = GEOTREEDEFID"; sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); System.out.println(sql); Object[] rowObjs = BasicSQLUtils.queryForRow(sql); if (rowObjs == null) { UIRegistry.showError("Couldn't locate US geography."); return; } int highNode = (Integer) rowObjs[0]; int nodeNum = (Integer) rowObjs[1]; //highNode = 2737; //nodeNum = 1065; sql = String.format( "SELECT l.Latitude1, l.Longitude1, g.GeographyCode, RankID, ParentID, l.LocalityID, g.GeographyID FROM locality l " + "INNER JOIN geography g ON l.GeographyID = g.GeographyID " + "WHERE Latitude1 IS NOT NULL AND Longitude1 IS NOT NULL AND DisciplineID = DSPLNID AND NodeNumber >= %d AND NodeNumber <= %d " + "ORDER BY LocalityID", nodeNum, highNode); sql = QueryAdjusterForDomain.getInstance().adjustSQL(sql); System.out.println(sql); Statement stmt = null; try { stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(sql); while (rs.next()) { double lat = rs.getDouble(1); double lon = rs.getDouble(2); String stateCode = rs.getString(3); int rankId = rs.getInt(4); int parentId = rs.getInt(5); int locId = rs.getInt(6); int geoId = rs.getInt(7); while (rankId > 300) { sql = "SELECT RankID, GeographyCode, ParentID FROM geography WHERE GeographyID = " + parentId; rowObjs = BasicSQLUtils.queryForRow(sql); if (rowObjs != null) { geoId = parentId; rankId = (Integer) rowObjs[0]; stateCode = (String) rowObjs[1]; parentId = (Integer) rowObjs[2]; } else { break; } } if (stateCode != null && stateCode.length() == 4) { stateCode = stateCode.substring(2, 4); } LookupType status = lookup(lat, lon, stateCode); if (status != LookupType.eFound) { items.add(new StateLookupInfo(locId, geoId, stateInfoFoundIn, status)); } } rs.close(); //int i = 0; for (StateLookupInfo sli : items) { //System.out.println(String.format("%d - %d %d %s", i++, sli.localityId, sli.geographyId, sli.status.toString())); sql = "SELECT l.LocalityName, g.FullName, l.Latitude1, l.Longitude1 FROM locality l " + "INNER JOIN geography g ON l.GeographyID = g.GeographyID " + "WHERE LocalityID = " + sli.localityId; Object[] row = BasicSQLUtils.queryForRow(sql); System.out.println(String.format("%s, %s, %s, %s (%d, %d)", row[0].toString(), row[1].toString(), row[2].toString(), row[3].toString(), sli.localityId, sli.geographyId)); } } catch (Exception ex) { ex.printStackTrace(); } finally { try { stmt.close(); } catch (SQLException e) { } } }
From source file:com.arcane.dao.Impl.PatternDaoImpl.java
@Override public HeadnShoulderBottom getHeadnShoulderBottom(String id) { //return requested head and shoulder inverse pattern LOG.info("Returning requested head and shoulder inverse pattern", id); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "SELECT * from headnshoulderbottom where id=" + id; List<HeadnShoulderBottom> headnshoulderbottom = jdbcTemplate.query(sql, new RowMapper<HeadnShoulderBottom>() { @Override/* w w w.java 2 s .c o m*/ public HeadnShoulderBottom mapRow(ResultSet rs, int rowNumber) throws SQLException { HeadnShoulderBottom headnshoulderbottom1 = new HeadnShoulderBottom(); headnshoulderbottom1.setBreakPointPrice(rs.getDouble("breakPointPrice")); headnshoulderbottom1.setFirstMinPrice(rs.getDouble("firstMinPrice")); headnshoulderbottom1.setSecondMinPrice(rs.getDouble("secondMinPrice")); headnshoulderbottom1.setThirdMinPrice(rs.getDouble("thirdMinPrice")); headnshoulderbottom1.setFirstMaxPrice(rs.getDouble("firstMaxPrice")); headnshoulderbottom1.setSecondMaxPrice(rs.getDouble("secondMaxPrice")); headnshoulderbottom1.setBreakPoint(rs.getString("breakPoint")); headnshoulderbottom1.setFirstMin(rs.getString("firstMin")); headnshoulderbottom1.setSecondMin(rs.getString("secondMin")); headnshoulderbottom1.setThirdMin(rs.getString("thirdMin")); headnshoulderbottom1.setFirstMax(rs.getString("firstMax")); headnshoulderbottom1.setSecondMax(rs.getString("secondMax")); return headnshoulderbottom1; } }); return headnshoulderbottom.get(0); }
From source file:Graficas.java
public void opera() { String sql = "select nombre,turno,grado,materia,Resultado,Criterios,anio, avg(Resultado) promedio,sum(Resultado) suma\n" + "from nivellogro n,turno t, escuela e, materias m, grados g\n" + "where n.idMaterias = m.idMaterias and n.idEscuela = e.idEscuela and n.idTurno = t.idTurno and n.idGrados = g.idGrados\n" + "group by nombre ORDER BY rand() LIMIT 0,20;"; int cont = 0; try {/*from w w w. j a v a2s . c om*/ Connection con = conexionMySQL.GetConnection(); DefaultPieDataset data = new DefaultPieDataset(); // Statement st = con.createStatement(); PreparedStatement ps = con.prepareStatement(sql); ResultSet rs = ps.executeQuery(); while (rs.next()) { if (cont <= 10) { data.setValue(rs.getString("nombre"), rs.getDouble("promedio")); cont++; } } JFreeChart chart = ChartFactory.createPieChart("Aprovechamiento por escuelas", data, true, true, false); ChartFrame frame = new ChartFrame("JFreeChart", chart); frame.pack(); frame.setVisible(true); } catch (SQLException ex) { Logger.getLogger(Graficas.class.getName()).log(Level.SEVERE, null, ex); } }