anyone know why this is failing - Mailing list pgsql-jdbc

From Dave Cramer
Subject anyone know why this is failing
Date
Msg-id 1076463584.16154.239.camel@localhost.localdomain
Whole thread Raw
Responses Re: anyone know why this is failing  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
The following code fails at the getObject(1)

Dave

package org.postgresql.test.jdbc2;

import org.postgresql.test.TestUtil;
import java.util.Calendar;
import junit.framework.*;
import java.sql.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class GetXXXTest extends TestCase
{
  Connection con = null;

  public GetXXXTest(String name )
  {
    super(name);
  }
  protected void setUp() throws Exception
  {
    super.setUp();

    con = TestUtil.openDB();
    TestUtil.createTempTable(con, "test_interval", "initial timestamp
with time zone, final timestamp with time zone");

  }

  protected void tearDown() throws Exception
  {
    super.tearDown();
    con.close();
  }

  public void testGetObject() throws SQLException
  {
    PreparedStatement pstmt = con.prepareStatement("insert into
test_interval values (?,?)");
    Calendar cal = Calendar.getInstance();
    cal.add( Calendar.DAY_OF_YEAR, -1 );

    pstmt.setTimestamp(1, new Timestamp( cal.getTimeInMillis()));
    pstmt.setTimestamp(2, new Timestamp( System.currentTimeMillis() ));
    assertTrue(pstmt.executeUpdate() == 1);
    ResultSet rs = pstmt.executeQuery("select (final-initial) as diff
from test_interval");
    while (rs.next() )
    {
      String str = (String)rs.getString(1);

      assertNotNull(str);
      str = (String)rs.getObject(1);
      assertNotNull(str);
    }
  }

}
--
Dave Cramer
519 939 0336
ICQ # 14675561


pgsql-jdbc by date:

Previous
From: "Riccardo Castagnoli"
Date:
Subject: unsubscribe
Next
From: wsmeyer@ibest.com.br
Date:
Subject: unsubscribe