Get list of database connections

How can I get a list of Ignition database connections for my module, akin to calling system.db.getConnections() from Igniton?

You can get the DatasourceManager from GatewayContext#getDatasourceManager(), and then call DatasourceManager#getDatasources().

The answer depends on what context you’re programming in. On the Gateway it’s easy - you can get to the DatasourceManager from SRContext, and it has functions on it to get all of the datasources.

From the Designer or Client, you can call a function through the GatewayInterface like this:

GatewayInterface gi = GatewayConnectionManager.getInstance().getGatewayInterface(); List<SerializableDatasourceMeta> datasources = (List<SerializableDatasourceMeta>) gi.invoke("DatasourceMeta.getConnections");

Thanks guys, I am programming in the client and was able to get the list I was looking for.

As a hopefully not too ignorant followup question, does invoking the DatasourceMeta let me call any of the functions I could call from system.db in Ignition? Extending that, does calling invoke() let me call any of the methods I could normally call from within Ignition? I only ask because I looked through the DatasourceMeta Interface in the SDK and I didn’t see a getConnections method.

Thanks again for your help!

The list of what’s possible through those invoke calls is not well document unfortunately, but yes, you should be able to do pretty much anything you can do through scripting calls in this way. What else would you like to do?

At this time, nothing else. I was just wondering for future usage :slight_smile: