Re: Could not determine data type of parameter $1
От | Kris Jurka |
---|---|
Тема | Re: Could not determine data type of parameter $1 |
Дата | |
Msg-id | Pine.BSO.4.63.0608292151450.28706@leary2.csoft.net обсуждение исходный текст |
Ответ на | Could not determine data type of parameter $1 (Vincent Risi <vince@bbd.co.za>) |
Ответы |
Re: Could not determine data type of parameter $1
|
Список | pgsql-jdbc |
On Fri, 25 Aug 2006, Vincent Risi wrote: > //////////////////////////// > > Using the version of the jbdc drive (postgresql-8.1dev-400.jdbc3.jar) > instead of (postgresql-8.1-407.jdbc3.jar) the code below works. I would > like to know if the code is valid or if the driver has a problem. It > fails at > > [ > PreparedStatement ps = conn.prepareStatement("SELECT ?"); > ps.setTimestamp(1, new Timestamp(0)); > ResultSet rs = ps.executeQuery(); > ] > When given a timestamp parameter the jdbc driver does not know if it is going to be used a timestamp with time zone or a timestamp without time zone. The driver passes it to the server as an unknown data type letting the server figure out what to do with it. Usually you'll have timestampcol = ? or you're inserting into a timestamp field so the server can easily determine the true datatype the parameter is being used at. In this case since it's just being sent back to the user the server cannot determine the type and bails out. You need to help it along with a cast: "SELECT ?::timestamptz". Kris Jurka
В списке pgsql-jdbc по дате отправления: