This code needs to be in the same try above, you need an big enclosing try catch finally clause, so that you only have one catch clause for DatabaseException and SQLException, do you notice that you are duplicating them