Changed to postgresql and fixed some problems.

Change-Id: I39bdcf4a5ca39da629e91d3e763b45abf234872e