Java Code Examples for java.sql.ResultSet.getFloat()

The following are Jave code examples for showing how to use getFloat() of the java.sql.ResultSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alchem   File: ViewPurchaseController.java   View Source Code Vote up 7 votes
public ObservableList<Purchase> getList(String sqlQuery,ObservableList<Purchase> purchaseListDetails)
{
    String date,wholesalerName,mode;
    Long billNumber;
    Float amount;
    try
    {
        Connection dbConnection= JDBC.databaseConnect();
        Statement sqlStatement=dbConnection.createStatement();
        ResultSet saleResultSet=sqlStatement.executeQuery(sqlQuery);
        while(saleResultSet.next())
        {
            date=saleResultSet.getString("date");
            wholesalerName=saleResultSet.getString("wholesaler_name");
            mode=saleResultSet.getString("mode");
            billNumber=saleResultSet.getLong("bill_no");
            amount=saleResultSet.getFloat("total_amount");
            purchaseListDetails.add(new Purchase(date,billNumber,wholesalerName,mode,amount));
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return purchaseListDetails;
}
 
Example 2
Project: Storage-System   File: ItemDAO.java   View Source Code Vote up 6 votes
public ArrayList<ItemCreation> getAllItems() {
    ArrayList<ItemCreation> items = new ArrayList<>();
    Connection conn = null;
    try {
        conn = MysqlDAO.getInstance().connect();
        PreparedStatement statement = conn.prepareStatement("SELECT `ID`, `itemName`, `dop`, `price`, `notes` FROM `items`");
        ResultSet resultSet = statement.executeQuery();

        while (resultSet.next()) {
            int id = resultSet.getInt("ID");
            String name = resultSet.getString("itemName");
            String dop = resultSet.getString("dop");
            Float price = resultSet.getFloat("price");
            String notes = resultSet.getString("notes");

            ItemCreation i = new ItemCreation(id, dop, name, price, notes);
            items.add(i);
        }
    } catch (SQLException ex) {
        Logger.getLogger(MysqlDAO.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        MysqlDAO.getInstance().closeConnection(conn);
    }
    return items;
}
 
Example 3
Project: JavaEE   File: DBUtils.java   View Source Code Vote up 6 votes
public static List<Product> queryProduct(Connection conn)
        throws SQLException {

    String sql = "SELECT code, name, price FROM product";

    PreparedStatement pstm = conn.prepareStatement(sql);
    ResultSet rs = pstm.executeQuery();
    List<Product> list = new ArrayList<Product>();
    while (rs.next()) {
        String code = rs.getString("code");
        String name = rs.getString("name");
        float price = rs.getFloat("price");
        Product product = new Product();
        product.setCode(code);
        product.setName(name);
        product.setPrice(price);
        list.add(product);
    }
    return list;
}
 
Example 4
Project: HTAPBench   File: TPCCUtil.java   View Source Code Vote up 6 votes
/**
    * Creates a Customer object from the current row in the given ResultSet.
    * The caller is responsible for closing the ResultSet.
    * @param rs an open ResultSet positioned to the desired row
    * @return the newly created Customer object
    * @throws SQLException for problems getting data from row
    */
public static Customer newCustomerFromResults(ResultSet rs)
		throws SQLException {
	Customer c = new Customer();
	// TODO: Use column indices: probably faster?
	c.c_first = rs.getString("c_first");
	c.c_middle = rs.getString("c_middle");
	c.c_street_1 = rs.getString("c_street_1");
	c.c_street_2 = rs.getString("c_street_2");
	c.c_city = rs.getString("c_city");
	c.c_state = rs.getString("c_state");
	c.c_zip = rs.getString("c_zip");
	c.c_phone = rs.getString("c_phone");
	c.c_credit = rs.getString("c_credit");
	c.c_credit_lim = rs.getFloat("c_credit_lim");
	c.c_discount = rs.getFloat("c_discount");
	c.c_balance = rs.getFloat("c_balance");
	c.c_ytd_payment = rs.getFloat("c_ytd_payment");
	c.c_payment_cnt = rs.getInt("c_payment_cnt");
	c.c_since = rs.getTimestamp("c_since");
	return c;
}
 
Example 5
Project: calcite-avatica   File: AvaticaResultSetConversionsTest.java   View Source Code Vote up 5 votes
public void testGetFloat(ResultSet resultSet) throws SQLException {
  try {
    resultSet.getFloat(ordinal);
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success
  }
}
 
Example 6
Project: GamingPlatform   File: GiocoDao.java   View Source Code Vote up 5 votes
/**
*Method to get votes average for a game
*
*@param gioco game we want votes average
*@return float all votes average
*@throws SQLException if no database connection is found or another error occurs
*/
@Override
public float getVotesAverage(Gioco gioco) throws SQLException{
  float votes_avarage;
  Connection connection = DB.openConnection();
  PreparedStatement ps = connection.prepareStatement(VOTES_AVERAGE);
  ps.setInt(1, gioco.getId());
  ResultSet rset = ps.executeQuery();
  rset.first();
  votes_avarage = rset.getFloat(1);
  ps.close();
  rset.close();
  connection.close();
  return votes_avarage;
}
 
Example 7
Project: alchem   File: InventoryController.java   View Source Code Vote up 5 votes
public ObservableList<Medicine> getMedicine() {
    int code = 0, quantity = 0, sgst = 0, cgst = 0, igst = 0;
    String name, salt, company, type, batch, hsn, expiry;
    float mrp, cost;
    medicines = FXCollections.observableArrayList();

    try {
        Connection dbConnection = JDBC.databaseConnect();
        Statement sqlStatement = dbConnection.createStatement();
        ResultSet medicineResultSet = sqlStatement.executeQuery("SELECT medicine.medicine_id,medicine.name,medicine.salt,medicine.company,medicine.type,medicine.hsn_number,medicine_info.batch_number,medicine_info.expiry_date,medicine_info.mrp,medicine_info.cost_price,quantity.piece,gst.sgst,gst.cgst,gst.igst FROM medicine JOIN  medicine_info ON medicine.medicine_id=medicine_info.medicine_id JOIN quantity ON medicine_info.medicine_info_id=quantity.medicine_info_id JOIN gst ON medicine.medicine_id=gst.medicine_id");
        while (medicineResultSet.next()) {
            code = medicineResultSet.getInt("medicine_id");
            name = medicineResultSet.getString("name");
            salt = medicineResultSet.getString("salt");
            company = medicineResultSet.getString("company");
            type = medicineResultSet.getString("type");
            hsn = medicineResultSet.getString("hsn_number");
            sgst = medicineResultSet.getInt("sgst");
            cgst = medicineResultSet.getInt("cgst");
            igst = medicineResultSet.getInt("igst");
            batch = medicineResultSet.getString("batch_number");
            expiry = medicineResultSet.getString("expiry_date");
            mrp = medicineResultSet.getFloat("mrp");
            cost = medicineResultSet.getFloat("cost_price");
            quantity = medicineResultSet.getInt("piece");
            medicines.add(new Medicine(code, name, salt, company, type, hsn, batch, expiry, quantity, mrp, cost, sgst, cgst, igst));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return medicines;
}
 
Example 8
Project: alchem   File: ViewSaleController.java   View Source Code Vote up 5 votes
public void datePicked() {
    String date = saleDatePicker.getValue().toString();
    float sum = 0.0f;
    saleParticularDayList = getParticularSaleDate(date);
    if (saleParticularDayList.size() < 1) {
        saleParticularDayList.add(new Sale(date, (long) 0, "-", "-", "-", "-", 0.0f));
    }
    try {
        Connection dbConnection = JDBC.databaseConnect();
        Statement sqlStatement = dbConnection.createStatement();
        String sqlQuery = "SELECT sum(total_amount) from retailer_sale_bill where user_access_id='" + user_id + "' and date='" + date + "'";
        ResultSet saleResultSet = sqlStatement.executeQuery(sqlQuery);
        while (saleResultSet.next()) {
            sum = saleResultSet.getFloat(1);
            break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    Calendar dateToday = Calendar.getInstance();
    int year, day, month;
    String dateChk, tense;
    year = dateToday.get(Calendar.YEAR);
    month = dateToday.get(Calendar.MONTH) + 1;
    day = dateToday.get(Calendar.DAY_OF_MONTH);
    dateChk = year + "-" + month + "-" + day;
    if (dateChk.equals(date))
        tense = "is";
    else
        tense = "was";
    saleTableView.setItems(saleParticularDayList);
    dateSelectedLabel.setText("Total Sale on " + date + " " + tense + " Rs." + sum);
    datePickedHBox.setVisible(true);

}
 
Example 9
Project: uavstack   File: DAOFactory.java   View Source Code Vote up 5 votes
public Object getResult(ResultSet rs, String columnName) throws SQLException {

            float f = rs.getFloat(columnName);
            if (rs.wasNull()) {
                return null;
            }
            else {
                return new Float(f);
            }
        }
 
Example 10
Project: slardar   File: BaseTypeWrapper.java   View Source Code Vote up 5 votes
@Override
public T bean(ResultSet rs, Class<T> type) {
    try {
        if (rs.next()) {
            switch (JAVAType.getType(type)){
                case INT:return (T) new Integer(rs.getInt(1));
                case FLOAT:return (T) new Float(rs.getFloat(1));
                case LONG:return (T) new Long(rs.getLong(1));
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 11
Project: calcite-avatica   File: ColumnMetaData.java   View Source Code Vote up 4 votes
/** Returns the value of a column of this type from a result set. */
public Object jdbcGet(ResultSet resultSet, int i) throws SQLException {
  switch (this) {
  case PRIMITIVE_BOOLEAN:
    return resultSet.getBoolean(i);
  case PRIMITIVE_BYTE:
    return resultSet.getByte(i);
  case PRIMITIVE_SHORT:
    return resultSet.getShort(i);
  case PRIMITIVE_INT:
    return resultSet.getInt(i);
  case PRIMITIVE_LONG:
    return resultSet.getLong(i);
  case PRIMITIVE_FLOAT:
    return resultSet.getFloat(i);
  case PRIMITIVE_DOUBLE:
    return resultSet.getDouble(i);
  case BOOLEAN:
    final boolean aBoolean = resultSet.getBoolean(i);
    return resultSet.wasNull() ? null : aBoolean;
  case BYTE:
    final byte aByte = resultSet.getByte(i);
    return resultSet.wasNull() ? null : aByte;
  case SHORT:
    final short aShort = resultSet.getShort(i);
    return resultSet.wasNull() ? null : aShort;
  case INTEGER:
    final int anInt = resultSet.getInt(i);
    return resultSet.wasNull() ? null : anInt;
  case LONG:
    final long aLong = resultSet.getLong(i);
    return resultSet.wasNull() ? null : aLong;
  case FLOAT:
    final float aFloat = resultSet.getFloat(i);
    return resultSet.wasNull() ? null : aFloat;
  case DOUBLE:
    final double aDouble = resultSet.getDouble(i);
    return resultSet.wasNull() ? null : aDouble;
  case JAVA_SQL_DATE:
    return resultSet.getDate(i);
  case JAVA_SQL_TIME:
    return resultSet.getTime(i);
  case JAVA_SQL_TIMESTAMP:
    return resultSet.getTimestamp(i);
  case ARRAY:
    return resultSet.getArray(i);
  case STRUCT:
    return resultSet.getObject(i, Struct.class);
  default:
    return resultSet.getObject(i);
  }
}
 
Example 12
Project: calcite-avatica   File: JdbcResultSet.java   View Source Code Vote up 4 votes
private static Object getValue(ResultSet resultSet, int type, int j,
    Calendar calendar) throws SQLException {
  switch (type) {
  case Types.BIGINT:
    final long aLong = resultSet.getLong(j + 1);
    return aLong == 0 && resultSet.wasNull() ? null : aLong;
  case Types.INTEGER:
    final int anInt = resultSet.getInt(j + 1);
    return anInt == 0 && resultSet.wasNull() ? null : anInt;
  case Types.SMALLINT:
    final short aShort = resultSet.getShort(j + 1);
    return aShort == 0 && resultSet.wasNull() ? null : aShort;
  case Types.TINYINT:
    final byte aByte = resultSet.getByte(j + 1);
    return aByte == 0 && resultSet.wasNull() ? null : aByte;
  case Types.DOUBLE:
  case Types.FLOAT:
    final double aDouble = resultSet.getDouble(j + 1);
    return aDouble == 0D && resultSet.wasNull() ? null : aDouble;
  case Types.REAL:
    final float aFloat = resultSet.getFloat(j + 1);
    return aFloat == 0D && resultSet.wasNull() ? null : aFloat;
  case Types.DATE:
    final Date aDate = resultSet.getDate(j + 1, calendar);
    return aDate == null
        ? null
        : (int) (aDate.getTime() / DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIME:
    final Time aTime = resultSet.getTime(j + 1, calendar);
    return aTime == null
        ? null
        : (int) (aTime.getTime() % DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIMESTAMP:
    final Timestamp aTimestamp = resultSet.getTimestamp(j + 1, calendar);
    return aTimestamp == null ? null : aTimestamp.getTime();
  case Types.ARRAY:
    final Array array = resultSet.getArray(j + 1);
    if (null == array) {
      return null;
    }
    try {
      // Recursively extracts an Array using its ResultSet-representation
      return extractUsingResultSet(array, calendar);
    } catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
      // Not every database might implement Array.getResultSet(). This call
      // assumes a non-nested array (depends on the db if that's a valid assumption)
      return extractUsingArray(array, calendar);
    }
  case Types.STRUCT:
    Struct struct = resultSet.getObject(j + 1, Struct.class);
    Object[] attrs = struct.getAttributes();
    List<Object> list = new ArrayList<>(attrs.length);
    for (Object o : attrs) {
      list.add(o);
    }
    return list;
  default:
    return resultSet.getObject(j + 1);
  }
}
 
Example 13
Project: tangyuan2   File: FloatTypeHandler.java   View Source Code Vote up 4 votes
@Override
public Float getNullableResult(ResultSet rs, String columnName) throws SQLException {
	return rs.getFloat(columnName);
}
 
Example 14
Project: ralasafe   File: ResultSetReader.java   View Source Code Vote up 4 votes
public Object reader(ResultSet rs, int columnIndex) throws SQLException {
	return new Float(rs.getFloat(columnIndex));
}
 
Example 15
Project: ralasafe   File: ResultSetReader.java   View Source Code Vote up 4 votes
public Object reader(ResultSet rs, String columnName)
		throws SQLException {
	return new Float(rs.getFloat(columnName));
}
 
Example 16
Project: ats-framework   File: SQLServerDbReadAccess.java   View Source Code Vote up 4 votes
public List<StatisticDescription> getSystemStatisticDescriptions(
                                                                  float timeOffset,
                                                                  String whereClause,
                                                                  Map<String, String> testcaseAliases,
                                                                  int utcTimeOffset,
                                                                  boolean dayLightSavingOn ) throws DatabaseAccessException {

    List<StatisticDescription> statisticDescriptions = new ArrayList<StatisticDescription>();

    String sqlLog = new SqlRequestFormatter().add("fdate", formatDateFromEpoch(timeOffset))
                                             .add("whereClause", whereClause)
                                             .format();
    Connection connection = getConnection();
    CallableStatement callableStatement = null;
    ResultSet rs = null;
    try {

        callableStatement = connection.prepareCall("{ call sp_get_system_statistic_descriptions(?, ?) }");
        callableStatement.setString(1, formatDateFromEpoch(timeOffset));
        callableStatement.setString(2, whereClause);

        rs = callableStatement.executeQuery();
        int numberRecords = 0;
        while (rs.next()) {
            StatisticDescription statisticDescription = new StatisticDescription();

            statisticDescription.testcaseId = rs.getInt("testcaseId");

            // if user has provided testcase alias - use it instead the original testcase name
            if (testcaseAliases != null) {
                statisticDescription.testcaseName = testcaseAliases.get(String.valueOf(statisticDescription.testcaseId));
            }
            if (statisticDescription.testcaseName == null) {
                statisticDescription.testcaseName = rs.getString("testcaseName");
            }

            long startTimestamp = rs.getInt("testcaseStarttime");
            if (dayLightSavingOn) {
                startTimestamp += 3600; // add 1h to time stamp
            }
            statisticDescription.setStartTimestamp(startTimestamp);
            statisticDescription.setTimeOffset(utcTimeOffset);

            statisticDescription.machineId = rs.getInt("machineId");
            statisticDescription.machineName = rs.getString("machineName");

            statisticDescription.statisticTypeId = rs.getInt("statsTypeId");
            statisticDescription.statisticName = rs.getString("name");

            statisticDescription.unit = rs.getString("units");
            statisticDescription.params = rs.getString("params");
            statisticDescription.parent = rs.getString("parentName");
            statisticDescription.internalName = rs.getString("internalName");

            statisticDescription.numberMeasurements = rs.getInt("statsNumberMeasurements");
            statisticDescription.minValue = rs.getFloat("statsMinValue");
            statisticDescription.maxValue = rs.getFloat("statsMaxValue");
            statisticDescription.avgValue = rs.getFloat("statsAvgValue");

            statisticDescriptions.add(statisticDescription);

            numberRecords++;
        }

        logQuerySuccess(sqlLog, "system statistic descriptions", numberRecords);
    } catch (Exception e) {
        throw new DatabaseAccessException("Error when " + sqlLog, e);
    } finally {
        DbUtils.closeResultSet(rs);
        DbUtils.close(connection, callableStatement);
    }

    return statisticDescriptions;
}
 
Example 17
Project: ats-framework   File: SQLServerDbReadAccess.java   View Source Code Vote up 4 votes
public List<Statistic> getSystemStatistics( float timeOffset,
                                            String testcaseIds,
                                            String machineIds,
                                            String statsTypeIds,
                                            int utcTimeOffset,
                                            boolean dayLightSavingOn )
                                                                       throws DatabaseAccessException {

    List<Statistic> allStatistics = new ArrayList<Statistic>();

    String sqlLog = new SqlRequestFormatter().add("fdate", formatDateFromEpoch(timeOffset))
                                             .add("testcase ids", testcaseIds)
                                             .add("machine ids", machineIds)
                                             .add("stats type ids", statsTypeIds)
                                             .format();

    Connection connection = getConnection();
    CallableStatement callableStatement = null;
    ResultSet rs = null;
    try {

        callableStatement = connection.prepareCall("{ call sp_get_system_statistics(?, ?, ?, ?) }");

        callableStatement.setString(1, formatDateFromEpoch(timeOffset));
        callableStatement.setString(2, testcaseIds);
        callableStatement.setString(3, machineIds);
        callableStatement.setString(4, statsTypeIds);

        rs = callableStatement.executeQuery();
        int numberRecords = 0;
        while (rs.next()) {
            Statistic statistic = new Statistic();
            statistic.statisticTypeId = rs.getInt("statsTypeId");
            statistic.name = rs.getString("statsName");
            statistic.parentName = rs.getString("statsParent");
            statistic.unit = rs.getString("statsUnit");
            statistic.value = rs.getFloat("value");
            statistic.setDate(rs.getString("statsAxis"));

            long startTimestamp = rs.getInt("statsAxisTimestamp");
            if (dayLightSavingOn) {
                startTimestamp += 3600; // add 1h to time stamp
            }
            statistic.setStartTimestamp(startTimestamp);
            statistic.setTimeOffset(utcTimeOffset);

            statistic.machineId = rs.getInt("machineId");
            statistic.testcaseId = rs.getInt("testcaseId");

            numberRecords++;
            // add the combined statistics to the others
            allStatistics.add(statistic);
        }

        logQuerySuccess(sqlLog, "system statistics", numberRecords);
    } catch (Exception e) {
        throw new DatabaseAccessException("Error when " + sqlLog, e);
    } finally {
        DbUtils.closeResultSet(rs);
        DbUtils.close(connection, callableStatement);
    }

    return allStatistics;
}
 
Example 18
Project: ats-framework   File: SQLServerDbReadAccess.java   View Source Code Vote up 4 votes
public List<Checkpoint> getCheckpoints( String testcaseId,
                                        int loadQueueId,
                                        String checkpointName,
                                        int utcTimeOffset,
                                        boolean dayLightSavingOn ) throws DatabaseAccessException {

    List<Checkpoint> checkpoints = new ArrayList<Checkpoint>();

    String sqlLog = new SqlRequestFormatter().add("testcase id", testcaseId)
                                             .add("loadQueue id", loadQueueId)
                                             .add("checkpoint name", checkpointName)
                                             .format();
    Connection connection = getConnection();
    PreparedStatement statement = null;
    ResultSet rs = null;
    try {

        statement = connection.prepareStatement("SELECT ch.checkpointId, ch.responseTime, ch.transferRate, ch.transferRateUnit, ch.result,"
                                                + " DATEDIFF(second, CONVERT( datetime, '1970-01-01 00:00:00', 20), ch.endTime) as endTime,"
                                                + " ch.endtime AS copyEndTime"
                                                + " FROM tCheckpoints ch"
                                                + " INNER JOIN tCheckpointsSummary chs on (chs.checkpointSummaryId = ch.checkpointSummaryId)"
                                                + " INNER JOIN tLoadQueues c on (c.loadQueueId = chs.loadQueueId)"
                                                + " INNER JOIN tTestcases tt on (tt.testcaseId = c.testcaseId) "
                                                + "WHERE tt.testcaseId = ? AND c.loadQueueId = ? AND ch.name = ?");

        statement.setString(1, testcaseId);
        statement.setInt(2, loadQueueId);
        statement.setString(3, checkpointName);

        rs = statement.executeQuery();
        while (rs.next()) {

            Checkpoint checkpoint = new Checkpoint();
            checkpoint.checkpointId = rs.getInt("checkpointId");
            checkpoint.name = checkpointName;
            checkpoint.responseTime = rs.getInt("responseTime");
            checkpoint.transferRate = rs.getFloat("transferRate");
            checkpoint.transferRateUnit = rs.getString("transferRateUnit");
            checkpoint.result = rs.getInt("result");

            if (dayLightSavingOn) {
                checkpoint.setEndTimestamp(rs.getLong("endTime") + 3600); // add 1h
            } else {
                checkpoint.setEndTimestamp(rs.getLong("endTime"));
            }
            checkpoint.setTimeOffset(utcTimeOffset);
            checkpoint.copyEndTimestamp = rs.getTimestamp("copyEndTime").getTime();

            checkpoints.add(checkpoint);
        }

        logQuerySuccess(sqlLog, "checkpoints", checkpoints.size());
    } catch (Exception e) {
        throw new DatabaseAccessException("Error when " + sqlLog, e);
    } finally {
        DbUtils.closeResultSet(rs);
        DbUtils.close(connection, statement);
    }

    return checkpoints;
}
 
Example 19
Project: alchem   File: ViewSaleController.java   View Source Code Vote up 4 votes
public void calculateTotalSale() {
    Calendar dateToday = Calendar.getInstance();
    long dateCheck;
    year[0] = dateToday.get(Calendar.YEAR);
    month[0] = dateToday.get(Calendar.MONTH) + 1;
    day[0] = dateToday.get(Calendar.DAY_OF_MONTH);
    String date;
    try {
        Connection dbConnection = JDBC.databaseConnect();
        Statement sqlStatement = dbConnection.createStatement();
        for (int i = 0; i < 7; i++) {
            date = year[i] + "-" + month[i] + "-" + day[i];
            String sqlQuery = "SELECT sum(total_amount) from retailer_sale_bill where user_access_id='" + user_id + "' and date='" + date + "'";
            ResultSet saleResultSet = sqlStatement.executeQuery(sqlQuery);
            while (saleResultSet.next()) {
                sum[i] = saleResultSet.getFloat(1);
                break;
            }
            if (i != 6) {
                dateCheck = day[i] - 1;
                if (dateCheck == 0) {
                    if (month[i] == 2 || month[i] == 4 || month[i] == 6 || month[i] == 8 || month[i] == 9 || month[i] == 11) {
                        day[i + 1] = 31;
                        month[i + 1] = month[i] - 1;
                        year[i + 1] = year[i];
                    } else if (month[i] == 5 || month[i] == 7 || month[i] == 10 || month[i] == 12) {
                        day[i + 1] = 30;
                        month[i + 1] = month[i] - 1;
                        year[i + 1] = year[i];
                    } else if (month[i] == 1) {
                        day[i + 1] = 31;
                        month[i + 1] = 12;
                        year[i + 1] = year[i] - 1;
                    } else {
                        if (year[i] % 4 == 0) {
                            if (year[i] % 100 == 0) {
                                if (year[i] % 400 == 0)
                                    day[i + 1] = 29;
                                else
                                    day[i + 1] = 28;
                            } else
                                day[i + 1] = 29;
                        } else
                            day[i + 1] = 28;
                        month[i + 1] = month[i] - 1;
                        year[i + 1] = year[i];
                    }
                } else {
                    day[i + 1] = day[i] - 1;
                    month[i + 1] = month[i];
                    year[i + 1] = year[i];
                }
            }
        }
        setSaleLabel();

    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
Example 20
Project: tangyuan2   File: FloatTypeHandler.java   View Source Code Vote up 4 votes
@Override
public Float getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
	return rs.getFloat(columnIndex);
}