'How to retrieve value for specific column in Arraylist with resultset
I would like to retrieve the data for the 5th row with the help of resultset.getDouble() after I have set the SQL queries. May I know is it possible to set to retrieve the value from specific column?
Data class:
data class BudgetList(
var bdCategory: String = "",
var bdAmount: Double =0.00,
var bdDate: String = "",
var bdNote:String ="",
var bdSpent: Double = 0.0) : Parcelable{}
SQL Queries:
"SELECT SUM(eAmount) as spentAmount from Expenses JOIN Budget ON Expenses.Category = Budget.Category where Expenses.Username = '$cUser'AND eMonth = '$month' AND eYear = '$year' GROUP BY eMonth, eYear"
statement = connection!!.createStatement()
var rs : ResultSet = statement!!.executeQuery(sql)
while (rs.next())
{
var amount : Double = rs.getDouble("spentAmount")
}
rs.close()
statement!!.close()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
