refactor database layer to use Java7 resource monitoring and make sure prepared statements are closed after use