开发者

Passing java.sql.date to netezza jdbc driver

When passing a Java.Sql.Date as a bind variable (a question mark in my query text) in a PreparedStatement to nzjdbc.jar, I'm getting:

pg_atoi: error in "2010-02-01": can't parse开发者_如何学C "-02-01"

what gives? I thought that the whole purpose of a JDBC driver is to fix such issues :(


Ok, found the answer, not related to JDBC.

When passing a date variable to JDBC, all it does is translate it to a literal string fitting the Netezza dateStyle, e.g. '2011-11-06 00:00:00'. It does not wrap it with a cast or to_date or anything.

However, when you try select '2011-11-06 00:00:00' - 30 from any Netezza client, you get a pg-atoi parse error, as Netezza tries to parse the string as a number, not as a date.

Solution: select cast('2004-02-22 00:00:00.000' as date) - 30 as bla;

its all cosmic love baby.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜