alter db connection and fix some bug.