i am trying to retrieve the max value of the column ID from the table SAMPLE_1. i am able to execute the sql query in Derby but i am not able to retrieve the value from my result set in java. Am i doing something wrong? do i need to retrieve the value from the max function in another way? Please help.
selectQuery = dbConnection.prepareStatement("SELECT MAX(ID)
FROM ROOTUSER.SAMPLE_1");
resultSet = selectQuery.executeQuery();
System.out.println(resultSet.getString(1));
You have to call resultSet.next()
before calling getString()
.