You may need to do some modifications in xform.js in which you can call a webscript which will get you the required data from the database and the returned data you should use to populate the text box in a web form.
Not for webform but to Share, but to complete this post, for those arriving now, I would like to mention that there is a component in Alfresco Addons that does this and more in a simple, intuitive and powerful way. https://addons.alfresco.com/addons/alfresco-metadbconnector-component I hope this helps the community.