Example usage for java.sql ResultSet getDouble

List of usage examples for java.sql ResultSet getDouble

Introduction

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

Prototype

double getDouble(String columnLabel) throws SQLException;

Source Link

Document

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

Usage

From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java

public Double getKeyValuesScore(String key, String val) {
    double score = 0.0;
    String sql = "SELECT sig FROM " + tableOrder1 + " WHERE word = ? and feature = ?";
    PreparedStatement ps;/* w w  w  .  j  ava 2 s.co  m*/
    try {
        ps = getDatabaseConnection().getConnection().prepareStatement(sql);
        ps.setString(1, key);
        ps.setString(2, val);
        ResultSet set = ps.executeQuery();
        if (set.next()) {
            score = set.getDouble("sig");
        }
        ps.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return score;
}

From source file:com.leapfrog.sms.dao.impl.CourseDAOImpl.java

private Course mapData(ResultSet rs) throws SQLException {
    Course course = new Course();
    course.setId(rs.getInt("id"));
    course.setName(rs.getString("name"));
    course.setDescription(rs.getString("description"));
    course.setPrice(rs.getDouble("price"));
    course.setStatus(rs.getBoolean("status"));
    return course;
}

From source file:id.aas.apps.mvc.view.chartFrame.java

void bar() {
    try {/*from ww w  . java2  s.co m*/
        double Lunas = 0;
        double Casbon = 0;

        String queryLunas = "SELECT SUM(total_tagihan) from transaksi where keterangan='Lunas'";
        String queryCasbon = "SELECT SUM(total_tagihan) from transaksi where keterangan='Cash Bon'";
        ConnectionDB.InstanceDB.openConnection();
        ResultSet rs = ConnectionDB.InstanceDB.RunSelectQuery(queryLunas);
        while (rs.next()) {
            Lunas = rs.getDouble(1);
        }
        System.out.println(Lunas);

        ResultSet rs1 = ConnectionDB.InstanceDB.RunSelectQuery(queryCasbon);
        while (rs1.next()) {
            Casbon = rs1.getDouble(1);
        }
        System.out.println(Casbon);
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.setValue(Lunas, "Lunas", "Catatan Uang Pendapatan");
        dataset.setValue(Casbon, "Cash Bon", "Catatan Uang Pendapatan");

        JFreeChart chart = ChartFactory.createBarChart3D("Catatan Uang Pendapatan dan Piutang Laundry",
                "Keterangan Pembayaran", "Jumlah Uang", dataset);
        chart.setBorderVisible(false);
        chart.setBackgroundPaint(null);

        //            BufferedImage image = chart.createBufferedImage(500, 300);
        //            jLabel1.setIcon(new ImageIcon(image));
        ChartPanel cPanel = new ChartPanel(chart);
        setBounds(100, 100, 685, 429);
        jPanel2 = new JPanel();
        jPanel2.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(jPanel2);
        jPanel2.setLayout(null);
        jPanel2.add(cPanel);
        jTabbedPane1.add(jPanel2);
        setVisible(true);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java

private List<Order2> fillExpansions(PreparedStatement ps) throws SQLException {
    List<Order2> list = new ArrayList<Order2>();
    ResultSet set = ps.executeQuery();
    while (set.next()) {
        list.add(new Order2(set.getString("word2"), set.getDouble("count")));
    }//ww w.j  a v a2s. com
    ps.close();
    return list;
}

From source file:com.bt.aloha.batchtest.PerformanceMeasurmentDao.java

@SuppressWarnings("unchecked")
public List<Metrics> findMetricsByRunId(long runId) {

    if (!exists) {
        log.warn("record skipped as schema does not exists");
        return null;
    }/*  w w w .  j a  v  a2s.  co  m*/
    List<Metrics> metrics = null;
    try {
        metrics = jdbcTemplate.query("select unitPerSecond, averageDuration,"
                + "numberOfRuns, numberOfSuccessfulRuns, variance, standardDeviation, success, description, threadInfo, testType "
                + "from Performance where runId=?", new Object[] { runId }, new RowMapper() {
                    public Object mapRow(ResultSet rs, int row) throws SQLException {
                        double ups = rs.getDouble("unitPerSecond");
                        double ad = rs.getDouble("averageDuration");
                        long nor = rs.getLong("numberOfRuns");
                        long nosr = rs.getLong("numberOfSuccessfulRuns");
                        double v = rs.getDouble("variance");
                        double sd = rs.getDouble("standardDeviation");
                        boolean s = rs.getBoolean("success");
                        String d = rs.getString("description");
                        String ti = rs.getString("threadInfo");
                        String tt = rs.getString("testType");
                        Metrics m = new Metrics(tt, ups, ad, nor, nosr, v, sd, s, d);
                        m.setThreadInfo(ti);
                        return m;
                    }
                });
    } catch (DataAccessException e) {
        log.error("Unable to access data for runId: " + runId, e);
    }
    return metrics;
}

From source file:ar.com.zauber.commons.gis.street.impl.UsigRouter.java

/** determina si para un eje del grafo el punto est ms cerca
 * de ser target o source *///  w w  w  .j a  v  a  2s  . c  o  m
private int sourceOrTarget(final Point geom, final RoutingEdge edge) {
    String s = "select distance(line_interpolate_point(" + "LineMerge(the_geom),0), GeomFromText(?, 4326)), "
            + "distance(line_interpolate_point(LineMerge(the_geom),1), "
            + "GeomFromText(?, 4326)),source, target from streets where gid=?";
    final List<Integer> ret = new ArrayList<Integer>();
    jdbcTemplate.query(s, new Object[] { geom.toString(), geom.toString(), edge.gid },
            new ResultSetExtractor() {
                public Object extractData(final ResultSet rs) throws SQLException, DataAccessException {

                    while (rs.next()) {
                        int r;
                        if (rs.getDouble(1) > rs.getDouble(2)) {
                            r = rs.getInt(4);
                        } else {
                            r = rs.getInt(3);
                        }
                        ret.add(r);
                    }

                    return null;
                }

            });

    if (ret.size() == 0) {
        throw new NoSuchEntityException(geom);
    }
    if (ret.size() > 1) {
        throw new IllegalStateException("bla");
    }

    return ret.get(0);
}

From source file:com.abixen.platform.module.chart.service.impl.AbstractDatabaseService.java

private DataSourceValueWeb getValueAsDataSourceValueDoubleWeb(ResultSet row, String columnName)
        throws SQLException {
    Double value = row.getDouble(row.findColumn(columnName));
    return new DataSourceValueDoubleWeb() {
        @Override// w  w w.ja v a  2 s. c  o  m
        public Double getValue() {
            return value;
        }

        @Override
        public void setValue(Double value) {
            throw new NotImplementedException("Setter not implemented yet");
        }
    };
}

From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java

private List<Order1> fillKeyValuesScores(String sql, String key) {
    PreparedStatement ps;/*from w  ww  .  ja v a  2  s . c  o m*/
    List<Order1> list = new ArrayList<Order1>();
    try {
        ps = getDatabaseConnection().getConnection().prepareStatement(sql);

        ps.setString(1, key);
        ResultSet set = ps.executeQuery();
        while (set.next()) {
            list.add(new Order1(set.getString("feature"), set.getDouble("sig")));
        }
        ps.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return list;
}

From source file:com.talkdesk.geo.GeoCodeResolver.java

/**
 * Get location information/*from   w  ww.  j a  va  2s . co m*/
 * @param townName
 * @param countryCode
 * @return
 * @throws GeoResolverException
 */
public GeoInfo getLocationInfo(String townName, String countryCode) throws GeoResolverException {
    String query;
    PreparedStatement statement;
    GeoInfo geoInfo = null;
    try {
        if (townName != null && countryCode != null) {
            query = "SELECT * FROM GEOCODES WHERE CITY_NAME = ? AND COUNTRY_CODE = ?";
            statement = connection.prepareStatement(query);
            statement.setString(1, townName);
            statement.setString(2, countryCode);
            ResultSet resultSet = statement.executeQuery();

            if (resultSet.next()) {
                double latitude = resultSet.getDouble("LATITUDE");
                double longitude = resultSet.getDouble("LONGITUDE");
                String country_code = resultSet.getString("COUNTRY_CODE");
                geoInfo = new GeoInfo(townName, latitude, longitude, country_code);
            }
            //countryCode cannot be null so when we cannot get info based on town we fall back to town
        }
        if (countryCode != null && geoInfo == null) {
            query = "SELECT * FROM COUNTRYCODES WHERE COUNTRY_CODE = ?";
            statement = connection.prepareStatement(query);
            statement.setString(1, countryCode);
            ResultSet resultSet = statement.executeQuery();

            if (resultSet.next()) {
                double latitude = resultSet.getDouble("LATITUDE");
                double longitude = resultSet.getDouble("LONGITUDE");
                String country_code = resultSet.getString("COUNTRY_CODE");
                geoInfo = new GeoInfo(townName, latitude, longitude, country_code);
                //
            }
        }

    } catch (SQLException e) {
        throw new GeoResolverException("Error while executing query to match phone number's details", e);
    }
    return geoInfo;
}

From source file:com.javacodegags.waterflooding.model.CriteriaImplemented.java

@Override
public List<Criteria> getListById(int id) {
    String sql = "SELECT criteria.id, criteria_value, formula " + "FROM intermediate " + "INNER JOIN caption "
            + "ON intermediate.foreign_to_caption=caption.Id " + "INNER JOIN criteria "
            + "ON intermediate.foreign_to_criteria=criteria.Id " + "Where intermediate.foreign_to_caption=" + id
            + ";";
    List<Criteria> listCriteria = jdbcTemplate.query(sql, new RowMapper<Criteria>() {
        @Override//from w  ww.j ava 2 s  .co m
        public Criteria mapRow(ResultSet rs, int rowNum) throws SQLException {
            Criteria criteria = new Criteria();
            criteria.setId(rs.getInt("id"));
            criteria.setValue(rs.getDouble("criteria_value"));
            criteria.setFormula(rs.getString("formula"));
            return criteria;
        }
    });
    return listCriteria;
}