I have a variable that is not supposed to change its value after it\'s been initialized, so I want to define it as a final variable.
the problem is that the variable
You could handle the Exceptions more accurately. If you get an Exception opening the connection, you don't have to close it in the finally block I guess. If you get an exception after that, in the try block, and handle the exception in a new nested try-catch block you don't need to define the variable outside. Something like:
try {
final Connection conn = getConn(prefix);
try {
//code using conn
} catch (Exception e) {
} finally {
closeConnection(conn);
}
} catch (DbHelperException e) {
throw new DbHelperException("error opening connection", e);
}