Thread: Found a problem with 8.2-508 JDBC 4
PostgreSQL: 8.2.4
JDK: 1.6.0_07
JDBC Driver: 8.2-508 JDBC4
I have found a problem with 8.2-508 JDBC 4. I can recreate the problem every time.
Summary of problem:
When the below SQL is executed the result set returns the value of “null” for the field “calendar_name”. When I use driver “8.2-506 JDBC 4” and “8.2-507 JDBC 4” it work correctly and I get a valid value.
SQL that returns a “null” in 508 but not in 506 and 507 for the field “calendar_name”:
SELECT to_char(event.start_timestamp, 'Mon FMDD, YYYY') AS start_date,
to_char(event.end_timestamp, 'Mon FMDD, YYYY') AS end_date,
to_char(event.start_timestamp, 'FMHH:MI am') AS start_time,
to_char(event.end_timestamp, 'FMHH:MI am') AS end_time,
to_char(event.news_letter_timestamp, 'YYYYMMDD') AS news_letter_date,
to_char(event.news_letter_timestamp, 'FMHHMISS') AS news_letter_time,
to_char(last_updated_timestamp, 'MM/DD/YYYY') AS last_updated_date,
to_char(event.created_timestamp, 'MM/DD/YYYY') AS created_date,
event.*,
calendar.name as calendar_name
FROM calendar.event, calendar.calendar
WHERE event.id=? AND event.fk_calendar_id=calendar.id
When I rearrange the following SQL, driver 508 will return a non “null” value for calendar_name. Both the above and below SQL work with 506 and 507:
SELECT to_char(event.start_timestamp, 'Mon FMDD, YYYY') AS start_date,
to_char(event.end_timestamp, 'Mon FMDD, YYYY') AS end_date,
to_char(event.start_timestamp, 'FMHH:MI am') AS start_time,
to_char(event.end_timestamp, 'FMHH:MI am') AS end_time,
to_char(event.news_letter_timestamp, 'YYYYMMDD') AS news_letter_date,
to_char(event.news_letter_timestamp, 'FMHHMISS') AS news_letter_time,
to_char(last_updated_timestamp, 'MM/DD/YYYY') AS last_updated_date,
to_char(event.created_timestamp, 'MM/DD/YYYY') AS created_date,
calendar.name as calendar_name,
event.*
FROM calendar.event, calendar.calendar
WHERE event.id=? AND event.fk_calendar_id=calendar.id
Thanks,
Lance Campbell
Project Manager/Software Architect
Web Services at Public Affairs
University of Illinois
217.333.0382
On Thu, 11 Sep 2008, Campbell, Lance wrote: > When the below SQL is executed the result set returns the value of > "null" for the field "calendar_name". When I use driver "8.2-506 JDBC > 4" and "8.2-507 JDBC 4" it work correctly and I get a valid value. > > SELECT ..., > event.*, > calendar.name as calendar_name Evidently event.* contains a field called calendar name and you're getting bitten by this change (from the 508 changelog): The JDBC spec says that when you have two duplicately named columns in a ResultSet, a search by name should return the first one. Previously our code was returning the second match. (jurka) Thanks to Magne Mahre. Kris Jurka
Kris, Thank you very much for identifying this. I even found that I had a problem with my data model because of this issue. Thanks, Lance -----Original Message----- From: Kris Jurka [mailto:books@ejurka.com] Sent: Thursday, September 11, 2008 12:19 PM To: Campbell, Lance Cc: pgsql-jdbc@postgresql.org Subject: Re: [JDBC] Found a problem with 8.2-508 JDBC 4 On Thu, 11 Sep 2008, Campbell, Lance wrote: > When the below SQL is executed the result set returns the value of > "null" for the field "calendar_name". When I use driver "8.2-506 JDBC > 4" and "8.2-507 JDBC 4" it work correctly and I get a valid value. > > SELECT ..., > event.*, > calendar.name as calendar_name Evidently event.* contains a field called calendar name and you're getting bitten by this change (from the 508 changelog): The JDBC spec says that when you have two duplicately named columns in a ResultSet, a search by name should return the first one. Previously our code was returning the second match. (jurka) Thanks to Magne Mahre. Kris Jurka