Adding a try-catch block
This shows how to use Eclipse to insert a try-catch block around a statement which automatically includes possible exceptions
Select the statement to surround with a try-catch block
Right click on the selection and choose Source -> Surround with Try / Catch Block
You should now edit the Auto-generated catch block(s)
Note: don't forget to remove the e.printStackTrace(); if you do not want this exception to put a stackTrace in the logs