Commit d634a590 authored by Barry Lind's avatar Barry Lind

Patches submitted by Kris Jurka (jurka@ejurka.com) for the following bugs:

  - 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 (d.wall@computer.org):
  - problem with getBlob when largeobject oid is null
  - improvements to BlobOutputStream
Patch submitted by Haris Peco (snpe@snpe.co.yu):
  - 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
parent 8aa966e4
...@@ -446,6 +446,6 @@ public class Driver implements java.sql.Driver ...@@ -446,6 +446,6 @@ public class Driver implements java.sql.Driver
} }
//The build number should be incremented for every new build //The build number should be incremented for every new build
private static int m_buildNumber = 104; private static int m_buildNumber = 105;
} }
...@@ -14,7 +14,7 @@ import org.postgresql.largeobject.LargeObjectManager; ...@@ -14,7 +14,7 @@ import org.postgresql.largeobject.LargeObjectManager;
import org.postgresql.util.*; 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 * This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection * methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
...@@ -982,21 +982,32 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec ...@@ -982,21 +982,32 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
*/ */
public int getTransactionIsolation() throws SQLException public int getTransactionIsolation() throws SQLException
{ {
clearWarnings(); String sql = "show transaction isolation level";
ExecSQL("show transaction isolation level"); String level = null;
if (haveMinimumServerVersion("7.3")) {
SQLWarning warning = getWarnings(); ResultSet rs = ExecSQL(sql);
if (warning != null) if (rs.next()) {
{ level = rs.getString(1);
String message = warning.getMessage(); }
rs.close();
} else {
clearWarnings(); 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; 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; 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; 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_SERIALIZABLE;
} }
return java.sql.Connection.TRANSACTION_READ_COMMITTED; return java.sql.Connection.TRANSACTION_READ_COMMITTED;
......
...@@ -27,19 +27,28 @@ public abstract class AbstractJdbc1DatabaseMetaData ...@@ -27,19 +27,28 @@ public abstract class AbstractJdbc1DatabaseMetaData
protected static final int iInt2Oid = 21; // OID for int2 protected static final int iInt2Oid = 21; // OID for int2
protected static final int iInt4Oid = 23; // OID for int4 protected static final int iInt4Oid = 23; // OID for int4
protected static final int VARHDRSZ = 4; // length 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) public AbstractJdbc1DatabaseMetaData(AbstractJdbc1Connection conn)
{ {
this.connection = conn; this.connection = conn;
String sql;
try { try {
if (connection.haveMinimumServerVersion("7.3")) { 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 { } 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) { } 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.
} }
} }
......
...@@ -8,7 +8,7 @@ import java.util.Vector; ...@@ -8,7 +8,7 @@ import java.util.Vector;
import org.postgresql.largeobject.*; import org.postgresql.largeobject.*;
import org.postgresql.util.*; 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 * This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
...@@ -170,6 +170,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -170,6 +170,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{ {
String l_sql = replaceProcessing(p_sql); String l_sql = replaceProcessing(p_sql);
m_sqlFragments = new String[] {l_sql}; m_sqlFragments = new String[] {l_sql};
m_binds = new Object[0];
//If we have already created a server prepared statement, we need //If we have already created a server prepared statement, we need
//to deallocate the existing one //to deallocate the existing one
if (m_statementName != null) { if (m_statementName != null) {
...@@ -213,6 +214,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -213,6 +214,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{ {
String l_sql = replaceProcessing(p_sql); String l_sql = replaceProcessing(p_sql);
m_sqlFragments = new String[] {l_sql}; m_sqlFragments = new String[] {l_sql};
m_binds = new Object[0];
//If we have already created a server prepared statement, we need //If we have already created a server prepared statement, we need
//to deallocate the existing one //to deallocate the existing one
if (m_statementName != null) { if (m_statementName != null) {
...@@ -1775,6 +1777,12 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1775,6 +1777,12 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
*/ */
private String modifyJdbcCall(String p_sql) throws SQLException 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 :( // syntax checking is not complete only a few basics :(
originalSql = p_sql; // save for error msgs.. originalSql = p_sql; // save for error msgs..
String l_sql = p_sql; String l_sql = p_sql;
......
...@@ -15,7 +15,7 @@ import org.postgresql.util.PGbytea; ...@@ -15,7 +15,7 @@ import org.postgresql.util.PGbytea;
import org.postgresql.util.PSQLException; 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 * This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1ResultSet which provides the jdbc1 * org.postgresql.jdbc1.AbstractJdbc1ResultSet which provides the jdbc1
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2ResultSet * 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 ...@@ -1546,14 +1546,7 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
case Types.REAL: case Types.REAL:
case Types.TINYINT: case Types.TINYINT:
try rowBuffer[columnIndex] = connection.getEncoding().encode(String.valueOf( updateValues.get( columnName ) ));
{
rowBuffer[columnIndex] = String.valueOf( updateValues.get( columnName ) ).getBytes(connection.getEncoding().name() );
}
catch ( UnsupportedEncodingException ex)
{
throw new SQLException("Unsupported Encoding " + connection.getEncoding().name());
}
case Types.NULL: case Types.NULL:
continue; continue;
......
...@@ -8,7 +8,7 @@ import java.util.Vector; ...@@ -8,7 +8,7 @@ import java.util.Vector;
import org.postgresql.largeobject.*; import org.postgresql.largeobject.*;
import org.postgresql.util.PSQLException; 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 * This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1 * org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Statement * 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 ...@@ -187,16 +187,26 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra
while (numRead != -1 && bytesRemaining > 0) while (numRead != -1 && bytesRemaining > 0)
{ {
bytesRemaining -= numRead; 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)); numRead = l_inStream.read(buf, 0, Math.min(buf.length, bytesRemaining));
} }
los.close();
} }
catch (IOException se) catch (IOException se)
{ {
throw new PSQLException("postgresql.unusual", 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); setInt(i, oid);
} }
......
...@@ -5,7 +5,7 @@ import java.sql.*; ...@@ -5,7 +5,7 @@ import java.sql.*;
import java.util.Vector; import java.util.Vector;
import org.postgresql.Field; 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. * This class implements the java.sql.ResultSet interface for JDBC2.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents * org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents
...@@ -25,11 +25,19 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet ...@@ -25,11 +25,19 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
public java.sql.Clob getClob(int i) throws SQLException 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)); return new org.postgresql.jdbc2.Jdbc2Clob(connection, getInt(i));
} }
public java.sql.Blob getBlob(int i) throws SQLException 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)); return new org.postgresql.jdbc2.Jdbc2Blob(connection, getInt(i));
} }
......
...@@ -5,7 +5,7 @@ import java.sql.*; ...@@ -5,7 +5,7 @@ import java.sql.*;
import java.util.Vector; import java.util.Vector;
import org.postgresql.Field; 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. * This class implements the java.sql.ResultSet interface for JDBC3.
* However most of the implementation is really done in * However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents * org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents
...@@ -25,11 +25,19 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet ...@@ -25,11 +25,19 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
public java.sql.Clob getClob(int i) throws SQLException 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)); return new Jdbc3Clob(connection, getInt(i));
} }
public java.sql.Blob getBlob(int i) throws SQLException 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)); return new Jdbc3Blob(connection, getInt(i));
} }
......
...@@ -68,6 +68,26 @@ public class BlobOutputStream extends OutputStream ...@@ -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 * Flushes this output stream and forces any buffered output bytes
* to be written out. The general contract of <code>flush</code> is * to be written out. The general contract of <code>flush</code> is
......
...@@ -304,7 +304,7 @@ public class LargeObject ...@@ -304,7 +304,7 @@ public class LargeObject
*/ */
public InputStream getInputStream() throws SQLException public InputStream getInputStream() throws SQLException
{ {
return new BlobInputStream(this); return new BlobInputStream(this, 4096);
} }
/* /*
...@@ -318,7 +318,7 @@ public class LargeObject ...@@ -318,7 +318,7 @@ public class LargeObject
public OutputStream getOutputStream() throws SQLException public OutputStream getOutputStream() throws SQLException
{ {
if (os == null) if (os == null)
os = new BlobOutputStream(this); os = new BlobOutputStream(this, 4096);
return os; return os;
} }
......
...@@ -109,11 +109,26 @@ public class TestUtil ...@@ -109,11 +109,26 @@ public class TestUtil
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
try 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) 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) catch (SQLException ex)
......
...@@ -9,7 +9,7 @@ import java.sql.*; ...@@ -9,7 +9,7 @@ import java.sql.*;
* *
* PS: Do you know how difficult it is to type on a train? ;-) * 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 public class DatabaseMetaDataTest extends TestCase
...@@ -264,7 +264,11 @@ public class DatabaseMetaDataTest extends TestCase ...@@ -264,7 +264,11 @@ public class DatabaseMetaDataTest extends TestCase
assertTrue( fkColumnName.equals( "m" ) || fkColumnName.equals( "n" ) ) ; assertTrue( fkColumnName.equals( "m" ) || fkColumnName.equals( "n" ) ) ;
String fkName = rs.getString( "FK_NAME" ); String fkName = rs.getString( "FK_NAME" );
assertTrue( fkName.equals( "<unnamed>") ); if (((org.postgresql.jdbc1.AbstractJdbc1Connection)con1).haveMinimumServerVersion("7.3")) {
assertTrue(fkName.startsWith("$1"));
} else {
assertTrue( fkName.startsWith( "<unnamed>") );
}
String pkName = rs.getString( "PK_NAME" ); String pkName = rs.getString( "PK_NAME" );
assertTrue( pkName.equals("vv_pkey") ); assertTrue( pkName.equals("vv_pkey") );
...@@ -317,7 +321,7 @@ public class DatabaseMetaDataTest extends TestCase ...@@ -317,7 +321,7 @@ public class DatabaseMetaDataTest extends TestCase
assertTrue( fkColumnName.equals( "people_id" ) || fkColumnName.equals( "policy_id" ) ) ; assertTrue( fkColumnName.equals( "people_id" ) || fkColumnName.equals( "policy_id" ) ) ;
String fkName = rs.getString( "FK_NAME" ); 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" ); String pkName = rs.getString( "PK_NAME" );
assertTrue( pkName.equals( "people_pkey") || pkName.equals( "policy_pkey" ) ); assertTrue( pkName.equals( "people_pkey") || pkName.equals( "policy_pkey" ) );
...@@ -337,7 +341,7 @@ public class DatabaseMetaDataTest extends TestCase ...@@ -337,7 +341,7 @@ public class DatabaseMetaDataTest extends TestCase
assertTrue( rs.getString( "FKTABLE_NAME" ).equals( "users" ) ); assertTrue( rs.getString( "FKTABLE_NAME" ).equals( "users" ) );
assertTrue( rs.getString( "FKCOLUMN_NAME" ).equals( "people_id" ) ); 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" ); TestUtil.dropTable( con1, "users" );
......
...@@ -124,6 +124,7 @@ public class UpdateableResultTest extends TestCase ...@@ -124,6 +124,7 @@ public class UpdateableResultTest extends TestCase
st.close(); st.close();
TestUtil.dropTable( con, "updateable" ); TestUtil.dropTable( con, "updateable" );
TestUtil.dropTable( con, "second" );
TestUtil.closeDB( con ); TestUtil.closeDB( con );
} }
catch (Exception ex) catch (Exception ex)
......
package org.postgresql.test.jdbc2.optional; package org.postgresql.test.jdbc2.optional;
import junit.framework.TestCase; 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.SimpleDataSource;
import org.postgresql.jdbc2.optional.BaseDataSource; import org.postgresql.jdbc2.optional.BaseDataSource;
...@@ -15,7 +15,7 @@ import java.sql.*; ...@@ -15,7 +15,7 @@ import java.sql.*;
* tests. * tests.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.2 $ * @version $Revision: 1.3 $
*/ */
public abstract class BaseDataSourceTest extends TestCase public abstract class BaseDataSourceTest extends TestCase
{ {
...@@ -36,12 +36,12 @@ public abstract class BaseDataSourceTest extends TestCase ...@@ -36,12 +36,12 @@ public abstract class BaseDataSourceTest extends TestCase
*/ */
protected void setUp() throws Exception protected void setUp() throws Exception
{ {
con = JDBC2Tests.openDB(); con = TestUtil.openDB();
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)");
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO poolingtest VALUES (1, 'Test Row 1')"); stmt.executeUpdate("INSERT INTO poolingtest VALUES (1, 'Test Row 1')");
stmt.executeUpdate("INSERT INTO poolingtest VALUES (2, 'Test Row 2')"); 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 ...@@ -50,9 +50,9 @@ public abstract class BaseDataSourceTest extends TestCase
*/ */
protected void tearDown() throws Exception protected void tearDown() throws Exception
{ {
con = JDBC2Tests.openDB(); con = TestUtil.openDB();
JDBC2Tests.dropTable(con, "poolingtest"); TestUtil.dropTable(con, "poolingtest");
JDBC2Tests.closeDB(con); TestUtil.closeDB(con);
} }
/** /**
...@@ -142,8 +142,7 @@ public abstract class BaseDataSourceTest extends TestCase ...@@ -142,8 +142,7 @@ public abstract class BaseDataSourceTest extends TestCase
try try
{ {
con = getDataSourceConnection(); con = getDataSourceConnection();
JDBC2Tests.dropTable(con, "poolingtest"); TestUtil.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
con.close(); con.close();
} }
catch (SQLException e) catch (SQLException e)
......
package org.postgresql.test.jdbc2.optional; package org.postgresql.test.jdbc2.optional;
import org.postgresql.jdbc2.optional.ConnectionPool; import org.postgresql.jdbc2.optional.ConnectionPool;
import org.postgresql.test.JDBC2Tests; import org.postgresql.test.TestUtil;
import javax.sql.*; import javax.sql.*;
import java.sql.*; import java.sql.*;
...@@ -11,7 +11,7 @@ import java.sql.*; ...@@ -11,7 +11,7 @@ import java.sql.*;
* interface to the PooledConnection is through the CPDS. * interface to the PooledConnection is through the CPDS.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.2 $ * @version $Revision: 1.3 $
*/ */
public class ConnectionPoolTest extends BaseDataSourceTest public class ConnectionPoolTest extends BaseDataSourceTest
{ {
...@@ -31,7 +31,7 @@ public class ConnectionPoolTest extends BaseDataSourceTest ...@@ -31,7 +31,7 @@ public class ConnectionPoolTest extends BaseDataSourceTest
if (bds == null) if (bds == null)
{ {
bds = new ConnectionPool(); bds = new ConnectionPool();
String db = JDBC2Tests.getURL(); String db = TestUtil.getURL();
if (db.indexOf('/') > -1) if (db.indexOf('/') > -1)
{ {
db = db.substring(db.lastIndexOf('/') + 1); db = db.substring(db.lastIndexOf('/') + 1);
...@@ -41,8 +41,8 @@ public class ConnectionPoolTest extends BaseDataSourceTest ...@@ -41,8 +41,8 @@ public class ConnectionPoolTest extends BaseDataSourceTest
db = db.substring(db.lastIndexOf(':') + 1); db = db.substring(db.lastIndexOf(':') + 1);
} }
bds.setDatabaseName(db); bds.setDatabaseName(db);
bds.setUser(JDBC2Tests.getUser()); bds.setUser(TestUtil.getUser());
bds.setPassword(JDBC2Tests.getPassword()); bds.setPassword(TestUtil.getPassword());
} }
} }
......
package org.postgresql.test.jdbc2.optional; package org.postgresql.test.jdbc2.optional;
import org.postgresql.test.JDBC2Tests; import org.postgresql.test.TestUtil;
import org.postgresql.jdbc2.optional.SimpleDataSource; import org.postgresql.jdbc2.optional.SimpleDataSource;
/** /**
...@@ -8,7 +8,7 @@ import org.postgresql.jdbc2.optional.SimpleDataSource; ...@@ -8,7 +8,7 @@ import org.postgresql.jdbc2.optional.SimpleDataSource;
* configuration logic. * configuration logic.
* *
* @author Aaron Mulder (ammulder@chariotsolutions.com) * @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.2 $ * @version $Revision: 1.3 $
*/ */
public class SimpleDataSourceTest extends BaseDataSourceTest public class SimpleDataSourceTest extends BaseDataSourceTest
{ {
...@@ -28,7 +28,7 @@ public class SimpleDataSourceTest extends BaseDataSourceTest ...@@ -28,7 +28,7 @@ public class SimpleDataSourceTest extends BaseDataSourceTest
if (bds == null) if (bds == null)
{ {
bds = new SimpleDataSource(); bds = new SimpleDataSource();
String db = JDBC2Tests.getURL(); String db = TestUtil.getURL();
if (db.indexOf('/') > -1) if (db.indexOf('/') > -1)
{ {
db = db.substring(db.lastIndexOf('/') + 1); db = db.substring(db.lastIndexOf('/') + 1);
...@@ -38,8 +38,8 @@ public class SimpleDataSourceTest extends BaseDataSourceTest ...@@ -38,8 +38,8 @@ public class SimpleDataSourceTest extends BaseDataSourceTest
db = db.substring(db.lastIndexOf(':') + 1); db = db.substring(db.lastIndexOf(':') + 1);
} }
bds.setDatabaseName(db); bds.setDatabaseName(db);
bds.setUser(JDBC2Tests.getUser()); bds.setUser(TestUtil.getUser());
bds.setPassword(JDBC2Tests.getPassword()); bds.setPassword(TestUtil.getPassword());
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment