heavyai / heavyai-jdbc

A JDBC driver for connecting to an HeavyAI GPU database and running queries.
https://www.heavy.ai/
Other
9 stars 16 forks source link

PreparedStatement addBatch insert NULL into POINT column #27

Open ediril opened 4 years ago

ediril commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Thanks for the precious info; I will take a look into issue (when I will back to home)

Ottieni Outlook per Androidhttps://aka.ms/ghei36


From: Emrah Diril notifications@github.com Sent: Wednesday, July 29, 2020 8:12:16 AM To: omnisci/omnisci-jdbc omnisci-jdbc@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [omnisci/omnisci-jdbc] PreparedStatement addBatch insert NULL into POINT column (#27)

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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/omnisci/omnisci-jdbc/issues/27#issuecomment-665454200, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHLFBF4X3TJL62Z373PQGRTR564UBANCNFSM4PLHRMAA.

ediril commented 4 years ago

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.