# Try not catching SQL Table Missing Error

**URL:** <https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [August 21, 2026, 10:12am UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858 "2026-08-21T10:12:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![billy\_hanner](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@billy\_hanner](https://forum.inductiveautomation.com/u/billy_hanner)\
**Post date:** [August 21, 2026, 10:12am UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/1 "2026-08-21T10:12:50Z")

</div>

Hi,  
I'm running a series of named queries using scripting. I've put try-except statements around most of my named queries, but it doesn't appear to be catching the error from the actual named query e.g. Table is missing or Database is offline

```python
	if C1_Database == True:
		print "Secondary Database Write Attempt"
		try:
			Write_Return = system.db.execQuery(Path,Parameters)
			print "Secondary Write Success"
		except Exception as error:
			print str(error)

```

It does catch errors like wrong path or wrong parameters

---

<div class="post-metadata">

**Author:** ![bobby.miller](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bobby.miller/32/85153_2.png) [@bobby.miller](https://forum.inductiveautomation.com/u/bobby.miller)\
**Post date:** [August 21, 2026, 10:55am UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/2 "2026-08-21T10:55:30Z")

</div>

First, you should use `system.db.execUpdate` for an insert/update, not `execQuery`.

Second, you can try catching the java exception with something like this:

```python
from java.lang import Throwable

try:
    Write_Return = system.db.execUpdate(Path, Parameters)
    print "Secondary Write Success"
except Throwable, error:
    system.util.getLogger("Database").error("Named query failed", error)

```

---

<div class="post-metadata">

**Author:** ![billy\_hanner](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@billy\_hanner](https://forum.inductiveautomation.com/u/billy_hanner)\
**Post date:** [August 21, 2026, 12:39pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/3 "2026-08-21T12:39:36Z")

</div>

> [@bobby.miller](#):
>
> `except Throwable, error:`

I had the query in question set to query not update changed that and didn't fix it but adding the throwable section did now i'm getting what i expected from the error handling.

Do you happen to know why I need the throwable code instead of a regular exception?

---

<div class="post-metadata">

**Author:** ![bobby.miller](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bobby.miller/32/85153_2.png) [@bobby.miller](https://forum.inductiveautomation.com/u/bobby.miller)\
**Post date:** [August 21, 2026, 12:42pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/4 "2026-08-21T12:42:23Z")

</div>

The exception is happening in java, not jython. You're going a layer deeper with this. Glad it's working for you now!

---

<div class="post-metadata">

**Author:** ![billy\_hanner](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@billy\_hanner](https://forum.inductiveautomation.com/u/billy_hanner)\
**Post date:** [August 21, 2026, 12:45pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/5 "2026-08-21T12:45:31Z")

</div>

Ahh got you that makes sense

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 21, 2026, 12:48pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/6 "2026-08-21T12:48:58Z")

</div>

To be more precise, java exceptions and jython exceptions are not in the same class hierarchy, so an `except` clause that names an exception type **cannot** catch from the other hierarchy. You need two `except` clauses in some cases.

---

<div class="post-metadata">

**Author:** ![billy\_hanner](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@billy\_hanner](https://forum.inductiveautomation.com/u/billy_hanner)\
**Post date:** [August 21, 2026, 2:10pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/7 "2026-08-21T14:10:26Z")

</div>

Oh thanks for the info i still need to protect against jython exceptions so knowing that is very helpful 🙂

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 21, 2026, 4:59pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/8 "2026-08-21T16:59:39Z")

</div>

> [@pturmel](#):
>
> You need two `except` clauses in some cases.

You should be able to use a single clause

```python
except (Exception, Throwable) as e:

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 21, 2026, 5:38pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/9 "2026-08-21T17:38:49Z")

</div>

Yes, but then you cannot easily use the backtrace-handling logger methods. And if you are going to throw away the backtrace, what's the point of catching any generic exception?  
If you aren't going to ignore the exception entirely (or expected exceptions for which you have specific handling), then you really want the proper backtrace.

If you want to handle some exceptions and then log the generic ones, use three or more `except` clauses. The last two should be the jython and java generics, and the jython generic should be converted to java for the logger.

---

<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:** [August 21, 2026, 5:57pm UTC](https://forum.inductiveautomation.com/t/try-not-catching-sql-table-missing-error/116858/10 "2026-08-21T17:57:51Z")

</div>

High on my scripting wish list is extending LoggerEx methods to accept Jython throwables and transparently adapt their stacktrace to the right format. That way logging either branch of exception 'just works' (if you've structured your `catch` the right way).
