"could not determine data type of parameter" with timestamp - Mailing list pgsql-jdbc

From Rémi Aubel
Subject "could not determine data type of parameter" with timestamp
Date
Msg-id CAG2M1febgZbhBwm0DQK4Y5ekDrTbzTyAa1syKcdXw+6Y8caK4g@mail.gmail.com
Whole thread Raw
Responses Re: "could not determine data type of parameter" with timestamp  (rob stone <floriparob@gmail.com>)
Re: "could not determine data type of parameter" with timestamp  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-jdbc
Hello,

I know my problem has already been answered in this list (https://www.postgresql.org/message-id/CA%2BxsaB0EMDaNek0Oky9c17_8UX3-epWVP11%2BvTNgrAPoY2s9FA%40mail.gmail.com), but it was a long time ago and I would like to know if any other solution exists now.

I need to execute this PreparedStatement:
select * from my_table where ? is null
with a bound parameter of type Timestamp.

With this form, the driver (version 42.1.4) raises this exception:
org.postgresql.util.PSQLException: ERROR: could not determine data type of parameter $1

Note: I have the same exception if the bound parameter is null. The PreparedStatement should result in
select * from my_table where null is null
which is correct SQL.

The solution given 4 years ago was to explicitly cast the parameter as a timestamp (select * from my_table where ?::timestamp is null).
But this workaround is not really useful for me, because my application uses generated (dynamic) queries and targets multiple database types (not only PosgreSQL). So, when I know the targeted database, I do not know my parameter types anymore.

Any suggestion?

Thanks in advance.

Rémi. 

--


pgsql-jdbc by date:

Previous
From: Jorge Solorzano
Date:
Subject: [pgjdbc/pgjdbc] 405f14: drop old and unused crypt auth (#1026)
Next
From: rob stone
Date:
Subject: Re: "could not determine data type of parameter" with timestamp