From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Mike Cannon-Brookes <mcannon(at)internet(dot)com> |
Cc: | "Pgsql-Interfaces(at)Postgresql(dot) Org" <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | Re: JDBC date problem |
Date: | 2001-01-12 04:31:12 |
Message-ID: | 200101120431.XAA25477@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Would you please send me a context diff (diff -c) comparing the two
versions? Thanks.
> Actually I've been playing around more and there's some cases left out of
> the driver. I hacked it to put them in and it works much better now. (Was
> giving Bad Timestamp exceptions).
>
> I've attached the hacked / fixed ResultSet.java file as I have no CVS
> access, would some kind soul with access patch it? I've marked my changes
> clearly with comments in the getTimestamp() method.
>
> Hope this helps!
>
> Mike
>
> > -----Original Message-----
> > From: pgsql-interfaces-owner(at)postgresql(dot)org
> > [mailto:pgsql-interfaces-owner(at)postgresql(dot)org]On Behalf Of Mike
> > Cannon-Brookes
> > Sent: Thursday, January 11, 2001 12:20 AM
> > To: Pgsql-Interfaces(at)Postgresql(dot) Org
> > Subject: RE: [INTERFACES] JDBC date problem
> >
> >
> > For reference, I just updated my CVS tree and recompiled using Ant and the
> > new jar works much better. It must be a bug in the old jar (ResultSet.java
> > was indeed updated with your patch Michael).
> >
> > Thanks for the tip!
> > Mike
> >
> > PS For anyone interested, org.postgresql.xa.Test has a serious bug in it,
> > tries to instantiate an interface (XADataSource) - someone might want to
> > hack at it. (just comment out the method and recompile if you
> > care not about
> > testing ;))
> >
> > > -----Original Message-----
> > > From: pgsql-interfaces-owner(at)postgresql(dot)org
> > > [mailto:pgsql-interfaces-owner(at)postgresql(dot)org]On Behalf Of Michael
> > > Stephenson
> > > Sent: Wednesday, January 10, 2001 8:42 PM
> > > To: Pgsql-Interfaces(at)Postgresql(dot) Org
> > > Subject: Re: [INTERFACES] JDBC date problem
> > >
> > >
> > > > Any ideas? This is a real stumper and I need to find a solution
> > > asap! I'm
> > > > using a JDBC driver I built from CVS no more than a month ago.
> > >
> > > The results look to me like that in org.postgresql.jdbc2.ResultSet
> > > 'mm' and 'MM' have been confused (I know that this was the case
> > in a patch
> > > I submitted), try replacing getTimeStamp() with:
> > >
> > > public Timestamp getTimestamp(int columnIndex) throws SQLException
> > > {
> > > String s = getString(columnIndex);
> > > if(s==null)
> > > return null;
> > >
> > > SimpleDateFormat df = null;
> > > if (s.length()>21 && s.indexOf('.') != -1) {
> > > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz");
> > > } else if (s.length()>19 && s.indexOf('.') == -1) {
> > > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzz");
> > > } else if (s.length()>19 && s.indexOf('.') != -1) {
> > > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS");
> > > } else if (s.length()>10 && s.length()<=18) {
> > > df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> > > } else {
> > > df = new SimpleDateFormat("yyyy-MM-dd");
> > > }
> > >
> > > try {
> > > return new Timestamp(df.parse(s).getTime());
> > > } catch(ParseException e) {
> > > throw new PSQLException("postgresql.res.badtimestamp",new
> > > Integer(e.getErrorOffset()),s);
> > > }
> > > }
> > >
> > > Michael Stephenson
> > >
> > >
> > >
> >
> >
[ Attachment, skipping... ]
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Howe | 2001-01-12 04:34:57 | Must implement PQnotifyFree() |
Previous Message | Joel Burton | 2001-01-11 15:42:40 | Re: [SQL] connecting to postgres server from Access |