Patches submitted by Kris Jurka ([email protected]) for the following bugs:
authorBarry Lind
Wed, 11 Sep 2002 05:38:45 +0000 (05:38 +0000)
committerBarry Lind
Wed, 11 Sep 2002 05:38:45 +0000 (05:38 +0000)
  - Properly drop tables in jdbc regression tests with cascade for 7.3
  - problem with Statement.execute() and executeUpdate() not clearing binds
  - problem with ResultSet not correctly handling default encoding
  - changes to correctly support show transaction isolation level in 7.3
  - changed DatabaseMetaDataTest to handle differences in FK names in 7.3
  - better fix for dynamically checking server NAME data length
  (With the fixes above the jdbc regression tests pass on jdbc2 and jdbc3
   against both a 7.2 and 7.3 server)
Patchs submitted by David Wall ([email protected]):
  - problem with getBlob when largeobject oid is null
  - improvements to BlobOutputStream
Patch submitted by Haris Peco ([email protected]):
  - problem with callable statement not supporting prepared statement methods

 Modified Files:
  jdbc/org/postgresql/Driver.java.in
  jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
  jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
  jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
  jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
  jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
  jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
  jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
  jdbc/org/postgresql/largeobject/BlobOutputStream.java
  jdbc/org/postgresql/largeobject/LargeObject.java
  jdbc/org/postgresql/test/TestUtil.java
  jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
  jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
  jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
  jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
  jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java

16 files changed:
src/interfaces/jdbc/org/postgresql/Driver.java.in
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
src/interfaces/jdbc/org/postgresql/largeobject/BlobOutputStream.java
src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java
src/interfaces/jdbc/org/postgresql/test/TestUtil.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java

index 019a78dbebcbefcdd2c9daf821bb351dfbe9daff..328c06ce6b969c5771eae916ad9dd3fc15bff3f8 100644 (file)
@@ -446,6 +446,6 @@ public class Driver implements java.sql.Driver
    }
 
    //The build number should be incremented for every new build
-   private static int m_buildNumber = 104;
+   private static int m_buildNumber = 105;
 
 }
index 45160ba34fc6fecc5350ea56df0a524ecda5097a..bf4ee76bd74f790e55900b9606caf0d2fd0e5061 100644 (file)
@@ -14,7 +14,7 @@ import org.postgresql.largeobject.LargeObjectManager;
 import org.postgresql.util.*;
 
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.8 2002/09/06 21:23:05 momjian Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.9 2002/09/11 05:38:44 barry Exp $
  * This class defines methods of the jdbc1 specification.  This class is
  * extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
  * methods.  The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
@@ -982,21 +982,32 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
     */
    public int getTransactionIsolation() throws SQLException
    {
-       clearWarnings();
-       ExecSQL("show transaction isolation level");
-
-       SQLWarning warning = getWarnings();
-       if (warning != null)
-       {
-           String message = warning.getMessage();
+       String sql = "show transaction isolation level";
+       String level = null;
+       if (haveMinimumServerVersion("7.3")) {
+           ResultSet rs = ExecSQL(sql);
+           if (rs.next()) {
+               level = rs.getString(1);
+           }
+           rs.close();
+       } else {
            clearWarnings();
-           if (message.indexOf("READ COMMITTED") != -1)
+           ExecSQL(sql);
+           SQLWarning warning = getWarnings();
+           if (warning != null)
+           {
+               level = warning.getMessage();
+           }
+           clearWarnings();
+       }
+       if (level != null) {
+           if (level.indexOf("READ COMMITTED") != -1)
                return java.sql.Connection.TRANSACTION_READ_COMMITTED;
-           else if (message.indexOf("READ UNCOMMITTED") != -1)
+           else if (level.indexOf("READ UNCOMMITTED") != -1)
                return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
-           else if (message.indexOf("REPEATABLE READ") != -1)
+           else if (level.indexOf("REPEATABLE READ") != -1)
                return java.sql.Connection.TRANSACTION_REPEATABLE_READ;
-           else if (message.indexOf("SERIALIZABLE") != -1)
+           else if (level.indexOf("SERIALIZABLE") != -1)
                return java.sql.Connection.TRANSACTION_SERIALIZABLE;
        }
        return java.sql.Connection.TRANSACTION_READ_COMMITTED;
index 59958e592dce1133e3714a673390c5afabc5e2d2..cdf6e8073ec2d9eefbc5d0177cf977932a155874 100644 (file)
@@ -27,19 +27,28 @@ public abstract class AbstractJdbc1DatabaseMetaData
    protected static final int iInt2Oid = 21; // OID for int2
    protected static final int iInt4Oid = 23; // OID for int4
    protected static final int VARHDRSZ = 4;    // length for int4
-   protected static int NAME_SIZE = 64;    // length for name datatype
+   protected static int NAME_SIZE = 63;    // length for name datatype
 
    public AbstractJdbc1DatabaseMetaData(AbstractJdbc1Connection conn)
    {
        this.connection = conn;
+       String sql;
        try {
            if (connection.haveMinimumServerVersion("7.3")) {
-               NAME_SIZE = 64;
+               sql = "SELECT t.typlen FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n WHERE t.typnamespace=n.oid AND t.typname='name' AND n.nspname='pg_catalog'";
+               NAME_SIZE = 63;
            } else {
-               NAME_SIZE = 32;
+               sql = "SELECT typlen FROM pg_type WHERE typname='name'";
+               NAME_SIZE = 31;
            }
+           ResultSet rs = connection.createStatement().executeQuery(sql);
+           if (rs.next()) {
+               NAME_SIZE = rs.getInt("typlen") - 1;
+           }
+           rs.close();
        } catch (SQLException l_se) {
-           //leave value at default
+           // depending on the error the NAME_SIZE value will
+           // be the original or the value set before the query.
        }
    }
 
index 672d0eefc7a22a86482c74eeb0a00c0a7c70f612..e7e5d85d22675d33d61b0313b4a662ef11bc8734 100644 (file)
@@ -8,7 +8,7 @@ import java.util.Vector;
 import org.postgresql.largeobject.*;
 import org.postgresql.util.*;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.8 2002/09/08 00:15:29 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.9 2002/09/11 05:38:44 barry Exp $
  * This class defines methods of the jdbc1 specification.  This class is
  * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
  * methods.  The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -170,6 +170,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
    {
        String l_sql = replaceProcessing(p_sql);
        m_sqlFragments = new String[] {l_sql};
+       m_binds = new Object[0];
        //If we have already created a server prepared statement, we need
        //to deallocate the existing one
        if (m_statementName != null) {
@@ -213,6 +214,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
    {
        String l_sql = replaceProcessing(p_sql);
        m_sqlFragments = new String[] {l_sql};
+       m_binds = new Object[0];
        //If we have already created a server prepared statement, we need
        //to deallocate the existing one
        if (m_statementName != null) {
@@ -1775,6 +1777,12 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
     */
    private String modifyJdbcCall(String p_sql) throws SQLException
    {
+       //Check that this is actually a call which should start with a {
+        //if not do nothing and treat this as a standard prepared sql
+       if (!p_sql.trim().startsWith("{")) {
+           return p_sql;
+       }
+
        // syntax checking is not complete only a few basics :(
        originalSql = p_sql; // save for error msgs..
        String l_sql = p_sql;
index cc468ff50a13f5d5be4e25148bffd4168dcc64fd..de0266ae7d0060b6b05feb7708a1492b160f405f 100644 (file)
@@ -15,7 +15,7 @@ import org.postgresql.util.PGbytea;
 import org.postgresql.util.PSQLException;
 
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.7 2002/09/06 21:23:06 momjian Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.8 2002/09/11 05:38:45 barry Exp $
  * This class defines methods of the jdbc2 specification.  This class extends
  * org.postgresql.jdbc1.AbstractJdbc1ResultSet which provides the jdbc1
  * methods.  The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2ResultSet
@@ -1546,14 +1546,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
                case Types.REAL:
                case Types.TINYINT:
 
-                   try
-                   {
-                       rowBuffer[columnIndex] = String.valueOf( updateValues.get( columnName ) ).getBytes(connection.getEncoding().name() );
-                   }
-                   catch ( UnsupportedEncodingException ex)
-                   {
-                       throw new SQLException("Unsupported Encoding " + connection.getEncoding().name());
-                   }
+                   rowBuffer[columnIndex] = connection.getEncoding().encode(String.valueOf( updateValues.get( columnName ) ));
 
                case Types.NULL:
                    continue;
index 7debda09ba82ad4bd96f50ab9aa5d574a85600b5..b9e4f44ef1d538c5c9d718436911c8c40022f4c7 100644 (file)
@@ -8,7 +8,7 @@ import java.util.Vector;
 import org.postgresql.largeobject.*;
 import org.postgresql.util.PSQLException;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.6 2002/09/06 21:23:06 momjian Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.7 2002/09/11 05:38:45 barry Exp $
  * This class defines methods of the jdbc2 specification.  This class extends
  * org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1
  * methods.  The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Statement
@@ -187,16 +187,26 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra
            while (numRead != -1 && bytesRemaining > 0)
            {
                bytesRemaining -= numRead;
-               los.write(buf, 0, numRead);
+               if ( numRead == buf.length )
+                   los.write(buf); // saves a buffer creation and copy in LargeObject since it's full
+               else
+                   los.write(buf,0,numRead);
                numRead = l_inStream.read(buf, 0, Math.min(buf.length, bytesRemaining));
            }
-           los.close();
        }
        catch (IOException se)
        {
            throw new PSQLException("postgresql.unusual", se);
        }
-       // lob is closed by the stream so don't call lob.close()
+       finally
+       {
+           try
+           {
+               los.close();
+                l_inStream.close();
+            }
+            catch( Exception e ) {}
+       }
        setInt(i, oid);
    }
 
index 84e3a7b9e6b66c3ff10f0349818e18561a7d21d5..36e3aa048ecc704467997124b0868f50ea805b9f 100644 (file)
@@ -5,7 +5,7 @@ import java.sql.*;
 import java.util.Vector;
 import org.postgresql.Field;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.5 2002/09/06 21:23:06 momjian Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.6 2002/09/11 05:38:45 barry Exp $
  * This class implements the java.sql.ResultSet interface for JDBC2.
  * However most of the implementation is really done in
  * org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents
@@ -25,11 +25,19 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
 
    public java.sql.Clob getClob(int i) throws SQLException
    {
+       wasNullFlag = (this_row[i - 1] == null);
+       if (wasNullFlag)
+           return null;
+
        return new org.postgresql.jdbc2.Jdbc2Clob(connection, getInt(i));
    }
 
    public java.sql.Blob getBlob(int i) throws SQLException
    {
+       wasNullFlag = (this_row[i - 1] == null);
+       if (wasNullFlag)
+           return null;
+
        return new org.postgresql.jdbc2.Jdbc2Blob(connection, getInt(i));
    }
 
index c988127fe46519a350f9d4aa4527a3f26655b1e0..4e53404e8a955880c782e61cfdc2338fbc25f4e2 100644 (file)
@@ -5,7 +5,7 @@ import java.sql.*;
 import java.util.Vector;
 import org.postgresql.Field;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.2 2002/09/06 21:23:06 momjian Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.3 2002/09/11 05:38:45 barry Exp $
  * This class implements the java.sql.ResultSet interface for JDBC3.
  * However most of the implementation is really done in
  * org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents
@@ -25,11 +25,19 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
 
    public java.sql.Clob getClob(int i) throws SQLException
    {
+       wasNullFlag = (this_row[i - 1] == null);
+       if (wasNullFlag)
+           return null;
+
        return new Jdbc3Clob(connection, getInt(i));
    }
 
    public java.sql.Blob getBlob(int i) throws SQLException
    {
+       wasNullFlag = (this_row[i - 1] == null);
+       if (wasNullFlag)
+           return null;
+
        return new Jdbc3Blob(connection, getInt(i));
    }
 
index b56de6e5430e6679ced02599e479cabe8b4831f7..eb506b6771eb904e26d768cef32a64f8b4b51cf9 100644 (file)
@@ -68,6 +68,26 @@ public class BlobOutputStream extends OutputStream
        }
    }
 
+   public void write(byte[] buf, int off, int len) throws java.io.IOException
+   {
+       try
+           {
+               // If we have any internally buffered data, send it first
+               if ( bpos > 0 )
+                   flush();
+
+               if ( off == 0 && len == buf.length )
+                   lo.write(buf); // save a buffer creation and copy since full buffer written
+               else
+                   lo.write(buf,off,len);
+           }
+       catch (SQLException se)
+           {
+               throw new IOException(se.toString());
+           }
+   }
+
+
    /*
     * Flushes this output stream and forces any buffered output bytes
     * to be written out. The general contract of flush is
index 316716e42d0964386a482410fc06b288369b24b0..5455e8e7698bd30883c385d215e94d7ff52eaeee 100644 (file)
@@ -304,7 +304,7 @@ public class LargeObject
     */
    public InputStream getInputStream() throws SQLException
    {
-       return new BlobInputStream(this);
+       return new BlobInputStream(this, 4096);
    }
 
    /*
@@ -318,7 +318,7 @@ public class LargeObject
    public OutputStream getOutputStream() throws SQLException
    {
        if (os == null)
-           os = new BlobOutputStream(this);
+           os = new BlobOutputStream(this, 4096);
        return os;
    }
 
index a9f9dfdf3f41423ceb03475489b2e9c0dfe14af6..fc8dc70deb01fccc1e011f9910650fac634e89a8 100644 (file)
@@ -109,11 +109,26 @@ public class TestUtil
            Statement stmt = con.createStatement();
            try
            {
-               stmt.executeUpdate("DROP TABLE " + table);
+               String sql = "DROP TABLE " + table;
+               if (con instanceof org.postgresql.jdbc1.AbstractJdbc1Connection && ((org.postgresql.jdbc1.AbstractJdbc1Connection)con).haveMinimumServerVersion("7.3")) {
+                   sql += " CASCADE ";
+               }
+               stmt.executeUpdate(sql);
            }
            catch (SQLException ex)
            {
-               // ignore
+               // Since every create table issues a drop table
+               // it's easy to get a table doesn't exist error.
+               // we want to ignore these, but if we're in a
+               // transaction we need to restart.
+               // If the test case wants to catch this error
+               // itself it should issue the drop SQL directly.
+               if (ex.getMessage().indexOf("does not exist") != -1) {
+                   if (!con.getAutoCommit()) {
+                       con.rollback();
+                   }
+
+               }
            }
        }
        catch (SQLException ex)
index 87341925c5d5b99991a6baba45daf8eaff1a480f..0d1a962049a0e28d4165edb389030f856726e95e 100644 (file)
@@ -9,7 +9,7 @@ import java.sql.*;
  *
  * PS: Do you know how difficult it is to type on a train? ;-)
  *
- * $Id: DatabaseMetaDataTest.java,v 1.13 2002/09/06 21:23:06 momjian Exp $
+ * $Id: DatabaseMetaDataTest.java,v 1.14 2002/09/11 05:38:45 barry Exp $
  */
 
 public class DatabaseMetaDataTest extends TestCase
@@ -264,7 +264,11 @@ public class DatabaseMetaDataTest extends TestCase
                assertTrue( fkColumnName.equals( "m" ) || fkColumnName.equals( "n" ) ) ;
 
                String fkName = rs.getString( "FK_NAME" );
-               assertTrue( fkName.equals( "") );
+               if (((org.postgresql.jdbc1.AbstractJdbc1Connection)con1).haveMinimumServerVersion("7.3")) {
+                   assertTrue(fkName.startsWith("$1"));
+               } else {
+                   assertTrue( fkName.startsWith( "") );
+               }
 
                String pkName = rs.getString( "PK_NAME" );
                assertTrue( pkName.equals("vv_pkey") );
@@ -317,7 +321,7 @@ public class DatabaseMetaDataTest extends TestCase
                assertTrue( fkColumnName.equals( "people_id" ) || fkColumnName.equals( "policy_id" ) ) ;
 
                String fkName = rs.getString( "FK_NAME" );
-               assertTrue( fkName.equals( "people") || fkName.equals( "policy" ) );
+               assertTrue( fkName.startsWith( "people") || fkName.startsWith( "policy" ) );
 
                String pkName = rs.getString( "PK_NAME" );
                assertTrue( pkName.equals( "people_pkey") || pkName.equals( "policy_pkey" ) );
@@ -337,7 +341,7 @@ public class DatabaseMetaDataTest extends TestCase
            assertTrue( rs.getString( "FKTABLE_NAME" ).equals( "users" ) );
            assertTrue( rs.getString( "FKCOLUMN_NAME" ).equals( "people_id" ) );
 
-           assertTrue( rs.getString( "FK_NAME" ).equals( "people" ) );
+           assertTrue( rs.getString( "FK_NAME" ).startsWith( "people" ) );
 
 
            TestUtil.dropTable( con1, "users" );
index 3e5519e3178f54eae06925b8074cf979a4316589..fcd6321803fb52e63506c848e63f4518521cf4f9 100644 (file)
@@ -124,6 +124,7 @@ public class UpdateableResultTest extends TestCase
            st.close();
 
            TestUtil.dropTable( con, "updateable" );
+           TestUtil.dropTable( con, "second" );
            TestUtil.closeDB( con );
        }
        catch (Exception ex)
index dbb73d3e72d0c238bf1e6c8f36cc15464f3045d4..7d041496c803f665bb25cb61ca5ffa56d010cf0b 100644 (file)
@@ -1,7 +1,7 @@
 package org.postgresql.test.jdbc2.optional;
 
 import junit.framework.TestCase;
-import org.postgresql.test.JDBC2Tests;
+import org.postgresql.test.TestUtil;
 import org.postgresql.jdbc2.optional.SimpleDataSource;
 import org.postgresql.jdbc2.optional.BaseDataSource;
 
@@ -15,7 +15,7 @@ import java.sql.*;
  * tests.
  *
  * @author Aaron Mulder ([email protected])
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public abstract class BaseDataSourceTest extends TestCase
 {
@@ -36,12 +36,12 @@ public abstract class BaseDataSourceTest extends TestCase
     */
    protected void setUp() throws Exception
    {
-       con = JDBC2Tests.openDB();
-       JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
+       con = TestUtil.openDB();
+       TestUtil.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
        Statement stmt = con.createStatement();
        stmt.executeUpdate("INSERT INTO poolingtest VALUES (1, 'Test Row 1')");
        stmt.executeUpdate("INSERT INTO poolingtest VALUES (2, 'Test Row 2')");
-       JDBC2Tests.closeDB(con);
+       TestUtil.closeDB(con);
    }
 
    /**
@@ -50,9 +50,9 @@ public abstract class BaseDataSourceTest extends TestCase
     */
    protected void tearDown() throws Exception
    {
-       con = JDBC2Tests.openDB();
-       JDBC2Tests.dropTable(con, "poolingtest");
-       JDBC2Tests.closeDB(con);
+       con = TestUtil.openDB();
+       TestUtil.dropTable(con, "poolingtest");
+       TestUtil.closeDB(con);
    }
 
    /**
@@ -142,8 +142,7 @@ public abstract class BaseDataSourceTest extends TestCase
        try
        {
            con = getDataSourceConnection();
-           JDBC2Tests.dropTable(con, "poolingtest");
-           JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
+           TestUtil.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
            con.close();
        }
        catch (SQLException e)
index 2e405f2a547dcc091c760143cd2c33496d89cdc9..90a3b564a5108865bea9fadf778e5b85ed03bf7b 100644 (file)
@@ -1,7 +1,7 @@
 package org.postgresql.test.jdbc2.optional;
 
 import org.postgresql.jdbc2.optional.ConnectionPool;
-import org.postgresql.test.JDBC2Tests;
+import org.postgresql.test.TestUtil;
 import javax.sql.*;
 import java.sql.*;
 
@@ -11,7 +11,7 @@ import java.sql.*;
  * interface to the PooledConnection is through the CPDS.
  *
  * @author Aaron Mulder ([email protected])
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public class ConnectionPoolTest extends BaseDataSourceTest
 {
@@ -31,7 +31,7 @@ public class ConnectionPoolTest extends BaseDataSourceTest
        if (bds == null)
        {
            bds = new ConnectionPool();
-           String db = JDBC2Tests.getURL();
+           String db = TestUtil.getURL();
            if (db.indexOf('/') > -1)
            {
                db = db.substring(db.lastIndexOf('/') + 1);
@@ -41,8 +41,8 @@ public class ConnectionPoolTest extends BaseDataSourceTest
                db = db.substring(db.lastIndexOf(':') + 1);
            }
            bds.setDatabaseName(db);
-           bds.setUser(JDBC2Tests.getUser());
-           bds.setPassword(JDBC2Tests.getPassword());
+           bds.setUser(TestUtil.getUser());
+           bds.setPassword(TestUtil.getPassword());
        }
    }
 
index 3eb42733a2cb4158b7e123e0ca1c5aa7a8d7ba07..b5c3e100ecd04ba50c30ca1fc49d200d05559acc 100644 (file)
@@ -1,6 +1,6 @@
 package org.postgresql.test.jdbc2.optional;
 
-import org.postgresql.test.JDBC2Tests;
+import org.postgresql.test.TestUtil;
 import org.postgresql.jdbc2.optional.SimpleDataSource;
 
 /**
@@ -8,7 +8,7 @@ import org.postgresql.jdbc2.optional.SimpleDataSource;
  * configuration logic.
  *
  * @author Aaron Mulder ([email protected])
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public class SimpleDataSourceTest extends BaseDataSourceTest
 {
@@ -28,7 +28,7 @@ public class SimpleDataSourceTest extends BaseDataSourceTest
        if (bds == null)
        {
            bds = new SimpleDataSource();
-           String db = JDBC2Tests.getURL();
+           String db = TestUtil.getURL();
            if (db.indexOf('/') > -1)
            {
                db = db.substring(db.lastIndexOf('/') + 1);
@@ -38,8 +38,8 @@ public class SimpleDataSourceTest extends BaseDataSourceTest
                db = db.substring(db.lastIndexOf(':') + 1);
            }
            bds.setDatabaseName(db);
-           bds.setUser(JDBC2Tests.getUser());
-           bds.setPassword(JDBC2Tests.getPassword());
+           bds.setUser(TestUtil.getUser());
+           bds.setPassword(TestUtil.getPassword());
        }
    }
 }