Post data into MYSql db using REST
<p>I am very new to Vaadin, REST and Vertx. I want to post the data into MYSQL db from a JSON file. So I have created a base url "localhost:1443" and am able to call the handler in the other project where db is connected. But don't know to to pass the JSON file my current project to the another project where the MYSQL is configured.</p>

<p>Here am calling the method which is defined in REST,</p>

<pre><code>public OutputStream receiveUpload(String filename, String mimeType) {
    FileOutputStream fos = null; // Output stream to write to
    file = new 
    File(VaadinService.getCurrent().getBaseDirectory().getAbsolutePath() 
  +"/Jsonfile/" + filename);
    FILE_PATH = 
    VaadinService.getCurrent().getBaseDirectory().getAbsolutePath() 
  +"/Jsonfile/" + filename;
    try{
        fos = new FileOutputStream(file);
        JSONArray products = 
       productsDataProvider.uploadCatalogs(file.toString());
        Notification.show("Succesfully converted :)");
    }
    catch (final java.io.FileNotFoundException e) {
        // Error while opening the file. Not reported here.
        e.printStackTrace();
        return null;
    }

    return fos; // Return the output stream to write to
}
</code></pre>

<p>this is where I defined method,</p>

<pre><code>public JSONArray uploadCatalogs(String catalogClass) {

    return dataProviderUtil.getResourceArray("gapi/upload_products", new 
      HashMap&lt;String, String&gt;(){
        {
            put("class", catalogClass);
        }
    });
</code></pre>

<p>This is the product handler in another project,</p>

<pre><code>    router.mountSubRouter("/gapi/upload_products", new 
                     UploadCatalog(VertxInstance.get()));
</code></pre>

<p>Here the class defined,</p>

<pre><code>public class UploadCatalog  extends AbstractRouteHandler {
    private final static Logger LOG =        
       LogManager.getLogger(UploadCatalog.class);

    public UploadCatalog(Vertx vertx) {
    super(vertx);
    this.route().handler(BodyHandler.create());
    this.get("/").handler(this::upload);
}

private void upload(RoutingContext routingContext) {
    LOG.info("hello");      
}
</code></pre>

<p>i can see the logger info in console...</p>

<p>I tried the below one,</p>

<pre><code>private void upload(RoutingContext routingContext) {
    JsonObject paramsObject = routingContext.getBodyAsJson();
    JsonObject result = new JsonObject();

    Integer id = LocalCache.getInstance().store(new 
           QueryData("product.insert", paramsObject));
    LOG.info("Executing query:" + "product.insert" );
    vertx.eventBus().send(DatabaseService.DB_QUERY, id,
            (AsyncResult&lt;Message&lt;Integer&gt;&gt; res) -&gt; {
                QueryData resultData = (QueryData) 
           LocalCache.getInstance().remove(res.result().body());
                if (resultData.errorFlag || 
         resultData.updateResult.getUpdated() == 0) {
                    /*result.put("status", "error").put("error", "Error 
            in creating user profile.");
                    response.putHeader("content-type", 
          "application/json").end(result.encode());*/
                } else {
                    /*LOG.info("Insert query (ms):" + 
           resultData.responseTimeInMillis);
                    this.sendNewUserProfile(data, response);*/
                }
            });
}
</code></pre>

<p>How to insert data in mysql db from JSON file?</p>