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

From rob stone
Subject Re: "could not determine data type of parameter" with timestamp
Date
Msg-id 1512505335.4814.5.camel@gmail.com
Whole thread Raw
In response to "could not determine data type of parameter" with timestamp  (Rémi Aubel <remi.aubel@gmail.com>)
Responses Re: "could not determine data type of parameter" with timestamp  (Rémi Aubel <remi.aubel@gmail.com>)
List pgsql-jdbc

On Tue, 2017-12-05 at 15:11 +0000, Rémi Aubel wrote:
> Hello,
> 
> 
> 
> 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. 
> 
> 

Hi Rémi,

After creating the Prepared Statement you can do a
ResultSetMetaData.getMetaData() which returns an object containing the
data types of the columns in your select list.
Then for each column in your "where" clause you can obtain its data
type and then do setLong, setString, setTimeStamp or whatever,
according to its type. Then do the "execute" to obtain the actual
result set.

HTH,
Rob 


pgsql-jdbc by date:

Previous
From: Rémi Aubel
Date:
Subject: "could not determine data type of parameter" with timestamp
Next
From: Rémi Aubel
Date:
Subject: Re: "could not determine data type of parameter" with timestamp