share db connection logic
Merge pull request #1276 from danmcp/master

Share db connection logic