Reputation: 169
Good day, I have searched through a couple of questions in how to save the values in the resultset in a variable. Since I am using a function, I do not know what to put in the ResultSetVar.getString("") function.
Here is my query.
sqlSelectRecord1 = "SELECT COUNT(name) as acount from maintable where VLdate = ?";
psSelectRecord1=conn.prepareStatement(sqlSelectRecord1);
psSelectRecord1.setString(1, strDateofVL);
rsSelectRecord1=psSelectRecord1.executeQuery();
String strCount;
Integer iCount;
while (rsSelectRecord1.next()) {
strCount = rsSelectRecord1.getString(acount);
iCount = Integer.valueOf(strCount);
}
I am having an error that says acount cannot be resolved into a variable. I'm guessing it does not read my AS acount in my query. How do I make my way through this?
Upvotes: 0
Views: 731
Reputation:
You must use a name.
strCount = rsSelectRecord1.getString("acount");
Upvotes: 2