What is RSS?
Re: Problems with Timestamp and Function Calls in JDBC/Prepared
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > PostgreSQL database development > Re: Problems with Timestamp and Function Calls in JDBC/Prepared 22 April 2006 00:16:46

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Re: Problems with Timestamp and Function Calls in JDBC/Prepared

Kris Jurka 22 April 2006 00:16:46
 

On Fri, 21 Apr 2006, tarabas@tarabas.de wrote:
I am having a bit trouble with function-calls containing timestamps.>
CREATE OR REPLACE FUNCTION do_something(int8, int8, int8, int8,> timestamptz, timestamptz, timestamptz, timestamptz, int8, timestamptz,> "varchar", int8, int8, "numeric", int8, int8)> RETURNS int8 AS>
When I now try to call the function through the JDBC 8.1-405 JDBC 3> with a prepared Statement I do this:>
ps.setDouble(14, param14);

I belive this line is actually your problem, not the timestamps. Your
function is declared to take numeric, so you should ps.setBigDecimal() to
get that type. setDouble implies a float8 type which does not work...

CREATE FUNCTION f(numeric) RETURNS int AS 'SELECT 1;' LANGUAGE sql;
SELECT f(1::float8);
ERROR: function f(double precision) does not exist

The odd thing is that when I do a setTimestamp() and the param is null,> the type timestamp seems to be used correctly (it is set to 1184). But> when the Timestamp is filled, the type is set to 0 in the prepared> statement.

When passing timestamp values to the server the JDBC driver must leave
them as an unresolved type because it does not know if it is a timestamp
or timestamptz. This is not an issue with a null value because in that
case the conversion between timestamp and timestamptz cannot alter the
value, so we can give the server a hint about the type involved.

Kris Jurka

-------------------­--------(end of broadcast)---------­------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Add comment
Guest 22 April 2006 00:16:46 permanent link ]
 Hi Kris,

you were right, it seems i was assuming that the Timestamps were the
problem because of the, from my side unexpected, behaviour.

Changing the setDouble to setBigDecimal worked fine for me.

Thanks a lot for the hint.

Manuel


-------------------­--------(end of broadcast)---------­------------------
TIP 2: Don't 'kill -9' the postmaster

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > PostgreSQL database development > Re: Problems with Timestamp and Function Calls in JDBC/Prepared 22 April 2006 00:16:46

see also:
Getting scrollbar line position from…
select box - using refresh to select…
Alternatives to body onload not working
пройди тесты:
see also:
Free Article Directory
everything for beuty
php script

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .