I would remove your database access. You don't need it, because you do not want to use it to do this. You must never write to an Atlassian database when the application is running, because you will, at best, make what you've written useless, and at worst, lose everything.
Forget the database, write your code to push your data in over the REST API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.