Attempting to use system.db.addDatasource

Using Version: 8.0.17

Hello everyone, I’m attempting to use the system.db.addDatasource function

https://docs.inductiveautomation.com/display/DOC80/system.db.addDatasource

It seems passing in the jdbcDriver as “MYSQL” or “MySQL” is causing errors.

I’ve created all connection types and used system.db.getConnections to get the “DBType” to pass into this variable.

It seems even when I use the example on the system.db.addDatasource documentation page, I receive the same error.

java.lang.Exception: java.lang.Exception: JDBC driver ‘MySQL’ not found

Does anyone have any insight on the situation? Thank you in advance!

I would imagine that is a typo in the 8.x documentation.

The code for 7.9x shows as

system.db.addDatasource(jdbcDriver = "MySQL ConnectorJ" , name = "MySQL" ,

connectURL = "jdbc:mysql://localhost:3306/test" , username = "root" ,

password = "password" , props = "zeroDateTimeBehavior=convertToNull;" )

So the driver name for MySQL should be MySQL ConnectorJ

@Paul.Scott

1 Like

Thank you very much, this was the solution. I should have looked at previous documentation. For anyone else, the driver names are exactly as they appear on the gateway page when trying to add a connection manually!

Correct, the function is looking for the name of the JDBC driver, as configured on the gateway. It looks like the initial name of the MySQL JDBC driver on new installations was changed sometime in 8.0’s lifespan.

I updated the example so it’s not so misleading for future folks trying to add MySQL connections. Thanks for lettings us know!