Traceback (most recent call last):
File "UcanaccessPreparedStatement.java", line 685, in net.ucanaccess.jdbc.UcanaccessPreparedStatement.setObject
Exception: Java Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/gord/venv/df_write.py", line 91, in <module>
crsr.execute("INSERT INTO my_table (varchar_col) VALUES (?)", (None,))
File "/home/gord/git/jaydebeapi/jaydebeapi/__init__.py", line 532, in execute
self._set_stmt_parms(self._prep, parameters)
File "/home/gord/git/jaydebeapi/jaydebeapi/__init__.py", line 523, in _set_stmt_parms
prep_stmt.setObject(i + 1, parameters[i])
java.lang.java.lang.NullPointerException: java.lang.NullPointerException
Fix:
@@ -519,8 +519,10 @@ class Cursor(object):
def _set_stmt_parms(self, prep_stmt, parameters):
for i in range(len(parameters)):
- # print (i, parameters[i], type(parameters[i]))
- prep_stmt.setObject(i + 1, parameters[i])
+ if parameters[i] is None:
+ prep_stmt.setNull(i + 1, 0) # java.sql.Types.Null
+ else:
+ prep_stmt.setObject(i + 1, parameters[i])
def execute(self, operation, parameters=None):
if self._connection._closed:
(Similar issue to #57.)
Passing
None
as a parameter value when using the UCanAccess JDBC driverthrows
Fix: