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

Unable to bind a null value typed as a UUID in a PreparedStatement #1161

Closed
raubel opened this Issue Mar 28, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@raubel
Copy link

raubel commented Mar 28, 2018

I need to bind a UUID parameter which may be null in a statement like "select * from test table where ? is null or ? = c_uuid".
Whatever approach I use, the driver rejects my request with "ERROR: could not determine data type of parameter $1".

See the code here.

When run, it gives the output below:

JDBC Driver Version: 42.2.1
PostgreSQL version: PostgreSQL 9.5.9 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609, 64-bit
setNull(varchar) + setObject(null) => works
setNull(other) + setNull(other) => fails (ERROR: could not determine data type of parameter $1)
setNull(other, uuid) + setNull(other, uuid) => fails (ERROR: could not determine data type of parameter $1)

The third case (last line above) uses method PreparedStatement.setNull(pos, type, typeName) and should work.
But in the current implementation of the driver, the PreparedStatement.setNull(int, int, String) delegates to setNull(int, int) so that specifying the type name has no effect.

Thank you.

@davecramer

This comment has been minimized.

Copy link
Member

davecramer commented Mar 28, 2018

duplicate of #1159 fixed in #1160

@davecramer davecramer closed this Mar 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.