2 Replies Latest reply on Jan 29, 2002 4:02 AM by jboss_naga

    Postgres Bad Timestamp Format at 12 in 1970-1-1 0:0

    jboss_naga

      I am using JBoss 2.4.1 with Postgres 7.3.1. The following error occurs when I try to retrieve a datetime column using rs.getTimeStamp..


      > 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)

      The code>>


      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;
      }

      Nagarajan.