import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
+import java.io.*;
/*
- * $Id: MiscTest.java,v 1.10 2003/05/29 04:39:48 barry Exp $
+ * $Id: MiscTest.java,v 1.10.4.1 2003/12/11 03:59:37 davec Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
fail( "Should not execute this, as a SQLException s/b thrown" );
con.commit();
}
- catch ( Exception ex )
- {}
+ catch ( SQLException ex )
+ {
+ // Verify that the SQLException is serializable.
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(ex);
+ oos.close();
+ } catch (IOException ioe) {
+ fail(ioe.getMessage());
+ }
+ }
try
{
con.commit();
catch ( Exception ex)
{}
}
+ public void testLastOID()
+ {
+ Connection con = null;
+ try
+ {
+ con = TestUtil.openDB();
+ TestUtil.createTable( con, "testoid","id int");
+ Statement stmt = con.createStatement();
+ con.setAutoCommit(false);
+ stmt.executeUpdate( "insert into testoid values (1)" );
+ con.commit();
+ long insertedOid = ((org.postgresql.PGStatement)stmt).getLastOID();
+ con.setAutoCommit(true);
+ TestUtil.dropTable( con, "testoid");
+ }
+ catch ( Exception ex )
+ {
+ fail( ex.getMessage() );
+ }
+ finally
+ {
+ try{if (con !=null )con.close();}catch(Exception ex){}
+ }
+ }
public void xtestLocking()
{