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:de.static_interface.reallifeplugin.module.corporation.database.table.CorpsTable.java

@Override
public CorpRow[] deserialize(ResultSet rs) throws SQLException {
    int rowcount = 0;
    if (rs.last()) {
        rowcount = rs.getRow();/*ww  w  . j  a v  a2s  .  c  o  m*/
        rs.beforeFirst();
    }

    CorpRow[] rows = new CorpRow[rowcount];
    int i = 0;

    while (rs.next()) {
        CorpRow row = new CorpRow();
        if (hasColumn(rs, "id")) {
            row.id = rs.getInt("id");
        }
        if (hasColumn(rs, "balance")) {
            row.balance = rs.getDouble("balance");
        }
        if (hasColumn(rs, "base_id")) {
            row.baseId = rs.getString("base_id");
        }
        if (hasColumn(rs, "base_world")) {
            row.baseWorld = rs.getString("base_world");
        }
        if (hasColumn(rs, "ceo_uuid")) {
            row.ceoUniqueId = UUID.fromString(rs.getString("ceo_uuid"));
        }
        if (hasColumn(rs, "corp_name")) {
            row.corpName = rs.getString("corp_name");
        }
        if (hasColumn(rs, "isdeleted")) {
            row.isDeleted = rs.getBoolean("isdeleted");
        }
        if (hasColumn(rs, "tag")) {
            row.tag = rs.getString("tag");
        }
        if (hasColumn(rs, "time")) {
            row.time = rs.getLong("time");
        }
        rows[i] = row;
        i++;
    }
    return rows;
}

From source file:at.plechinger.minigeocode.mapper.ReverseGeocodeRowMapper.java

@Override
public ReverseGeocodeResult mapRow(ResultSet row, int index) throws SQLException {
    ReverseGeocodeResult result = new ReverseGeocodeResult();
    GeocodeResult original = geocodeRowMapper.mapRow(row, index);

    result.setStreet(original.getStreet());
    result.setHousenumber(original.getHousenumber());
    result.setPostcode(original.getPostcode());
    result.setCity(original.getCity());//from  ww  w.  java 2 s .co m
    result.setCountry(original.getCountry());

    result.setLongitude(original.getLongitude());
    result.setLatitude(original.getLatitude());

    result.setDistance(row.getDouble("distance"));

    return result;
}

From source file:br.com.great.dao.JogosDAO.java

/**
 * Retorna um jogo com todos os seus dados
 * @return JSONArray lista de todos os jogos
 *//*from  ww  w . j a v  a2s.  c o m*/
public Jogo getJogo(int jogo_id) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Connection conexao = criarConexao();
    try {
        String sql = "select * from jogos where id=" + jogo_id;
        pstmt = conexao.prepareStatement(sql);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            Jogo jogo = new Jogo();
            jogo.setId(rs.getInt("id"));
            jogo.setNome(rs.getString("nome"));
            jogo.setIcone(rs.getString("icone"));
            jogo.setPosicao(new Posicao(rs.getDouble("latitude"), rs.getDouble("longitude")));
            jogo.setNomeficticio(rs.getString("nomeficticio"));
            jogo.setStatus(rs.getInt("status"));
            return jogo;
        }
    } catch (SQLException e) {
        System.out.println("Erro no getJogo: " + e.getMessage());
    } finally {
        fecharConexao(conexao, pstmt, rs);
    }
    return null;
}

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

public VehiclePeccancy mapRow(ResultSet rs, int arg1) throws SQLException {
    VehiclePeccancy vehiclePeccancy = new VehiclePeccancy();

    vehiclePeccancy.setId(rs.getLong("id"));
    vehiclePeccancy.setCarframe_no(rs.getString("carframe_no"));
    vehiclePeccancy.setEngine_no(rs.getString("engine_no"));
    vehiclePeccancy.setLicense_plate(rs.getString("license_plate"));
    vehiclePeccancy.setPeccancy_at(rs.getDate("peccancy_at"));
    vehiclePeccancy.setPeccancy_place(rs.getString("peccancy_place"));
    vehiclePeccancy.setPeccancy_reason(rs.getString("peccancy_reason"));
    vehiclePeccancy.setPeccancy_price(rs.getDouble("peccancy_price"));
    vehiclePeccancy.setScore(rs.getInt("score"));
    vehiclePeccancy.setStatus(rs.getInt("status"));
    vehiclePeccancy.setArbitration(rs.getString("arbitration"));
    vehiclePeccancy.setEmployee_id(rs.getString("employee_id"));
    vehiclePeccancy.setEmployee_name(rs.getString("employee_name"));
    vehiclePeccancy.setCustomer_id(rs.getString("customer_id"));
    vehiclePeccancy.setCustomer_name(rs.getString("customer_name"));
    vehiclePeccancy.setCreate_at(rs.getDate("create_at"));
    vehiclePeccancy.setCreate_by(rs.getLong("create_by"));
    vehiclePeccancy.setCreate_at(rs.getDate("update_at"));
    vehiclePeccancy.setCreate_by(rs.getLong("update_by"));

    return vehiclePeccancy;
}

From source file:com.enigmastation.ml.perceptron.impl.HSQLDBPerceptronRepository.java

@Override
public double getStrength(int from, int to, Layer layer) {
    double strength = layer.getStrength();
    PreparedStatement ps;//from   ww  w  . j a v  a2s. c om
    ResultSet rs;

    try (Connection conn = getConnection()) {
        ps = conn.prepareStatement(
                "select strength from " + layer.getStoreName() + " where fromid=? and toid=?");
        ps.setInt(1, from);
        ps.setInt(2, to);
        rs = ps.executeQuery();
        if (rs.next()) {
            strength = rs.getDouble(1);
        }
        rs.close();
        ps.close();
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
    return strength;
}

From source file:financepro.XYLineChartExample.java

License:asdf

public XYLineChartExample(String company) {
    super("Financial Ratios");
    System.out.println("Entered contructor");
    Company = company;//  ww  w. ja v  a2  s .  c o  m
    obj[0] = new RatioObj();
    obj[1] = new RatioObj();
    obj[2] = new RatioObj();

    //start of database accessssssssssssss
    Connection conn = null;
    Statement stmt = null;
    try {
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection(url, username, password);

        stmt = conn.createStatement();

        /*String insert = "INSERT INTO login " + "VALUES('"+id+"','"+password+"')";
          stmt.executeUpdate(insert);*/
        double iEquity = 0;
        double iCurrRatio = 0;
        double iQuickRatio;
        double iCashRatio;
        double iAssetsTo;
        double iDaySalesOut;
        double iDaysPayOut;
        double iInvDays;
        double iReturnOnSales;
        double iReturnOnAssets;
        double iReturnOnEquity;
        double iGrossProfitMargin;
        double iEBIT;
        ResultSet rs;
        int i = 0;
        System.out.println(Company);
        String insert = "SELECT Equity,CurrRatio,QuickRatio,CashRatio,AssetsTo,DaySalesOut,DaysPayOut,InvDays,ReturnOnSales,ReturnOnAssets,ReturnOnEquity,GrossProfitMargin,EBIT FROM "
                + company;
        rs = stmt.executeQuery(insert);
        while (rs.next()) {

            obj[i].Equity = rs.getDouble("Equity");
            obj[i].CurrRatio = rs.getDouble("CurrRatio");
            obj[i].QuickRatio = rs.getDouble("QuickRatio");
            obj[i].CashRatio = rs.getDouble("CashRatio");
            obj[i].AssetsTo = rs.getDouble("AssetsTo");
            obj[i].DaySalesOut = rs.getDouble("DaySalesOut");
            obj[i].DaysPayOut = rs.getDouble("DaysPayOut");
            obj[i].InvDays = rs.getDouble("InvDays");
            obj[i].ReturnOnSales = rs.getDouble("ReturnOnSales");
            obj[i].ReturnOnAssets = rs.getDouble("ReturnOnAssets");
            obj[i].ReturnOnEquity = rs.getDouble("ReturnOnEquity");
            obj[i].GrossProfitMargin = rs.getDouble("GrossProfitMargin");
            obj[i].EBIT = rs.getDouble("EBIT");
            i++;
        }

        rs.close();
        // jLabel3.setText("Connected");
    } catch (SQLException e) {
        System.out.println("Connection problems");
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(RatioObj.class.getName()).log(Level.SEVERE, null, ex);
    }

    // end of database acesssssssssssssssssssssss

    /*
     for(int i=0;i<3;i++)
     {
    obj[i].Equity = (i+1)*100;
     obj[i].CurrRatio = i + 0.34;
       obj[i].QuickRatio = i+0.56;
      obj[i].CashRatio = i+0.12;
      obj[i].AssetsTo = (i+1)*120;
        obj[i].DaySalesOut = (i+1)*300;
        obj[i].DaysPayOut = (i+1)*110;
            obj[i].InvDays = i+10;
        obj[i].ReturnOnSales = (i+1)*600;
      obj[i].ReturnOnAssets = (i+1)*300;
        obj[i].ReturnOnEquity = (i+1)*400;
         obj[i].GrossProfitMargin = (i+1)*200;
       obj[i].EBIT = (i+1)*100;
     }*/
    System.out.println(obj[0].Equity);
    JPanel chartPanel = createChartPanel();
    add(chartPanel, BorderLayout.CENTER);

    setSize(1360, 720);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
}

From source file:com.arcane.dao.Impl.PatternDaoImpl.java

@Override
public List<Event> getPatternRealData(String start, String end, String stock) {
    //return events which occurred in given time period in given stock company
    LOG.info("Returning events which occurred in given time period in given stock company ", stock);
    List<Event> events = new ArrayList<Event>();
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    String sql = "";
    Integer start1 = Integer.parseInt(start) - 40;
    Integer end1 = Integer.parseInt(end) + 0;
    sql = "SELECT * from livestream where CONVERT(date, SIGNED INTEGER) BETWEEN " + start1.toString() + " AND "
            + end1 + " ORDER BY CONVERT(date, SIGNED INTEGER)";
    List<Event> tempEventList = jdbcTemplate.query(sql, new RowMapper<Event>() {

        @Override/*from  w ww . j  a v a  2s . c  o m*/
        public Event mapRow(ResultSet rs, int rowNumber) throws SQLException {
            Event event = new Event();
            event.setId(rs.getString("id"));
            event.setStock(rs.getString("stock"));
            event.setDate(rs.getString("date"));
            event.setPrice(rs.getDouble("price"));
            return event;
        }

    });

    return tempEventList;
}

From source file:bizlogic.Records.java

public static void writeCSV(Connection DBcon, String record_id) throws SQLException {

    Statement st;/* ww  w  .  j  a  v a2 s .  c om*/
    ResultSet rs = null;

    System.out.println("WriteCSV started");

    try {
        st = DBcon.createStatement();
        rs = st.executeQuery("SELECT * FROM PUBLIC.t" + record_id);
        System.out.println("Result set read finished");
    } catch (SQLException ex) {
        Logger lgr = Logger.getLogger(Records.class.getName());
        lgr.log(Level.SEVERE, ex.getMessage(), ex);
    }

    try {

        String DELIMITER = ",";
        String NEW_LINE = "\n";
        String FILE_HEADER = "Time,Series";

        System.out.println("Delete old file");
        FileWriter csvFile = new FileWriter("/var/lib/tomcat8/webapps/ROOT/Records/Data/" + record_id + ".csv");

        //BufferedWriter csvFile = new BufferedWriter(
        //        new OutputStreamWriter(new FileOutputStream(new File(
        //                "/var/lib/tomcat8/webapps/ROOT/Records/Data/" + 
        //                        record_id + ".csv"))));

        csvFile.write("");

        csvFile.append(FILE_HEADER);
        csvFile.append(NEW_LINE);

        Calendar calendar = new GregorianCalendar();

        System.out.println("Writing file...");
        while (rs.next()) {

            long time_stamp = rs.getLong("time");
            double value = rs.getDouble("value");
            String _year;
            String _month;
            String _day;
            String _hour;
            String _min;
            String _sec;

            calendar.setTimeInMillis(time_stamp);

            _year = Integer.toString(calendar.get(Calendar.YEAR));
            _month = Integer.toString(calendar.get(Calendar.MONTH) + 1);
            _day = Integer.toString(calendar.get(Calendar.DAY_OF_MONTH));
            _hour = Integer.toString(calendar.get(Calendar.HOUR_OF_DAY));
            _min = Integer.toString(calendar.get(Calendar.MINUTE));
            _sec = Integer.toString(calendar.get(Calendar.SECOND));

            csvFile.append(_year + "/" + _month + "/" + _day + " " + _hour + ":" + _min + ":" + _sec + DELIMITER
                    + Double.toString(value) + NEW_LINE); //new Date("2009/07/19 12:34:56")

        }
        System.out.print("File written");
        rs.close();
        //csvFile.flush();
        csvFile.close();
    }

    catch (IOException ex) {
        Logger.getLogger(Records.class.getName()).log(Level.WARNING, null, ex);
    }
}

From source file:modelo.ProcesoVertimientosManagers.InformacionTecnica.java

/**
 * /*from   w  ww . j  av  a  2  s.  c o m*/
 * Arma el JSON con la informacion tecnica.
 * 
 * @param codigoProceso
 * @return
 * @throws Exception 
 */
public JSONArray getInformacionTecnica(int codigoProceso) throws Exception {

    int cantidadDatos = hayDatos(codigoProceso);

    //Mangers necesarios y Delegates Necesarios
    PuntosVertimiento puntoVert = new PuntosVertimiento();
    ParamFisicoquimicos param = new ParamFisicoquimicos();

    //Creamos el contenedor principal del JSON
    JSONArray contenedorPrincipal = new JSONArray();

    //Obtenemos la informacion del punto de vertimiento.
    Object data[] = puntoVert.getPuntosParaInfoTecnica(codigoProceso);
    ResultSet rset1 = (ResultSet) data[0];

    //Array para guardar la informacion del punto
    JSONArray puntoArray = new JSONArray();
    int puntoMonitoreo = 0;

    //Guardamos la informacion del punto en el JSON
    while (rset1.next()) {

        JSONObject puntoObject = new JSONObject();

        puntoObject.put("codigo", rset1.getString("PUNTO_MONITOREO"));
        puntoMonitoreo = Integer.parseInt(rset1.getString("PUNTO_MONITOREO"));
        puntoObject.put("ubicacion", rset1.getString("UBICACION"));
        puntoObject.put("latitud", rset1.getString("LATITUD"));
        puntoObject.put("longitud", rset1.getString("LONGITUD"));
        puntoObject.put("ciiu", rset1.getString("CIIU"));
        puntoObject.put("fechaMonitoreo", rset1.getString("FECHA_MONITOREO_PUNTO"));
        puntoObject.put("descripcionCiiu", rset1.getString("DESCRIPCION_CIIU"));
        puntoObject.put("jordanadaProductivaDia", rset1.getString("JPRODDIAS"));
        puntoObject.put("jordanadaProductivaHoras", rset1.getString("JPRODHORAS"));
        puntoObject.put("jordanadaProductivaObsev", rset1.getString("JPRODOBV"));

        int ciiu = rset1.getInt("CIIU");

        //Guardamos las informacion de la jornada
        JSONArray arrayJornada = new JSONArray();
        SeleccionarInfoTecJornadas infoTecJornadas = new SeleccionarInfoTecJornadas();

        //Validamos si ya hay datos registrados en las jornadas y en los detalles de las jornadas.
        if (cantidadDatos > 0) {

            //Obtenemos La informacion de las jornadas y las guardamos en el JSON
            ResultSet rsetJornadas = infoTecJornadas.getJornadas(puntoMonitoreo);
            while (rsetJornadas.next()) {

                JSONObject objectJornada = new JSONObject();
                objectJornada.put("nombre", "Jornada " + rsetJornadas.getInt("JORNADA"));
                objectJornada.put("cargaDBO", rsetJornadas.getDouble("CARGA_DBO"));
                objectJornada.put("cargaSST", rsetJornadas.getDouble("CARGA_SST"));
                objectJornada.put("horaInicio", rsetJornadas.getString("HORA_INICIO"));
                objectJornada.put("horaFin", rsetJornadas.getString("HORA_FIN"));
                objectJornada.put("caudalJornada", rsetJornadas.getString("CAUDAL_JORNADA"));

                int jornada = rsetJornadas.getInt("JORNADA");

                //Obtenemos y guardamos la informacion de cada parametro
                Object data2[] = param.getParametrosParaInfoTecnica(puntoMonitoreo, jornada, ciiu);
                ResultSet rset2 = (ResultSet) data2[0];

                JSONArray arrayParametro = new JSONArray();
                while (rset2.next()) {

                    JSONObject objectParametro = new JSONObject();
                    objectParametro.put("parametro", rset2.getString("PARAMETRO"));
                    objectParametro.put("codigoParametro", rset2.getString("CODIGO_PARAMETRO"));
                    objectParametro.put("rangoInicial", rset2.getString("RANGO_INICIAL"));
                    objectParametro.put("rangoFinal", rset2.getString("RANGO_FINAL"));
                    objectParametro.put("valorInforme", rset2.getDouble("VALOR"));
                    objectParametro.put("cumple", rset2.getString("CUMPLE"));
                    objectParametro.put("observacion", rset2.getString("OBSERVACION"));
                    objectParametro.put("indicardorMenor", rset2.getString("MENOR"));

                    arrayParametro.add(objectParametro);
                }

                //Cerramos conexion de parametros
                SeleccionarPrmfisicoquimicos select2 = (SeleccionarPrmfisicoquimicos) data2[1];
                select2.desconectar();

                //Guardamos los parametros en la jornada.
                objectJornada.put("tabla", arrayParametro);

                //Guardamos la Jornada
                arrayJornada.add(objectJornada);
            }
            //Cerramos la conexion de jornadas

        } else if (cantidadDatos == 0) {

            //Guardamos la informacion de las jornadas
            for (int i = 1; i < 5; i++) {
                JSONObject objectJornada = new JSONObject();
                objectJornada.put("nombre", "Jornada " + i);
                objectJornada.put("cargaDBO", "");
                objectJornada.put("cargaSST", "");
                objectJornada.put("horaInicio", "");
                objectJornada.put("horaFin", "");
                objectJornada.put("caudalJornada", "");

                //Obtenemos y guardamos la informacion de cada parametro
                Object data2[] = param.getParametrosParaInfoTecnica(ciiu);
                ResultSet rset2 = (ResultSet) data2[0];

                JSONArray arrayParametro = new JSONArray();
                while (rset2.next()) {

                    JSONObject objectParametro = new JSONObject();
                    objectParametro.put("parametro", rset2.getString("PARAMETRO"));
                    objectParametro.put("codigoParametro", rset2.getString("CODIGO_PARAMETRO"));
                    objectParametro.put("rangoInicial", rset2.getString("RANGO_INICIAL"));
                    objectParametro.put("rangoFinal", rset2.getString("RANGO_FINAL"));
                    objectParametro.put("valorInforme", "");
                    objectParametro.put("cumple", "");
                    objectParametro.put("observacion", "");
                    objectParametro.put("indicardorMenor", "");

                    arrayParametro.add(objectParametro);
                }

                //Cerramos conexion de parametros
                SeleccionarPrmfisicoquimicos select2 = (SeleccionarPrmfisicoquimicos) data2[1];
                select2.desconectar();

                //Guardamos los parametros en la jornada.
                objectJornada.put("tabla", arrayParametro);

                //Guardamos la Jornada
                arrayJornada.add(objectJornada);
            }
        }

        //guardamos las jornadas en el punto
        puntoObject.put("jornadas", arrayJornada);
        puntoArray.add(puntoObject);

        infoTecJornadas.desconectar();
    }

    contenedorPrincipal.add(puntoArray);

    //Cerrar Conexion.
    SeleccionarPuntosVertimiento select = (SeleccionarPuntosVertimiento) data[1];
    select.desconectar();

    return contenedorPrincipal;
}