Here you can find the source of getFloatList(ResultSet resultSet, String columnName)
Parameter | Description |
---|---|
resultSet | - Result set. |
columnName | - Column name. |
public static List<Float> getFloatList(ResultSet resultSet, String columnName) throws SQLException
//package com.java2s; /*// www .ja v a 2s . com * Copyright (C) 2015 Bryan W. Snipes * * This file is part of the JDistil web application framework. * * JDistil is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * JDistil is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with JDistil. If not, see <http://www.gnu.org/licenses/>. */ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; public class Main { /** Returns a list of float values using a given SQL result set and column name. @param resultSet - Result set. @param columnName - Column name. @return List - Column values. */ public static List<Float> getFloatList(ResultSet resultSet, String columnName) throws SQLException { // Initialize return value List<Float> values = null; if (resultSet != null && columnName != null) { // Create values list values = new ArrayList<Float>(); // Populate list while (resultSet.next()) { values.add(getFloat(resultSet, columnName)); } } return values; } /** Returns a float value using a given SQL result set and column name. @param resultSet - Result set. @param columnName - Column name. @return Float - Column value. */ public static Float getFloat(ResultSet resultSet, String columnName) throws SQLException { // Initialize return value Float value = null; if (resultSet != null && columnName != null) { // Get column value float columnValue = resultSet.getFloat(columnName); // Check for null value if (!resultSet.wasNull()) { value = new Float(columnValue); } } return value; } }