本文整理汇总了Java中java.sql.ResultSet.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getFloat方法的具体用法?Java ResultSet.getFloat怎么用?Java ResultSet.getFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.getFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getList
import java.sql.ResultSet; //导入方法依赖的package包/类
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;
}
示例2: getAllItems
import java.sql.ResultSet; //导入方法依赖的package包/类
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;
}
示例3: queryProduct
import java.sql.ResultSet; //导入方法依赖的package包/类
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;
}
示例4: newCustomerFromResults
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* 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;
}
示例5: testGetFloat
import java.sql.ResultSet; //导入方法依赖的package包/类
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
}
}
示例6: getVotesAverage
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
*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;
}
示例7: getMedicine
import java.sql.ResultSet; //导入方法依赖的package包/类
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;
}
示例8: datePicked
import java.sql.ResultSet; //导入方法依赖的package包/类
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);
}
示例9: getResult
import java.sql.ResultSet; //导入方法依赖的package包/类
public Object getResult(ResultSet rs, String columnName) throws SQLException {
float f = rs.getFloat(columnName);
if (rs.wasNull()) {
return null;
}
else {
return new Float(f);
}
}
示例10: bean
import java.sql.ResultSet; //导入方法依赖的package包/类
@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;
}
示例11: jdbcGet
import java.sql.ResultSet; //导入方法依赖的package包/类
/** 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);
}
}
示例12: getValue
import java.sql.ResultSet; //导入方法依赖的package包/类
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);
}
}
示例13: getNullableResult
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Float getNullableResult(ResultSet rs, String columnName) throws SQLException {
return rs.getFloat(columnName);
}
示例14: reader
import java.sql.ResultSet; //导入方法依赖的package包/类
public Object reader(ResultSet rs, int columnIndex) throws SQLException {
return new Float(rs.getFloat(columnIndex));
}
示例15: getSystemStatisticDescriptions
import java.sql.ResultSet; //导入方法依赖的package包/类
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;
}