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:br.com.great.dao.SonsDAO.java

/**
* 
* Mtodo responsvel por get os dados da CSons no banco de dados
*
* @author Carleandro Noleto/*from w  w  w  .  j  a  va2s. co  m*/
 * @param mecanica_id int
 * @return JSONObject Dados CSons
* @since 14/01/2015
* @version 1.0
*/
public Som getMecCSons(int mecanica_id) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Connection conexao = criarConexao();
    Som cSons = null;
    try {
        String sql = "SELECT * FROM  `csons` WHERE  `csons`.`mecsimples_id` =  " + mecanica_id;
        pstmt = conexao.prepareStatement(sql);
        rs = pstmt.executeQuery();
        if (rs.next()) {
            cSons = new Som();
            cSons.setSom_id(rs.getInt("id"));
            cSons.setArqSom(rs.getString("som"));
            cSons.setCapturarObjeto(new CapturarObjeto());
            cSons.getCapturarObjeto().setJogador_id(rs.getInt("jogador_id"));
            cSons.getCapturarObjeto()
                    .setPosicao(new Posicao(rs.getDouble("latitude"), rs.getDouble("longitude")));
            cSons.setMecsimples_id(rs.getInt("mecsimples_id"));
        }
    } catch (SQLException e) {
        System.out.println("Erro ao listar dados de uma mecanica csons: " + e.getMessage());
    } finally {
        fecharConexao(conexao, pstmt, rs);
    }
    return cSons;

}

From source file:com.smhdemo.common.report.generate.factory.ChartFactory.java

/**
 * ?//from  www.j av  a2 s  .c o m
 *
 * @param reportDataSet ??
 * @param sql SQL?
 * @return DefaultCategoryDataset
 * @throws BaseException
 */
@SuppressWarnings("rawtypes")
private DefaultCategoryDataset buildDataset(Chart report, Map<String, String> pageParams) throws BaseException {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Connection con = null;

    DataSourceServiceable service = null;
    int colCount;
    try {
        Base dataSet = report.getBaseDS();
        String executableSQL = report.getChartSql();
        executableSQL = replaceParam(pageParams, report.getParameters(), executableSQL, true);

        if (dataSet == null) {
            con = dataSource.getConnection();
        } else {
            DataSourceFactoryable factory = (DataSourceFactoryable) initDataSourceFactory
                    .getBean(dataSet.getClass());
            service = factory.createService(dataSet);
            con = service.openConnection();
        }

        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery(executableSQL);

        colCount = rs.getMetaData().getColumnCount();

        if (colCount == 2) {
            while (rs.next()) {
                try {
                    try {
                        dataset.addValue(rs.getDouble(1), "", (Comparable) rs.getObject(2));
                    } catch (Exception e) {
                        dataset.addValue(rs.getDouble(2), "", (Comparable) rs.getObject(1));
                    }
                } catch (Exception e) {
                    logger.error("SQL?", e);
                    throw new BaseException("SQL?", "SQL?");
                }
            }
        } else if (colCount == 3) {
            while (rs.next()) {
                try {
                    try {
                        dataset.addValue(rs.getDouble(3), (Comparable) rs.getObject(1),
                                (Comparable) rs.getObject(2));
                    } catch (Exception e) {
                        try {
                            dataset.addValue(rs.getDouble(2), (Comparable) rs.getObject(1),
                                    (Comparable) rs.getObject(3));
                        } catch (Exception ex) {
                            dataset.addValue(rs.getDouble(1), (Comparable) rs.getObject(2),
                                    (Comparable) rs.getObject(3));
                        }
                    }
                } catch (Exception e) {
                    logger.error("SQL?", e);
                    throw new BaseException("SQL?", "SQL?");
                }
            }
        } else {
            logger.error("SQL??12");
            throw new BaseException("?12", "?12");
        }
        st.close();
        rs.close();
    } catch (Exception e) {
        throw new BaseException(e.toString(), e.toString());
    } finally {
        if (service != null) {
            service.closeConnection();
        }
        if (con != null) {
            try {
                con.close();
            } catch (SQLException e) {
            }
            con = null;
        }
    }
    return dataset;
}

From source file:com.freedomotic.plugins.devices.harvester_chart.HarvesterChart.java

@ListenEventsOn(channel = "app.event.sensor.object.behavior.clicked")
public void onObjectClicked(EventTemplate event) {
    List<String> behavior_list = new ArrayList<String>();
    System.out.println("received event " + event.toString());
    ObjectReceiveClick clickEvent = (ObjectReceiveClick) event;
    //PRINT EVENT CONTENT WITH
    System.out.println(clickEvent.getPayload().toString());
    String objectName = clickEvent.getProperty("object.name");
    String protocol = clickEvent.getProperty("object.protocol");
    String address = clickEvent.getProperty("object.address");

    try {/*ww w.  java2  s .c om*/
        Statement stat = connection.createStatement();
        System.out.println("Protocol=" + protocol + ",Address=" + address);

        //for (EnvObjectLogic object : EnvObjectPersistence.getObjectByProtocol("wifi_id")){
        //EnvObjectLogic object = EnvObjectPersistence.getObjectByName(objectName);

        for (EnvObjectLogic object : EnvObjectPersistence.getObjectByAddress(protocol, address)) {
            for (BehaviorLogic behavior : object.getBehaviors()) {
                System.out.println(behavior.getName());
            }
        }

        //String query = "select date,value from events where protocol='"+clickEvent.getProperty("object.protocol")+"' and behavior='power' ORDER BY ID DESC LIMIT 1000;";
        String query = "select date,value from events where object='" + objectName
                + "' and behavior='power' ORDER BY ID DESC LIMIT 1000;";
        System.out.println(query);
        //String query = "select datetime(date, 'unixepoch', 'localtime') as TIME,value from events where protocol='remote_receiver' and behavior='button'";

        ResultSet rs = stat.executeQuery(query);
        //JFreeChart chart = ChartFactory.createLineChart("Test", "Id", "Score", dataset, PlotOrientation.VERTICAL, true, true, false); 

        //System.out.println("Wilson Kong Debug:"+rs.getLong("date"));
        final TimeSeries series = new TimeSeries("Data1", Millisecond.class);

        while (rs.next()) {
            Date resultdate = new Date(rs.getLong("date") * 1000);
            Millisecond ms_read = new Millisecond(resultdate);
            series.addOrUpdate(ms_read, rs.getDouble("value"));
            //series.add((Millisecond)rs.getLong("date"),(double)rs.getLong("value"));
        }
        XYDataset xyDataset = new TimeSeriesCollection(series);

        JFreeChart chart = ChartFactory.createTimeSeriesChart("Chart", "TIME", "VALVE", xyDataset, true, // legend
                true, // tooltips
                false // urls
        );
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(800, 500));
        JFrame f = new JFrame("Chart");
        f.setContentPane(chartPanel);
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        f.pack();
        f.setVisible(true);
        //if (...) {
        //MyFrame myFrame = new MyFrame();
        //bindGuiToPlugin(myFrame);
        //showGui(); //triggers the showing of your frame. Before it calls onShowGui()
        //}
    } catch (SQLException ex) {
        Logger.getLogger(HarvesterChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage());
        System.out.println("Wilson Kong Error: " + ex.toString());
        //ex.printStackTrace();
        stop();
    }
}

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

/**
* 
* Mtodo responsvel por get os dados da CSons no banco de dados
*
* @author Carleandro Noleto/*w  w w  . j av  a 2 s .c om*/
 * @param mecanica_id int
 * @return JSONObject Dados de CVideos
* @since 14/01/2015
* @version 1.0
*/
public Video getMecCVideos(int mecanica_id) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Connection conexao = criarConexao();
    Video cVideos = null;
    try {
        String sql = "SELECT * FROM  `cvideos` WHERE  `cvideos`.`mecsimples_id` =  " + mecanica_id;
        pstmt = conexao.prepareStatement(sql);
        rs = pstmt.executeQuery();
        if (rs.next()) {
            cVideos = new Video();
            cVideos.setVideo_id(rs.getInt("id"));
            cVideos.setArqVideo(rs.getString("video"));
            cVideos.setCapturarObjeto(new CapturarObjeto());
            cVideos.getCapturarObjeto().setJogador_id(rs.getInt("jogador_id"));
            cVideos.getCapturarObjeto()
                    .setPosicao(new Posicao(rs.getDouble("latitude"), rs.getDouble("longitude")));
            cVideos.setMecsimples_id(rs.getInt("mecsimples_id"));
        }
    } catch (SQLException e) {
        System.out.println("Erro ao listar dados de uma mecanica cvideos: " + e.getMessage());
    } finally {
        fecharConexao(conexao, pstmt, rs);
    }
    return cVideos;

}

From source file:eu.udig.tools.jgrass.geopaparazzi.ImportGeopaparazziFolderWizard.java

private void notesToShapefile(Connection connection, File outputFolderFile, IProgressMonitor pm)
        throws Exception {
    File outputShapeFile = new File(outputFolderFile, GEOPAPARAZZI_NOTES_OUTPUTSHAPEFILENAME);

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName("geopaparazzinotes"); //$NON-NLS-1$
    b.setCRS(mapCrs);/*from w  w w . j  av a 2s . co  m*/
    b.add("the_geom", Point.class); //$NON-NLS-1$
    for (String fieldName : GEOPAPARAZZI_NOTES_DESCRIPTIONFIELDS) {
        b.add(fieldName, String.class);
    }
    SimpleFeatureType featureType = b.buildFeatureType();
    MathTransform transform = CRS.findMathTransform(DefaultGeographicCRS.WGS84, mapCrs);
    pm.beginTask("Import notes...", IProgressMonitor.UNKNOWN);
    FeatureCollection<SimpleFeatureType, SimpleFeature> newCollection = FeatureCollections.newCollection();

    Statement statement = null;
    try {
        statement = connection.createStatement();
        statement.setQueryTimeout(30); // set timeout to 30 sec.

        ResultSet rs = statement.executeQuery("select lat, lon, altim, ts, text from notes");
        int i = 0;
        while (rs.next()) {

            double lat = rs.getDouble("lat");
            double lon = rs.getDouble("lon");
            double altim = rs.getDouble("altim");
            String dateTimeString = rs.getString("ts");
            String text = rs.getString("text");

            if (lat == 0 || lon == 0) {
                continue;
            }

            // and then create the features
            Coordinate c = new Coordinate(lon, lat);
            Point point = gF.createPoint(c);
            Geometry reprojectPoint = JTS.transform(point, transform);

            SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
            Object[] values = new Object[] { reprojectPoint, text, dateTimeString, String.valueOf(altim) };
            builder.addAll(values);
            SimpleFeature feature = builder.buildFeature(featureType.getTypeName() + "." + i++);
            newCollection.add(feature);
            pm.worked(1);
        }
    } finally {
        pm.done();
        if (statement != null)
            statement.close();
    }

    ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("url", outputShapeFile.toURI().toURL());
    params.put("create spatial index", Boolean.TRUE);
    ShapefileDataStore dStore = (ShapefileDataStore) factory.createNewDataStore(params);
    dStore.createSchema(featureType);
    dStore.forceSchemaCRS(mapCrs);

    JGrassToolsPlugin.getDefault().writeToShapefile(dStore, newCollection);

    JGrassToolsPlugin.getDefault().addServiceToCatalogAndMap(outputShapeFile.getAbsolutePath(), true, true,
            new NullProgressMonitor());

}

From source file:edu.uga.cs.fluxbuster.features.FeatureCalculator.java

/**
 * Calculates the previous cluster ratio feature for each cluster generated
 * on a specific run date and within the a specific window
 *
 * @param log_date the run date/*from   w ww. ja  va 2s  . com*/
 * @param window the number of days previous to use in feature calculation
 * @return a table of results, the keys of the table are cluster ids and the
 *       values are lists of two elements.  The first element is the 
 *       last_growth_ratio_prev_clusters value and the second element is the
 *       last_growth_prefix_ratio_prev_clusters value
 * @throws SQLException if there is and error calculating the feature
 */
public Hashtable<Integer, List<Double>> calculatePrevClusterRatios(Date log_date, int window)
        throws SQLException {
    Hashtable<Integer, List<Double>> retval = new Hashtable<Integer, List<Double>>();

    ArrayList<Date> prevDates = getPrevDates(log_date, window);
    String query1 = properties.getProperty(PREVCLUSTER_QUERY1KEY);
    String query2 = properties.getProperty(PREVCLUSTER_QUERY2KEY);
    String logDateStr = df.format(log_date);
    String completequery = new String();

    StringBuffer addQueryBuff = new StringBuffer();
    for (int i = 0; i < prevDates.size(); i++) {
        String prevDateStr = df.format(prevDates.get(i));
        StringBuffer querybuf = new StringBuffer();
        Formatter formatter = new Formatter(querybuf);
        formatter.format(query1, logDateStr, logDateStr, prevDateStr, prevDateStr, prevDateStr);
        addQueryBuff.append(querybuf.toString());
        if (i < prevDates.size() - 1) {
            addQueryBuff.append(" UNION ");
        }
        formatter.close();
    }

    if (addQueryBuff.length() > 0) {
        StringBuffer querybuf = new StringBuffer();
        Formatter formatter = new Formatter(querybuf);
        formatter.format(query2, logDateStr, logDateStr, addQueryBuff.toString());
        completequery = querybuf.toString();
        formatter.close();
    }

    if (completequery.length() > 0) {
        ResultSet rs = null;
        try {
            rs = dbi.executeQueryWithResult(completequery);
            while (rs.next()) {
                ArrayList<Double> temp = new ArrayList<Double>();
                temp.add(rs.getDouble(3));
                temp.add(rs.getDouble(4));
                retval.put(rs.getInt(1), temp);
            }
        } catch (Exception e) {
            if (log.isErrorEnabled()) {
                log.error(e);
            }
        } finally {
            if (rs != null && !rs.isClosed()) {
                rs.close();
            }
        }
        Hashtable<Integer, Double> queryPerDomain = getQueriesPerDomain(log_date);
        for (Integer clusterid : retval.keySet()) {
            List<Double> values = retval.get(clusterid);
            values.set(0, values.get(0) / queryPerDomain.get(clusterid));
            values.set(1, values.get(1) / queryPerDomain.get(clusterid));
        }
    }

    return retval;
}

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

/**
* 
* Mtodo responsvel por get os dados da CTextos no banco de dados
*
* @author Carleandro Noleto/*  ww  w.  j av  a 2 s .  c o  m*/
 * @param mecanica_id int
 * @return JSONObject Dados de CTextos
* @since 19/01/2015
* @version 1.0
*/
public Texto getMecCTextos(int mecanica_id) {
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    Connection conexao = criarConexao();
    Texto cTextos = null;
    try {
        String sql = "SELECT * FROM  `ctextos` WHERE  `ctextos`.`mecsimples_id` =  " + mecanica_id;
        pstmt = conexao.prepareStatement(sql);
        rs = pstmt.executeQuery();
        if (rs.next()) {
            cTextos = new Texto();
            cTextos.setTexto_id(rs.getInt("id"));
            cTextos.setTexto(rs.getString("texto"));
            cTextos.setCapturarObjeto(new CapturarObjeto());
            cTextos.getCapturarObjeto().setJogador_id(rs.getInt("jogador_id"));
            cTextos.getCapturarObjeto()
                    .setPosicao(new Posicao(rs.getDouble("latitude"), rs.getDouble("longitude")));
            cTextos.setMecsimples_id(rs.getInt("mecsimples_id"));
        }
    } catch (SQLException e) {
        System.out.println("Erro ao listar dados de uma mecanica cTextos: " + e.getMessage());
    } finally {
        fecharConexao(conexao, pstmt, rs);
    }
    return cTextos;

}

From source file:com.ewcms.plugin.report.generate.factory.ChartFactory.java

/**
 * ?//  ww  w  .  ja va 2  s  . c  o m
 *
 * @param reportDataSet ??
 * @param sql SQL?
 * @return DefaultCategoryDataset
 * @throws BaseException
 */
@SuppressWarnings("rawtypes")
private DefaultCategoryDataset buildDataset(ChartReport report, Map<String, String> pageParams)
        throws BaseException {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Connection con = null;
    EwcmsDataSourceServiceable service = null;
    int colCount;
    try {
        BaseDS dataSet = report.getBaseDS();
        String executableSQL = report.getChartSql();

        executableSQL = replaceParam(pageParams, report.getParameters(), executableSQL, true);

        if (dataSet == null) {
            con = dataSource.getConnection();
        } else {
            DataSourceFactoryable factory = (DataSourceFactoryable) getAlqcDataSourceFactory()
                    .getBean(dataSet.getClass());
            service = factory.createService(dataSet);
            con = service.openConnection();
        }

        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery(executableSQL);

        colCount = rs.getMetaData().getColumnCount();

        if (colCount == 2) {
            while (rs.next()) {
                try {
                    try {
                        dataset.addValue(rs.getDouble(1), "", (Comparable) rs.getObject(2));
                    } catch (Exception e) {
                        dataset.addValue(rs.getDouble(2), "", (Comparable) rs.getObject(1));
                    }
                    //                       if (rs.getMetaData().getColumnType(1) == Types.NUMERIC){
                    //                            dataset.addValue(rs.getDouble(1), "", (Comparable) rs.getObject(2));
                    //                       }else if (rs.getMetaData().getColumnType(2) == Types.NUMERIC) {
                    //                            dataset.addValue(rs.getDouble(2), "", (Comparable) rs.getObject(1));
                    //                       }
                } catch (Exception e) {
                    logger.error("SQL?", e);
                    throw new BaseException("SQL?", "SQL?");
                }
            }
        } else if (colCount == 3) {
            while (rs.next()) {
                try {
                    //                       log.info(rs.getMetaData().getColumnType(1));
                    //                       log.info(rs.getMetaData().getColumnType(2));
                    //                       log.info(rs.getMetaData().getColumnType(3));
                    //                       if (rs.getMetaData().getColumnType(1) == Types.NUMERIC){
                    //                            dataset.addValue(rs.getDouble(1), (Comparable) rs.getObject(2), (Comparable) rs.getObject(3));
                    //                       }else if (rs.getMetaData().getColumnType(2) == Types.NUMERIC){
                    //                          dataset.addValue(rs.getDouble(2), (Comparable) rs.getObject(1), (Comparable) rs.getObject(3));
                    //                       }else if (rs.getMetaData().getColumnType(3) == Types.NUMERIC){
                    //                          dataset.addValue(rs.getDouble(3), (Comparable) rs.getObject(1), (Comparable) rs.getObject(2));
                    //                       }
                    try {
                        dataset.addValue(rs.getDouble(3), (Comparable) rs.getObject(1),
                                (Comparable) rs.getObject(2));
                    } catch (Exception e) {
                        try {
                            dataset.addValue(rs.getDouble(2), (Comparable) rs.getObject(1),
                                    (Comparable) rs.getObject(3));
                        } catch (Exception ex) {
                            dataset.addValue(rs.getDouble(1), (Comparable) rs.getObject(2),
                                    (Comparable) rs.getObject(3));
                        }
                    }
                } catch (Exception e) {
                    logger.error("SQL?", e);
                    throw new BaseException("SQL?", "SQL?");
                }
            }
        } else {
            logger.error("SQL??12");
            throw new BaseException("?12", "?12");
        }
        st.close();
        rs.close();
    } catch (SQLException e) {
        throw new BaseException(e.toString(), e.toString());
    } catch (ConvertException e) {
        throw new BaseException(e.toString(), e.toString());
    } catch (ClassNotFoundException e) {
        throw new BaseException(e.toString(), e.toString());
    } finally {
        if (service != null) {
            service.closeConnection();
        }
        if (con != null) {
            try {
                con.close();
            } catch (SQLException e) {
            }
            con = null;
        }
    }
    return dataset;
}

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

@Override
public String getJSONPaymentPreferances(int state) {
    StringBuffer sb = null;//from   w ww.j  a  v  a  2  s .c o  m
    int dataCount = 0;

    int pages = 0;
    PaymentAccountDAOImp pad = new PaymentAccountDAOImp();
    try {
        sb = new StringBuffer("{'prefarence':{");
        sb.append("'pages':[");

        String sql = "SELECT * FROM payment_preferences WHERE state=?";
        PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql);
        ps.setInt(1, state);
        ResultSet rs = ps.executeQuery();
        System.out.println("total:" + getResultSetCount(rs));

        while (rs.next()) {

            if (dataCount % 10 == 0) {

                pages++;

                if (rs.isLast()) {
                    sb.append("{'id':'" + rs.getString(1) + "','userid':'" + rs.getString(2) + "','reqdate':'"
                            + rs.getString(3) + "','acctype':'" + pad.getPaymetAccountName(rs.getInt(5))
                            + "','amount':'" + rs.getDouble(7) + "','state':'" + rs.getInt(8) + "','email':'"
                            + rs.getString(9) + "','no':'" + pages + "'}");
                } else {

                    sb.append("{'id':'" + rs.getString(1) + "','userid':'" + rs.getString(2) + "','reqdate':'"
                            + rs.getString(3) + "','acctype':'" + pad.getPaymetAccountName(rs.getInt(5))
                            + "','amount':'" + rs.getDouble(7) + "','state':'" + rs.getInt(8) + "','email':'"
                            + rs.getString(9) + "','no':'" + pages + "'},");

                }
            }

            if (dataCount % 10 != 0) {

                if (rs.isLast()) {
                    sb.append("{'id':'" + rs.getString(1) + "','userid':'" + rs.getString(2) + "','reqdate':'"
                            + rs.getString(3) + "','acctype':'" + pad.getPaymetAccountName(rs.getInt(5))
                            + "','amount':'" + rs.getDouble(7) + "','state':'" + rs.getInt(8) + "','email':'"
                            + rs.getString(9) + "','no':'" + pages + "'}");
                } else {
                    sb.append("{'id':'" + rs.getString(1) + "','userid':'" + rs.getString(2) + "','reqdate':'"
                            + rs.getString(3) + "','acctype':'" + pad.getPaymetAccountName(rs.getInt(5))
                            + "','amount':'" + rs.getDouble(7) + "','state':'" + rs.getInt(8) + "','email':'"
                            + rs.getString(9) + "','no':'" + pages + "'},");
                }
            }
            System.out.println("id:" + rs.getInt(1));
            System.out.println(dataCount + "||" + dataCount % 10);
            System.out.println("pages" + pages);
            dataCount++;
        }
        sb.append("],");
        sb.append("'leng':'" + pages + "',");
        sb.append("}");
        sb.append("}");

    } catch (Exception e) {
        e.printStackTrace();
    }
    return sb.toString();
}

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

public Holding getHoldingForUpdate(int orderId) throws DAOException {
    if (logger.isDebugEnabled()) {
        logger.debug("MySQLCustomerDAO.getHoldingForUpdate(int)\nOrder ID :" + orderId);
    }//w  w  w .ja v a2 s  .c om

    Holding holding = null;
    PreparedStatement selectHoldingLockStat = null;
    try {
        selectHoldingLockStat = sqlConnection.prepareStatement(SQL_SELECT_HOLDING_LOCK);
        selectHoldingLockStat.setInt(1, orderId);
        ResultSet rs = selectHoldingLockStat.executeQuery();
        if (rs.next()) {
            try {
                holding = new Holding(rs.getInt(1), rs.getInt(2), rs.getDouble(3), rs.getBigDecimal(4),
                        StockTraderUtility.convertToCalendar(rs.getDate(5)), rs.getString(6));
                return holding;
            } finally {
                try {
                    rs.close();
                } catch (SQLException e) {
                    logger.debug("", e);
                }
            }
        }
    } catch (SQLException e) {
        throw new DAOException("Exception is thrown when selecting the holding entry for order ID :" + orderId,
                e);
    } finally {
        if (selectHoldingLockStat != null) {
            try {
                selectHoldingLockStat.close();
            } catch (SQLException e) {
                logger.debug("", e);
            }
        }
    }
    return holding;
}