Can I load in a unique Groovy Scrip (or DB Connector) many queries form data base and save this data in many processes variables? How?

Hello to the hole Bonita community, I’m new in Bonita 7.2, any help will be appreciated.
The problem is that I have too many Data Base connectors, and I think should exist a different way of doing this in an optimal way, with only one connector executing multiples queries.
In one task I have to load many Select Widgets from different tables in data base, now what I am doing is creating one ON_Enter Data base connector for each Select Item. I store the values of the query, in a process Variable and I show it in a select item, accessing via API rest to the process variable, and I show it in the form (of course in json format).
This is perfect and show the values that I want.
My Question is if is there a way of making it in one unique groovy script?, can I read all the tables and store and load these values in the different processes variables to show it in the form?, I think this would be better than having 20 data base connectors in one task, that is what I am doing right now.
I think that it would be better to have one groovy script that makes all of this things, but I can’t connect to the data base from this script and return the different values in the different variables.

I think that the connector lets you execute many different queries, and access this values from the groovy script, but I don’t know the way of store this results in many processes variables to show it in different select item.
Bye!!
Thanks to all

We do this a lot and use only one groovy script.

The way to do it is as follows:

Create a list variable
Connect to database
Do select 1 and process to json1
ListVariable.add(json1)
Do select 2 and process to json2
ListVariable.add(json2)
Etc.
Return ListVariable

Then on the output of the groovy script connector

Pv1 = ListVariable(1)
Etc.

Very easy and very effective.

regards
Seán

PS: If this reply answers your question, please mark as resolved.

Thank you very much, it seems very easy, right now I have changed the focus of my work and I am working in a different thing for some days and I can’t try this.
When I took this job again, I will try that option.
Thanks!!

Thanks!

Sorry, in this case Do you use a Data base connector?, or you use a common groovy script, and then, Do you conect from it to the data base?
I don’t understad this:

Connect to database
Do select 1 and process to json1
ListVariable.add(json1)
Do select 2 and process to json2
ListVariable.add(json2)

¿Could you tell me how to conect to the Data Base from a Groovy Script?
I’m tryin to do it with jdbc conector. but I get null allways

conn = BonitaSql.newInstance(SMSOpConfig.getDBUrl(), SMSOpConfig.getDBUser(),SMSOpConfig.getDBPass(), new com.mysql.jdbc.Driver());
conn().executeQuery(…

… And this never returns any value, always null.

Thanks