Re: Bad Timestamp Format

From: "Thomas O'Dowd" <tom(at)nooper(dot)com>
To: Gunaseelan Nagarajan <gnagarajan(at)dkf(dot)de>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bad Timestamp Format
Date: 2002-01-28 01:29:39
Message-ID: 20020128102939.J8130@beast.uwillsee.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Hi Nagarajan,

I'm not familiar with jboss, but I just tried messing with an old
7.1.2 database that I had lying around and can't get it to return
a short format of a timestamp like "1970-1-1 0:0". The driver
code in 7.1.3 will cause an exception for this short form as you
are getting and the 7.2 driver will just parse the datepart but
not the hour/minute part.

Before changing the new driver code to handle this format, I'd
like to know how you are generating it, so that a) I know it makes
sense to support it and b) that I can test it. Can anyone on the
list let me know how to get the backend to return this short format?

The only way I can think about doing it is using the to_char()
functions which you would have to be explicitly doing??? ie, something
like:

select now(), to_char(now(), 'YYYY-FMMM-FMDD FMHH24:FMMI');
now | to_char
------------------------+-----------------
2002-01-28 10:26:09+09 | 2002-1-28 10:26
(1 row)

If your select code or jboss is somehow using to_char() to alter the
default timestamp string, its doing something unusual which the driver
doesn't support.

Can anyone add anymore reasons why the backend would be returning
a short timestamp string to the driver, such as specific datestyle
options, a specific locale or other?

Tom.

On Sun, Jan 27, 2002 at 03:22:58PM +0100, Gunaseelan Nagarajan wrote:
> Hi Tom,
>
> I am using PostgreSQL 7.1.3. It was built from the source file
> by using ./configure --with-java etc. I used the jdbc source that comes
> along with the source and did not download it seperately.
>
> Here is my java environment.
> JDK 1.3.10
> JBoss 2.4
>
> I use the following code for inserting the date value
>
> public String giveInsert(Calendar cal)
> throws Exception{
> String colValue = "";
> colValue = "'" + cal.get(Calendar.YEAR) + "-"
> + ( cal.get( Calendar.MONTH ) + 1 ) + "-"
> + cal.get(Calendar.DAY_OF_MONTH) + " "
> + cal.get( Calendar.HOUR_OF_DAY ) + ":"
> + cal.get( Calendar.MINUTE ) + "'";
>
> return colValue;
> }
>
> For retreiving from the database, I use the following code
>
> public Calendar takeFromResultSet(ResultSet rs, String columnName)
> throws SQLException, Exception{
> Timestamp ts = rs.getTimestamp(columnName);
> Calendar c = Calendar.getInstance();
> if(ts != null)
> c.set(ts.getYear()+1900, ts.getMonth(), ts.getDate(),
> ts.getHours(),ts.getMinutes());
> else
> c = null;
> return c;
> }
>
> The database connection comes through the JBoss connection pool handler.
> Maybe that is not setting the required database property?
>
> here is the configuration settings in jboss.jcml
>
> <mbean code="org.jboss.jdbc.XADataSourceLoader"
> name="DefaultDomain:service=XADataSource,name=postgresqlDS">
> <attribute
> name="DataSourceClass">org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl</attribute>
> <attribute name="PoolName">postgresqlDS</attribute>
> <attribute name="URL">jdbc:postgresql:db</attribute>
> <attribute name="JDBCUser">root</attribute>
> <attribute name="Password">japan</attribute>
> </mbean>
>
>
> To get the database connection, I use the following code
>
> cat.debug("Using jboss pool to get Connection");
> Context ctx = new InitialContext();
> javax.sql.DataSource ds =(javax.sql.DataSource)ctx.lookup( jndiName );
> con = ds.getConnection();
>
> Thanks and Regards,
> Nagarajan.
>
> On Saturday 26 January 2002 14:33, you wrote:
> > hi,
> > I get the following error while retrieving a datetime column using
> > getTimestamp.
> >
> > Bad Timestamp Format at 12 in 1970-1-1 0:0;
> >
> >
> > Bad Timestamp Format at 12 in 1970-1-1 0:0
> > at org.postgresql.jdbc2.ResultSet.getTimestamp(Unknown Source)
> > at org.postgresql.jdbc2.ResultSet.getTimestamp(Unknown Source)
> > at
> > org.jboss.pool.jdbc.ResultSetInPool.getTimestamp(ResultSetInPool.java:734)
> >
> > regards,
> > Nagarajan.
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Thomas O'Dowd. - Nooping - http://nooper.com
tom(at)nooper(dot)com - Testing - http://nooper.co.jp/labs

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2002-01-28 01:33:05 Re: RFD: schemas and different kinds of Postgres objects
Previous Message Peter Eisentraut 2002-01-27 16:02:33 Re: pltcl build problem on FreeBSD (was: Re: pltlc and

Browse pgsql-jdbc by date

  From Date Subject
Next Message G.Nagarajan 2002-01-28 08:33:10 Re: Bad Timestamp Format
Previous Message Gunaseelan Nagarajan 2002-01-27 14:22:58 Re: Bad Timestamp Format