Re: Patch for JDBC timestamp problems

From: Richard Bullington-McGuire <rbulling(at)microstate(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Re: Patch for JDBC timestamp problems
Date: 2001-01-17 23:30:59
Message-ID: Pine.LNX.4.10.10101171823180.27489-100000@polymorphic.microstate.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


I've been reading the recent patch messages for issues related to the JDBC
driver, and I read this notice:

> In fixing the above two bugs, I noticed some things that could be
> improved. In PreparedStatement.setTimestamp(),
> PreparedStatement.setDate(), ResultSet.getTimestamp(), and
> ResultSet.getDate() these methods were creating a new SimpleDateFormat
> object everytime they were called. To avoid this unnecessary object
> creation overhead, I changed the code to use static variables for
> keeping a single instance of the needed formating objects.

In fact, the SimpleDateFormat class is not threadsafe, and you do need to
instantiate a new SimpleDateFormat for each pass through the thread. It is
more efficient to have a static instance; unfortunately, it is not
correct. It is desirable to centralize the creation of each type of
DateFormat, but the way to do it is a series of getMyDateFormat() calls
that instantiate a new instance of the variety of SimpleDateFormat you
want to get.

See
<http://developer.java.sun.com/developer/bugParade/bugs/4093418.html> for
details (this requires registration with the Sun Developer Connection).

--
Richard Bullington-McGuire <rbulling(at)microstate(dot)com>
Chief Technology Officer, The Microstate Corporation
Phone: 703-796-6446 URL: http://www.microstate.com/
PGP key IDs: RSA: 0x93862305 DH/DSS: 0xDAC3028E

Browse pgsql-patches by date

  From Date Subject
Next Message Gunnar R|nning 2001-01-18 13:49:23 Re: Fixes and enhancements to JDBC driver (take 2)
Previous Message Bruce Momjian 2001-01-17 22:15:38 Re: docs: syntax.sgml patch