Fixed the nullPointerException caused by not succesfully opening the dataSource. There are a lot of hacks in here, expect a clean up soon.