When attempting to compile my code I seem to get the following error:
"Resource specification not allowed here for source level below 1.7"
I know what it means but I do not understand why I am getting it. It displays the area as being relevant to DriverManager.getConnection(DATABASE_URL, DATABASE_USERNAME, DATABASE_PASSWORD);
public boolean validate(String emailId, String password) throws SQLException{
try(Connection connection = DriverManager
.getConnection(DATABASE_URL, DATABASE_USERNAME,DATABASE_PASSWORD);
PreparedStatement preparedStatement = connection.prepareStatement(SELECT_QUERY)){
preparedStatement.setString(1, emailId);
preparedStatement.setString(2, password);
System.out.println(preparedStatement);
ResultSet resultSet = preparedStatement.executeQuery();
if(resultSet.next()) {
return true;
}
}
catch (SQLException e) {
printSQLException(e);
}
return false;
}
To clarify I am using maven in addition to Eclipse as my IDE. I am aware I can edit the compliance level in the project properties window. However this results in another error where different classes have been compiled with different versions of the JRE.
Is there anything else I could do other than having to downgrade my current version of Java and the version of Javafx I am using?