There are many docs available that does that. Create an adaptive form and form data modelUse adaptive form rule editor to build business rulesStyle an adaptive formTest and publish an adaptive form
If you need to populate this dynamically - why use content fragment in the first place. I would look at writing HTL/Sling Model component where you have a lot more control using code.
Here is an older doc that covers HOW TO pass a file to an AEM servlet using JQuery:Adobe Experience Manager Help | Uploading files to Adobe Experience Manager DAM using AssetManager API
Querying data from a relational database to display in an AEM component can be done:Adobe Experience Manager Help | Querying MySQL data using an Adobe Experience Manager 6.4 DataSourcePool
Did you write that Java code or copy it from somewhere?The reason I am asking is that it seems strange that you know how to write that Java code for Experience Manager yet post in a Encore forum.