I have a database template thing and is it possible to configure the jdbc connection string dynamically from the mashup? When a mashup is loaded, is it possible to pass the database name, username and password as input to establish the connection between that database and thing?
Yes, this is definitely possible. Please refer to Setting Configuration tab values on Things via a custom Service in ThingWorx for more information.
In summary, you need to navigate to your Database Thing > Services > GetConfigurationTables. This will return all the Configuration Tables available for that specific Thing, depending on the template. Then, run GetConfigurationTable for the specific table you are looking for more information about. In this case, we are looking at ConnectionInfo, per the image below:
This allows you to create a Data Shape from the returned values by clicking the + Data Shape button on the top right corner of the screen. Then, all you need to do is setup your service to run SetConfigurationTable and passing the table name (ConnectionInfo) and an infotable with a row containing the information sent from the UI.
I hope you find this information helpful in setting configuration tables dynamically in runtime.
The JDBC settings are stored in configuration table in Thingworx and you can get/set them using the get/setconfigurationtable snippet on the DB thing. There is also an example given here:
If you feel your question has been answered, please mark the appropriate post as the Accepted Solution for the benefit of others with the same question.
Thank you for your participation in our community!