The @bjrmatos suggestion is the most common implementation.
However I just add two additional options you have:
Expose a REST API in your application and use jsreport custom script to fetch the data from it.
If you for some reason really need to connect report directly to the db, you can also use AWS lambda or Azure function to do so and request it from the jsreportonline.