# \[IGN-10341\]Error when using database transaction when a project does not have a default database

**URL:** <https://forum.inductiveautomation.com/t/ign-10341-error-when-using-database-transaction-when-a-project-does-not-have-a-default-database/93240>\
**Category:** Ignition\
**Created:** [July 15, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/ign-10341-error-when-using-database-transaction-when-a-project-does-not-have-a-default-database/93240 "2024-07-15T15:54:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [July 15, 2024, 3:54pm UTC](https://forum.inductiveautomation.com/t/ign-10341-error-when-using-database-transaction-when-a-project-does-not-have-a-default-database/93240/1 "2024-07-15T15:54:31Z")

</div>

Why does a project need a default database connection when using transactions?

```python
txID = system.db.beginTransaction(database = "LocalMYSQL")

query = """
	INSERT INTO test(MyAge)
	VALUE (?)
	"""
s = system.date.toMillis(system.date.now())
system.db.runPrepUpdate(query, [s], tx = txID)
system.db.commitTransaction(txID)
system.db.closeTransaction(txID)

```

> Java Traceback:  
> Traceback (most recent call last):  
> File "", line 8, in   
> INSERT INTO test(MyAge)  
> VALUE (?)  
> , [1721058713492], Transaction datasource 'LocalMYSQL', 40dd3b55-0c8e-4529-9d8e-4bac72824631, false, false)
> 
> at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:392)
> 
> at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:268)
> 
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 
> at java.base/java.lang.reflect.Method.invoke(Unknown Source)
> 
> java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(  
> INSERT INTO test(MyAge)  
> VALUE (?)  
> , [1721058713492], Transaction datasource 'LocalMYSQL', 40dd3b55-0c8e-4529-9d8e-4bac72824631, false, false)
> 
> at org.python.core.Py.JavaError(Py.java:545)
> 
> at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:392)
> 
> at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:268)
> 
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 
> at java.base/java.lang.reflect.Method.invoke(Unknown Source)
> 
> at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:190)
> 
> at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. **call** (ScriptManager.java:553)
> 
> at org.python.core.PyObject. **call** (PyObject.java:400)
> 
> at org.python.pycode.\_pyx21.f$0(:10)
> 
> at org.python.pycode.\_pyx21.call\_function()
> 
> at org.python.core.PyTableCode.call(PyTableCode.java:173)
> 
> at org.python.core.PyCode.call(PyCode.java:18)
> 
> at org.python.core.Py.runCode(Py.java:1703)
> 
> at org.python.core.Py.exec(Py.java:1747)
> 
> at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:277)
> 
> at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:130)
> 
> at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:628)
> 
> at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:616)
> 
> at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
> 
> at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
> 
> at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
> 
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> 
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> 
> at java.base/java.lang.Thread.run(Unknown Source)
> 
> Caused by: java.lang.Exception: Error executing system.db.runPrepUpdate(  
> INSERT INTO test(MyAge)  
> VALUE (?)  
> , [1721058713492], Transaction datasource 'LocalMYSQL', 40dd3b55-0c8e-4529-9d8e-4bac72824631, false, false)
> 
> ... 25 more
> 
> Caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: Connection Error: Unable to find project's default datasource.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 15, 2024, 4:02pm UTC](https://forum.inductiveautomation.com/t/ign-10341-error-when-using-database-transaction-when-a-project-does-not-have-a-default-database/93240/2 "2024-07-15T16:02:08Z")

</div>

Because of a coding mistake on our part; the check for "does this database name exist" happens unconditionally (when a DB query is invoked from the client/designer, at least) _before_ the transaction ID is evaluated.

---

<div class="post-metadata">

**Author:** ![james.vosler](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@james.vosler](https://forum.inductiveautomation.com/u/james.vosler)\
**Post date:** [June 23, 2026, 2:27pm UTC](https://forum.inductiveautomation.com/t/ign-10341-error-when-using-database-transaction-when-a-project-does-not-have-a-default-database/93240/3 "2026-06-23T14:27:19Z")

</div>

Note 1: This is not (ever? no longer?) an issue on the gateway side of things. It only affects client (designer/vision) calls. Still an issue in 8.1.52 and 8.3.6

Note 2: Vision scripts require the default db to be set.

Note 3: If you have a valid transaction in a script console, the db connection you pass in does not have to be valid -- any garbage string will do.

Has this been resolved or is there a plan to do so?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 23, 2026, 2:57pm UTC](https://forum.inductiveautomation.com/t/ign-10341-error-when-using-database-transaction-when-a-project-does-not-have-a-default-database/93240/4 "2026-06-23T14:57:46Z")

</div>

It's still a bug sitting in our backlog. Evidently it survived the refactoring the RPC system got in 8.3, which I guess is a testament to us maintaining bug-for-bug compatibility 🙃

The state of things right now would be to resolve this in 8.3.x only.
