Cannot find database connection - name cannot be null

We are using a system.db.runPrepQuery in a UDT and are getting the following error when our tag event is being fired:

com.inductiveautomation.ignition.common.script.JythonExecException: java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepQuery( select top 1 DowntimeOngoingId ,MachineName ,SCWStatus ,FirstName ,LastName ,EmployeeId from [downtime_ongoing] where MachineName = ? and SCWStatus is not null and ClosedAt is null , , [ZZTest], )

Caused by: java.lang.IllegalArgumentException: Cannot find database connection - name cannot be null.

From what we understand, if you exclude the database argument it should use the project default as stated in the documentation:

String database - The name of the database connection to execute against. If omitted or "", the project's default database connection will be used. [optional]

Is this not the case when using system.db.runPrepQuery in a UDT or are we hitting a bug?

Tags don’t belong to any project. You have to include the database connection name.


I would think that tags get executed in the context of the project that is calling them? That would be a pretty be oversight in the documentation if that is the case.

Tag events are initiated by the tag itself. There’s no project calling them.

1 Like

Thank you, however that’s ridiculous… The documentation needs to be updated in order to mention this as a warning… it caused us some real headaches.


Yeah, it sure is. Normally we have a separate panel for gateway scoped syntax, specifically for cases like this. I updated the page for runPrepUpdate, but I’ll take a look at the adjacent functions to see if there are any other offenders (I see a few). Thanks for mentioning the issue.