ihadanny
ihadanny

Reputation: 4483

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 "-02-01"

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

Upvotes: 2

Views: 1115

Answers (1)

ihadanny
ihadanny

Reputation: 4483

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.

Upvotes: 2

Related Questions