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:com.leapfrog.academyspring.dao.impl.CourseDAOImpl.java

private Course mapData(ResultSet rs) throws SQLException {
    Course cor = new Course();

    cor.setId(rs.getInt("id"));
    cor.setName(rs.getString("name"));
    cor.setDescription(rs.getString("description"));
    cor.setCourseDuration(rs.getInt("course_duration"));
    cor.setDurationType(rs.getString("duration_type"));
    cor.setFees(rs.getDouble("fees"));
    cor.setAddedDate(rs.getDate("added_date"));
    cor.setModifiedDate(rs.getDate("modified_date"));
    cor.setDeleteFlag(rs.getBoolean("delete_flag"));
    cor.setDeleteDate(rs.getDate("delete_date"));
    cor.setStatus(rs.getBoolean("status"));

    return cor;/*from w  ww .  j  a v  a2 s .  co m*/
}

From source file:com.bs.beans.SalesBean.java

public void memoFindview() {
    Connection con = DB.getConnection();
    try {/*from ww w  .j ava 2s. c o m*/
        PreparedStatement stm = con.prepareCall("select * from sales where MemoNo=?");
        stm.setInt(1, 4);
        ResultSet rs = stm.executeQuery();
        double gt = 0.0;
        while (rs.next()) {
            gt += rs.getDouble(6);
            setDate(rs.getString(7));
            slsList11.add(new SeslesReport(rs.getInt(8), rs.getInt(2), rs.getString(3), rs.getInt(5),
                    rs.getDouble(6), rs.getDate(7), rs.getInt(9)));
            System.out.println(rs.getDouble("Total"));
        }
        setGtota2(gt);
        con.close();
        rs.close();
    } catch (Exception e) {
        System.out.println(e.toString());
    }

}

From source file:com.bs.beans.SalesBean.java

public void reportFirstModel(HttpServletRequest request) {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpSession ses = req.getSession(false);
    int emp_id = (Integer.parseInt(ses.getAttribute("status").toString()));
    Connection con = DB.getConnection();
    try {/*w w  w. ja  v a2 s.  co m*/
        PreparedStatement stm = con.prepareCall(
                "SELECT distinct MemoNo,sum(Price*Quantity) as GT FROM sales where Sell_Date=DATE_FORMAT(NOW(),'%Y-%m-%d') and Emp_Id=? group by MemoNo");
        stm.setInt(1, emp_id);
        ResultSet rs = stm.executeQuery();
        while (rs.next()) {
            sre1.add(new SeslesReport(rs.getInt(1), rs.getDouble(2)));
        }
    } catch (Exception e) {
    }

}

From source file:com.imagelake.control.PaymentPreferenceDAOImp.java

public MinEarning getMin(int id) {
    MinEarning me = new MinEarning();
    try {/*from  ww w.  j  a  v  a 2s  .  c o m*/
        String sql = "SELECT * FROM min_earning WHERE id=?";
        PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql);
        ps.setInt(1, id);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            me.setId(rs.getInt(1));
            me.setMinearning(rs.getDouble(2));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return me;
}

From source file:com.abixen.platform.service.businessintelligence.multivisualisation.service.impl.AbstractDatabaseService.java

private DataValueWeb getValueAsDataSourceValueDoubleWeb(ResultSet row, String columnName) throws SQLException {
    Double value = row.getDouble(row.findColumn(columnName));
    return new DataValueDoubleWeb() {
        @Override//from   www  . j  a va2 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:edu.uga.cs.fluxbuster.analytics.ClusterSimilarityCalculator.java

/**
 * Executes the similarity query.// w  ww  . j  av  a 2s.  c o  m
 * 
 * @param query the query to execute.
 * @param adate the date of the first clustering run 
 * @param bdate the date of the second clustering run
 * @return the list of cluster similarities
 */
private List<ClusterSimilarity> executeSimilarityQuery(String query, Date adate, Date bdate) {
    List<ClusterSimilarity> retval = new ArrayList<ClusterSimilarity>();
    ResultSet rs = null;
    try {
        rs = db.executeQueryWithResult(query);
        while (rs.next()) {
            retval.add(new ClusterSimilarity(adate, bdate, rs.getInt(1), rs.getInt(2), rs.getDouble(3)));
        }
    } catch (SQLException e) {
        if (log.isErrorEnabled()) {
            log.error(e);
        }
    } finally {
        try {
            rs.close();
        } catch (SQLException e) {
            if (log.isErrorEnabled()) {
                log.error(e);
            }
        }
    }
    return retval;
}

From source file:HSqlPrimerDesign.java

@SuppressWarnings("Duplicates")
public static void locations(Connection connection) throws ClassNotFoundException, SQLException,
        InstantiationException, IllegalAccessException, IOException {
    long time = System.nanoTime();
    String base = new File("").getAbsolutePath();
    DpalLoad.main(new String[0]);
    Dpal_Inst = DpalLoad.INSTANCE_WIN64;
    System.out.println(Dpal_Inst);
    Connection db = connection;//from   w w  w .ja  v a 2s.  com
    db.setAutoCommit(false);
    Statement stat = db.createStatement();
    PrintWriter log = new PrintWriter(new File("javalog.log"));
    stat.execute("SET FILES LOG FALSE;");
    PreparedStatement st = db.prepareStatement("INSERT INTO Primerdb.MatchedPrimers("
            + "Primer, PrimerMatch, Comp,FragAVG,FragVAR,H2SD,L2SD, Cluster, Strain)"
            + "Values(?,?,?,?,?,?,?,?,?)");
    ResultSet call = stat.executeQuery("Select * From Primerdb.Phages;");
    List<String[]> phages = new ArrayList<>();
    while (call.next()) {
        String[] r = new String[3];
        r[0] = call.getString("Strain");
        r[1] = call.getString("Cluster");
        r[2] = call.getString("Name");
        phages.add(r);
        //            if(strain.equals("-myco")) {
        //                if (r[2].equals("xkcd")) {
        //                    strain = r[0];
        //                }
        //            }else if(strain.equals("-arthro")){
        //                if (r[2].equals("ArV1")) {
        //                    strain = r[0];
        //                }
        //            }
    }
    call.close();
    Set<String> strains = phages.stream().map(y -> y[0]).collect(Collectors.toSet());
    for (String x : strains) {
        Set<String> clust = phages.stream().filter(y -> y[0].equals(x)).map(y -> y[1])
                .collect(Collectors.toSet());
        String[] clusters = clust.toArray(new String[clust.size()]);
        //        String z ="A1";
        for (String z : clusters) {
            System.out.println("Starting:" + z);
            List<Primer> primers = new ArrayList<>();
            Set<Matches> matched = new HashSet<>();
            Set<String> clustphage = phages.stream().filter(a -> a[0].equals(x) && a[1].equals(z))
                    .map(a -> a[2]).collect(Collectors.toSet());
            String[] clustphages = clustphage.toArray(new String[clustphage.size()]);
            if (clustphages.length > 1) {
                try {
                    ResultSet resultSet = stat
                            .executeQuery("Select * from primerdb.primers" + " where Strain ='" + x
                                    + "' and Cluster ='" + z + "' and UniqueP = true" + " and Hairpin = false");
                    while (resultSet.next()) {
                        Primer primer = new Primer(resultSet.getString("Sequence"));
                        primer.setTm(resultSet.getDouble("Tm"));
                        primers.add(primer);
                    }
                    resultSet.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                    System.out.println("Error occurred at " + x + " " + z);
                }
                System.out.println(primers.size());
                Set<Primer> primerlist2 = primers.stream().collect(Collectors.toSet());
                Primer[] primers2 = primerlist2.toArray(new Primer[primerlist2.size()]);
                Map<String, Map<CharSequence, List<Integer>>> locations = Collections
                        .synchronizedMap(new HashMap<>());
                clustphage.stream().forEach(phage -> {
                    String[] seqs = Fasta.parse(base + "/Fastas/" + phage + ".fasta");
                    String sequence = seqs[0] + seqs[1];
                    Map<String, List<Integer>> seqInd = new HashMap<>();
                    for (int i = 0; i <= sequence.length() - 10; i++) {
                        String sub = sequence.substring(i, i + 10);
                        if (seqInd.containsKey(sub)) {
                            seqInd.get(sub).add(i);
                        } else {
                            List<Integer> list = new ArrayList<>();
                            list.add(i);
                            seqInd.put(sub, list);
                        }
                    }
                    Map<CharSequence, List<Integer>> alllocs = new HashMap<>();
                    for (Primer primer : primers2) {
                        List<Integer> locs = new ArrayList<>();
                        String sequence1 = primer.getSequence();
                        String frag = sequence1.substring(0, 10);
                        List<Integer> integers = seqInd.get(frag);
                        if (integers != null) {
                            for (Integer i : integers) {
                                if ((sequence1.length() + i) < sequence.length()
                                        && sequence.substring(i, sequence1.length() + i).equals(sequence1)) {
                                    locs.add(i);
                                }
                            }
                        }
                        alllocs.put(sequence1, locs);
                    }
                    locations.put(phage, alllocs);
                });
                System.out.println("locations found");
                System.out.println((System.nanoTime() - time) / Math.pow(10, 9) / 60.0);
                final int[] k = new int[] { 0 };
                primerlist2.parallelStream().forEach(a -> {
                    int matches = 0;
                    int i = 0;
                    while (primers2[i] != a) {
                        i++;
                    }
                    for (int j = i + 1; j < primers2.length; j++) {
                        double[] frags = new double[clustphages.length];
                        int phageCounter = 0;
                        Primer b = primers2[j];
                        boolean match = true;
                        if (matches > 0) {
                            break;
                        }
                        if (Math.abs(a.getTm() - b.getTm()) > 5.0 || a.getSequence().equals(b.getSequence())) {
                            continue;
                        }
                        for (String phage : clustphages) {
                            List<Integer> loc1 = locations.get(phage).get(a.getSequence());
                            List<Integer> loc2 = locations.get(phage).get(b.getSequence());
                            //                            if(loc1.size()==0){
                            //                                System.out.println(phage+" "+a.getSequence());
                            //                            }
                            if (loc1.size() == 0 || loc2.size() == 0) {
                                //                                if (loc1.size()!=1||loc2.size()!=1){
                                match = false;
                                break;
                            }
                            boolean found = false;
                            int fragCount = 0;
                            int l1 = loc1.get(0);
                            int l2 = loc2.get(0);
                            int count1 = 0;
                            int count2 = 0;
                            int frag = Math.abs(l1 - l2);
                            while (!found) {
                                if (frag >= 500 && frag <= 2000) {
                                    fragCount++;
                                    if (++count1 < loc1.size())
                                        l1 = loc1.get(count1);
                                    else if (++count2 < loc2.size())
                                        l2 = loc2.get(count2);
                                } else if (l1 < l2 && frag < 500) {
                                    count2++;
                                } else if (l1 > l2 && frag < 500) {
                                    count1++;
                                } else if (l1 > l2 && frag > 2000) {
                                    count2++;
                                } else if (l1 < l2 && frag > 2000) {
                                    count1++;
                                } else {
                                    break;
                                }
                                if (count1 < loc1.size() && count2 < loc2.size()) {
                                    l1 = loc1.get(count1);
                                    l2 = loc2.get(count2);
                                    frag = Math.abs(l1 - l2);
                                } else {
                                    if (fragCount == 1) {
                                        found = true;
                                        frags[phageCounter++] = frag + 0.0;
                                    } else {
                                        break;
                                    }
                                }
                            }
                            if (!found) {
                                match = false;
                                break;
                            }

                        }
                        if (match) {
                            matches++;
                            matched.add(new Matches(a, b, frags));
                        }
                    }
                    //                    k[0]++;
                    //                    System.out.println(k[0]);
                });
                System.out.println((System.nanoTime() - time) / Math.pow(10, 9) / 60.0);
                System.out.println("Primers matched");
                int c = 0;
                int i = 0;
                try {
                    for (Matches primerkey : matched) {
                        c++;
                        String primer1 = primerkey.one.getSequence();
                        String primer2 = primerkey.two.getSequence();
                        st.setString(1, primer1);
                        st.setString(2, primer2);
                        st.setDouble(3, complementarity(primer1, primer2, Dpal_Inst));
                        st.setDouble(4, primerkey.stats.getMean());
                        st.setDouble(5, primerkey.stats.getVariance());
                        st.setDouble(6, primerkey.stats.getMean() + 2 * primerkey.stats.getStandardDeviation());
                        st.setDouble(7, primerkey.stats.getMean() - 2 * primerkey.stats.getStandardDeviation());
                        st.setString(8, z);
                        st.setString(9, x);
                        st.addBatch();
                        i++;
                        if (i == 1000) {
                            i = 0;
                            st.executeBatch();
                            db.commit();
                        }
                    }

                    if (i > 0) {
                        st.executeBatch();
                        db.commit();
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                    System.out.println("Error occurred at " + x + " " + z);
                }
                System.out.println(c);
            }
            log.println(z);
            log.flush();
            System.gc();
        }
    }
    stat.execute("SET FILES LOG TRUE;");
    st.close();
    stat.close();
    System.out.println("Matches Submitted");
}

From source file:nl.tudelft.stocktrader.derby.DerbyMarketSummaryDAO.java

public Quote getQuoteForUpdate(String symbol) throws DAOException {
    if (logger.isDebugEnabled()) {
        logger.debug("MarketSummaryDAO.getQouteForUpdate(String)\nSymbol :" + symbol);
    }//from  ww  w  .j  a va  2 s .  co  m
    PreparedStatement qouteForUpdateStat = null;
    try {
        qouteForUpdateStat = sqlConnection.prepareStatement(SQL_SELECT_QUOTE);
        Quote quote = null;

        qouteForUpdateStat.setString(1, symbol);
        ResultSet rs = qouteForUpdateStat.executeQuery();

        if (rs.next()) {
            quote = new Quote(rs.getString(1), rs.getString(2), rs.getDouble(3), rs.getBigDecimal(4),
                    rs.getBigDecimal(5), rs.getBigDecimal(6), rs.getBigDecimal(7), rs.getDouble(8));

            try {
                rs.close();
            } catch (SQLException e) {
                logger.debug("", e);
            }
            return quote;
        } else {
            throw new DAOException("No quote entry found");
        }
    } catch (SQLException e) {
        throw new DAOException("", e);
    } finally {
        try {
            if (qouteForUpdateStat != null) {
                qouteForUpdateStat.close();
            }
        } catch (SQLException e) {
            logger.debug("", e);
        }
    }
}

From source file:ems.emsystem.dao.JDBCEmployeeDAOImpl.java

private Employee getEmployeeFromResultSet(ResultSet rs) throws SQLException {
    Employee em = new Employee();
    em.setId(rs.getLong("ID"));
    em.setActive(rs.getBoolean("ACTIVE"));
    em.setBirthdate(rs.getDate("BIRTHDATE"));
    em.setFirstname(rs.getString("FIRSTNAME"));
    em.setLastname(rs.getString("LASTNAME"));
    em.setSalary(rs.getDouble("SALARY"));
    long dep_id = rs.getLong("DEPARTMENT");
    Department dep = departmentDAO.getDepartment(dep_id);
    em.setDepartment(dep);//  w w  w .j  a va2s .  c  o m
    return em;
}

From source file:com.carfinance.module.vehiclemanage.domain.VehicleInsuranceRowMapper.java

public VehicleInsurance mapRow(ResultSet rs, int arg1) throws SQLException {
    VehicleInsurance vehicleInfo = new VehicleInsurance();

    vehicleInfo.setId(rs.getLong("id"));
    vehicleInfo.setCarframe_no(rs.getString("carframe_no"));
    vehicleInfo.setEngine_no(rs.getString("engine_no"));
    vehicleInfo.setLicense_plate(rs.getString("license_plate"));
    vehicleInfo.setInsurance_company(rs.getString("insurance_company"));
    vehicleInfo.setStrong_insurance(rs.getDouble("strong_insurance"));
    vehicleInfo.setStrong_insurance_expire_at(rs.getDate("strong_insurance_expire_at"));
    vehicleInfo.setVehicle_vessel_tax(rs.getDouble("vehicle_vessel_tax"));
    vehicleInfo.setBusiness_insurance(rs.getDouble("business_insurance"));
    vehicleInfo.setBusiness_insurance_expire_at(rs.getDate("business_insurance_expire_at"));
    vehicleInfo.setRemark(rs.getString("remark"));
    vehicleInfo.setCreate_by(rs.getLong("create_by"));
    vehicleInfo.setCreate_at(rs.getDate("create_at"));
    vehicleInfo.setCreate_by(rs.getLong("update_by"));
    vehicleInfo.setCreate_at(rs.getDate("update_at"));

    return vehicleInfo;
}