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

PreparedStatement addBatch insert NULL into POINT column #27

Open
ediril opened this issue Jul 29, 2020 · 3 comments
Open

PreparedStatement addBatch insert NULL into POINT column #27

ediril opened this issue Jul 29, 2020 · 3 comments

Comments

@ediril
Copy link

ediril commented Jul 29, 2020

I have a table with several columns one of which is a defined as FrameCenter GEOMETRY(POINT, 4326) so it's nullable. For some rows, I'd like to insert a NULL into this column. I'm using addBatch and executeBatch methods. I tried calling setNull with all combinations of java.sql.Types. I also tried setString with empty string as value, but didn't work. I don't get an error when I call executeBatch but my row does not get inserted into the table either.

I also tried INSERT with named columns leaving out the column I'd like to insert a NULL but that didn't work either. executeBatch knows the full list of columns and gave me this error: executeBatch failed: Exception: TException - service has thrown: TOmniSciException(error_msg=Wrong number of columns to load into Table (4 vs 7))

So how do I insert a NULL to a Geometry Point column?

@ediril
Copy link
Author

ediril commented Jul 29, 2020

Btw, setNull with VARCHAR using execute (instead of addBatch and executeBatch) works if that helps. But I need it to work with addBatch and executeBatch.

@cdessanti
Copy link
Contributor

cdessanti commented Jul 29, 2020 via email

@ediril
Copy link
Author

ediril commented Jul 29, 2020

Thank you!

One easy way to reproduce this problem is to modify OmniSciGeomTest.tst2_geometry and replace the first ps.setString line with ps.setNull(1, Types.VARCHAR);. The test will still pass, but you'll notice the resultset from statement.executeQuery(sql_select_geom) is empty since the row never got created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants