| From: | Dave Cramer <pg(at)fastcrypt(dot)com> | 
|---|---|
| To: | "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org> | 
| Subject: | anyone know why this is failing | 
| Date: | 2004-02-11 01:39:45 | 
| Message-ID: | 1076463584.16154.239.camel@localhost.localdomain | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | wsmeyer | 2004-02-11 02:05:03 | unsubscribe | 
| Previous Message | Riccardo Castagnoli | 2004-02-10 22:32:31 | unsubscribe |