Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error inserting None as Nulls using parameter in Teradata #57

Open
r-richmond opened this issue Oct 4, 2017 · 1 comment · May be fixed by #87 or #245
Open

error inserting None as Nulls using parameter in Teradata #57

r-richmond opened this issue Oct 4, 2017 · 1 comment · May be fixed by #87 or #245

Comments

@r-richmond
Copy link

I receiving the following error message

File "/usr/local/lib/python3.6/site-packages/jaydebeapi/__init__.py", line 499, in execute
  self._set_stmt_parms(self._prep, parameters)
File "/usr/local/lib/python3.6/site-packages/jaydebeapi/__init__.py", line 490, in _set_stmt_parms
  prep_stmt.setObject(i + 1, parameters[i])

jpype._jexception.SQLExceptionPyRaisable: java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 16.10.00.03] [Error 1063] [SQLState HY000] null is not supported as a data value with this variant of the setObject method; use the setNull method or the setObject method with a targetSqlType parameter

when running the following code

sql = "insert into table (col1, col2) values (?, ?)"
row = (None,'name',)
cur.execute(sql, parameters=row)
@r-richmond
Copy link
Author

r-richmond commented Oct 4, 2017

seems like the suggestion here is the fix but i'm not super familiar with java

stmt.SetNull(i,Types.NULL)

also found this

Let's assume you have an Object with a null value in your application:
Object obj = null ;
The error message is indicating that your application cannot use the PreparedStatement.setObject(int,Object) method to bind the null value:
PreparedStatement ps = con.prepareStatement ... ;
ps.setObject(1, obj) ; // will throw exception if obj is null
Instead, your application must specify the data type of the null value using one or the other of these methods:
ps.setObject(1, obj, Types.VARCHAR) ; // or some other java.sql.Types constant
// or
ps.setNull(1, Types.VARCHAR) ; // or some other java.sql.Types constant
The Teradata Database requires the data type to be specified for a NULL value, so the Teradata JDBC Driver, in turn, must require the application to specify the java.sql.Types constant for a null value.

@Spasnof Spasnof linked a pull request Nov 6, 2018 that will close this issue
gordthompson added a commit to gordthompson/jaydebeapi that referenced this issue May 12, 2024
@gordthompson gordthompson linked a pull request May 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant