# system.db.runPrepUpdate throws java.lang.Exception

**URL:** <https://forum.inductiveautomation.com/t/system-db-runprepupdate-throws-java-lang-exception/50762>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [September 9, 2021, 11:54am UTC](https://forum.inductiveautomation.com/t/system-db-runprepupdate-throws-java-lang-exception/50762 "2021-09-09T11:54:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahsasalimi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mahsasalimi/32/68520_2.png) [@mahsasalimi](https://forum.inductiveautomation.com/u/mahsasalimi)\
**Post date:** [September 9, 2021, 11:54am UTC](https://forum.inductiveautomation.com/t/system-db-runprepupdate-throws-java-lang-exception/50762/1 "2021-09-09T11:54:47Z")

</div>

## Hi , I am trying to follow an example regarding the file upload (onFileReceived) [https://docs.inductiveautomation.com/display/DOC80/Download+and+Upload+Files](https://docs.inductiveautomation.com/display/DOC80/Download+and+Upload+Files) I tried to save the uploaded file into my database but I get an error . Is there a way to get more info about the error and what causes it ?

```
	# Grab the file name and data
fname = event.file.name
fdata = event.file.getBytes()
system.perspective.print(fname)
	     
# Use a query to insert the file
query = "INSERT INTO files (filename, filedata) VALUES(?, CONVERT(varbinary(MAX), ?))"
args = [fname, fdata]
try:
	system.db.runPrepUpdate(query,args,"Test")
	#system.perspective.print(newID)
except:
	system.perspective.print(sys.exc_info())	

```

* * *

error:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/11437440b14fbfc85b83e0e75f1c81d60ee4d453.png)

---

<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:** [September 9, 2021, 12:04pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepupdate-throws-java-lang-exception/50762/2 "2021-09-09T12:04:36Z")

</div>

Please post the rest of the exception. Click on the “+” sign on the right in the gateway web interface, or open the wrapper.log file itself. Please paste it here (preferably as text using the “preformatted” button, not as a screenshot).

---

<div class="post-metadata">

**Author:** ![mahsasalimi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mahsasalimi/32/68520_2.png) [@mahsasalimi](https://forum.inductiveautomation.com/u/mahsasalimi)\
**Post date:** [September 9, 2021, 1:49pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepupdate-throws-java-lang-exception/50762/3 "2021-09-09T13:49:11Z")

</div>

following is from the wrapper

INFO | jvm 1 | 2021/09/09 15:44:57 | I [myLogger] [13:44:57]: (\<type ‘java.lang.Exception’\>, java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO files (filename, filedata) VALUES(?, CONVERT(varbinary(MAX), ?)), [normal.json, [B@63cadafa], MSSQL, , false, false), \<traceback object at 0x5\>) view=z\_Example/Apps/native-app@C, project-name=IgnitionTPM\_POC, component=root/Native Applications/Small/File Upload/FileUpload

in the gateway logs there is no + sign next to this line

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 9, 2021, 1:52pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepupdate-throws-java-lang-exception/50762/4 "2021-09-09T13:52:05Z")

</div>

What happens if you run `system.db.runPrepUpdate(query,args,"Test")` in script console? You should get a full stack trace then. Run it without a try/except.
