Commit b3dd55c6 authored by Barry Lind's avatar Barry Lind

Added support for JDBC3. The driver will now build under JDBC3 (i.e. Java 1.4).

This concludes my changes that restructured the code to support JDBC3.
The jdbc unit tests were also resturctured to allow different tests between
jdbc2 and jdbc3, although currently make check (aka ant test) for JDBC3 just
runs the JDBC2 tests.  Of special note the largeobject/PGblob and PGclob
classes have been moved under the jdbc2/jdbc3 specific directories as they
now differ by jdbc version.  Also note that this checkin removes the
PostgresqlDataSource and files in the xa directory.  A recent checkin has
added new datasource support that replaces the functionality provided by these
classes.

 Modified Files:
 	jdbc/build.xml
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
 	jdbc/org/postgresql/jdbc2/Array.java
 	jdbc/org/postgresql/jdbc2/Jdbc2CallableStatement.java
 	jdbc/org/postgresql/jdbc2/Jdbc2Connection.java
 	jdbc/org/postgresql/jdbc2/Jdbc2DatabaseMetaData.java
 	jdbc/org/postgresql/jdbc2/Jdbc2PreparedStatement.java
 	jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
 	jdbc/org/postgresql/jdbc2/Jdbc2ResultSetMetaData.java
 	jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
 	jdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java
 	jdbc/org/postgresql/test/jdbc2/BlobTest.java
 	jdbc/org/postgresql/test/jdbc2/CallableStmtTest.java
 	jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
 	jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
 	jdbc/org/postgresql/test/jdbc2/DateTest.java
 	jdbc/org/postgresql/test/jdbc2/DriverTest.java
 	jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
 	jdbc/org/postgresql/test/jdbc2/MiscTest.java
 	jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
 	jdbc/org/postgresql/test/jdbc2/TimeTest.java
 	jdbc/org/postgresql/test/jdbc2/TimestampTest.java
 	jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
 Added Files:
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2Blob.java
 	jdbc/org/postgresql/jdbc2/AbstractJdbc2Clob.java
 	jdbc/org/postgresql/jdbc2/Jdbc2Blob.java
 	jdbc/org/postgresql/jdbc2/Jdbc2Clob.java
 	jdbc/org/postgresql/jdbc3/AbstractJdbc3Blob.java
 	jdbc/org/postgresql/jdbc3/AbstractJdbc3Clob.java
 	jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java
 	jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java
 	jdbc/org/postgresql/jdbc3/AbstractJdbc3ResultSet.java
 	jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java
 	jdbc/org/postgresql/jdbc3/Jdbc3Blob.java
 	jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java
 	jdbc/org/postgresql/jdbc3/Jdbc3Clob.java
 	jdbc/org/postgresql/jdbc3/Jdbc3Connection.java
 	jdbc/org/postgresql/jdbc3/Jdbc3DatabaseMetaData.java
 	jdbc/org/postgresql/jdbc3/Jdbc3PreparedStatement.java
 	jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
 	jdbc/org/postgresql/jdbc3/Jdbc3ResultSetMetaData.java
 	jdbc/org/postgresql/jdbc3/Jdbc3Statement.java
 	jdbc/org/postgresql/test/TestUtil.java
 	jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
 	jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
 Removed Files:
 	jdbc/org/postgresql/PostgresqlDataSource.java
 	jdbc/org/postgresql/largeobject/PGblob.java
 	jdbc/org/postgresql/largeobject/PGclob.java
 	jdbc/org/postgresql/test/JDBC2Tests.java
 	jdbc/org/postgresql/xa/ClientConnection.java
 	jdbc/org/postgresql/xa/TwoPhaseConnection.java
 	jdbc/org/postgresql/xa/TxConnection.java
 	jdbc/org/postgresql/xa/XAConnectionImpl.java
 	jdbc/org/postgresql/xa/XADataSourceImpl.java
parent 64a06494
......@@ -6,7 +6,7 @@
This file now requires Ant 1.4.1. 2002-04-18
$Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.27 2002/07/30 13:22:02 davec Exp $
$Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/build.xml,v 1.28 2002/08/14 20:35:39 barry Exp $
-->
......@@ -46,6 +46,25 @@
</condition>
<available property="datasource" classname="javax.sql.DataSource"/>
<available property="junit" classname="junit.framework.Test" />
<condition property="jdbc2tests">
<and>
<isset property="jdbc2"/>
<isset property="junit"/>
</and>
</condition>
<condition property="jdbc2optionaltests">
<and>
<isset property="jdbc2"/>
<isset property="datasource"/>
<isset property="junit"/>
</and>
</condition>
<condition property="jdbc3tests">
<and>
<isset property="jdbc3"/>
<isset property="junit"/>
</and>
</condition>
</target>
......@@ -89,18 +108,10 @@
<exclude name="${package}/jdbc2/**" unless="jdbc2"/>
<exclude name="${package}/jdbc3/**" unless="jdbc3"/>
<exclude name="${package}/largeobject/PGblob.java" if="jdbc1" />
<exclude name="${package}/largeobject/PGclob.java" if="jdbc1" />
<exclude name="${package}/jdbc2/optional/**" unless="jdbc2" />
<exclude name="${package}/jdbc2/optional/**" unless="datasource" />
<exclude name="${package}/PostgresqlDataSource.java" />
<exclude name="${package}/xa/**" />
<exclude name="${package}/test/**" unless="junit" />
<exclude name="${package}/test/jdbc2/**" if="jdbc1" />
<exclude name="${package}/test/jdbc2/optional/**" unless="datasource" />
<exclude name="${package}/test/JDBC2Tests.java" if="jdbc1" />
<exclude name="${package}/test/**"/>
</javac>
</target>
......@@ -128,8 +139,15 @@
</condition>
<!-- determine the connection class -->
<property name="connectclass" value="org.postgresql.jdbc1.Jdbc1Connection" />
<available property="connectclass" value="org.postgresql.jdbc2.Jdbc2Connection" classname="java.lang.ThreadLocal" />
<condition property="connectclass" value="org.postgresql.jdbc1.Jdbc1Connection">
<equals arg1="${jdbc1}" arg2="true"/>
</condition>
<condition property="connectclass" value="org.postgresql.jdbc2.Jdbc2Connection">
<equals arg1="${jdbc2}" arg2="true"/>
</condition>
<condition property="connectclass" value="org.postgresql.jdbc3.Jdbc3Connection">
<equals arg1="${jdbc3}" arg2="true"/>
</condition>
<!-- Some defaults -->
<filter token="MAJORVERSION" value="${major}" />
......@@ -222,14 +240,31 @@
<property name="junit.ui" value="textui" />
<target name="test" depends="jar" if="junit">
<target name="test" depends="testjdbc2,testjdbc2optional,testjdbc3">
</target>
<target name="testjdbc2" depends="jar" if="jdbc2tests">
<javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
<include name="${package}/test/jdbc2/**" if="jdbc2" />
<include name="${package}/test/jdbc2/**" if="jdbc3" />
<include name="${package}/test/jdbc2/*" />
</javac>
<java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
<arg value="org.postgresql.test.jdbc2.Jdbc2TestSuite" />
<sysproperty key="database" value="${database}" />
<sysproperty key="username" value="${username}" />
<sysproperty key="password" value="${password}" />
<classpath>
<pathelement location="${builddir}" />
<pathelement path="${java.class.path}" />
</classpath>
</java>
</target>
<target name="testjdbc2optional" depends="jar" if="jdbc2optionaltests">
<javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
<include name="${package}/test/jdbc2/optional/**" />
</javac>
<java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
<arg value="org.postgresql.test.JDBC2Tests" />
<arg value="org.postgresql.test.jdbc2.optional.OptionalTestSuite" />
<sysproperty key="database" value="${database}" />
<sysproperty key="username" value="${username}" />
<sysproperty key="password" value="${password}" />
......@@ -240,4 +275,21 @@
</java>
</target>
<target name="testjdbc3" depends="jar" if="jdbc3tests">
<javac srcdir="${srcdir}" destdir="${builddir}" debug="${debug}">
<include name="${package}/test/jdbc3/*" />
</javac>
<java fork="yes" classname="junit.${junit.ui}.TestRunner" taskname="junit" failonerror="true">
<arg value="org.postgresql.test.jdbc3.Jdbc3TestSuite" />
<sysproperty key="database" value="${database}" />
<sysproperty key="username" value="${username}" />
<sysproperty key="password" value="${password}" />
<classpath>
<pathelement location="${builddir}" />
<pathelement path="${java.class.path}" />
</classpath>
</java>
</target>
</project>
......@@ -8,6 +8,7 @@ import org.postgresql.util.PSQLException;
public abstract class AbstractJdbc1DatabaseMetaData
{
protected AbstractJdbc1Connection connection; // The connection association
// These define various OID's. Hopefully they will stay constant.
......
......@@ -13,13 +13,14 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.PGbytea;
import org.postgresql.util.PSQLException;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.2 2002/07/25 22:45:27 barry Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.3 2002/08/14 20:35:39 barry Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2ResultSet which adds the jdbc2
* methods. The real ResultSet class (for jdbc1) is org.postgresql.jdbc1.Jdbc1ResultSet
*/
public abstract class AbstractJdbc1ResultSet
{
protected Vector rows; // The results
protected Statement statement;
protected Field fields[]; // The field descriptions
......
......@@ -10,6 +10,7 @@ import java.sql.Types;
public abstract class AbstractJdbc1ResultSetMetaData
{
protected Vector rows;
protected Field[] fields;
......
package org.postgresql.largeobject;
// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
// If you make any modifications to this file, you must make sure that the
// changes are also made (if relevent) to the related JDBC 1 class in the
// org.postgresql.jdbc1 package.
package org.postgresql.jdbc2;
import java.lang.*;
import java.io.*;
......@@ -13,22 +7,15 @@ import java.text.*;
import java.util.*;
import java.sql.*;
import org.postgresql.Field;
import org.postgresql.largeobject.*;
import org.postgresql.PGConnection;
import org.postgresql.largeobject.*;
/*
* This implements the Blob interface, which is basically another way to
* access a LargeObject.
*
* $Id: PGblob.java,v 1.4 2002/07/23 03:59:55 barry Exp $
*
*/
public class PGblob implements java.sql.Blob
public abstract class AbstractJdbc2Blob
{
private int oid;
private LargeObject lo;
public PGblob(org.postgresql.PGConnection conn, int oid) throws SQLException
public AbstractJdbc2Blob(PGConnection conn, int oid) throws SQLException
{
this.oid = oid;
LargeObjectManager lom = conn.getLargeObjectAPI();
......
package org.postgresql.largeobject;
// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
// If you make any modifications to this file, you must make sure that the
// changes are also made (if relevent) to the related JDBC 1 class in the
// org.postgresql.jdbc1 package.
package org.postgresql.jdbc2;
import java.lang.*;
......@@ -13,22 +8,15 @@ import java.text.*;
import java.util.*;
import java.sql.*;
import org.postgresql.Field;
import org.postgresql.largeobject.*;
import org.postgresql.PGConnection;
import org.postgresql.largeobject.*;
/*
* This implements the Blob interface, which is basically another way to
* access a LargeObject.
*
* $Id: PGclob.java,v 1.4 2002/07/23 03:59:55 barry Exp $
*
*/
public class PGclob implements java.sql.Clob
public class AbstractJdbc2Clob
{
private int oid;
private LargeObject lo;
public PGclob(org.postgresql.PGConnection conn, int oid) throws SQLException
public AbstractJdbc2Clob(PGConnection conn, int oid) throws SQLException
{
this.oid = oid;
LargeObjectManager lom = conn.getLargeObjectAPI();
......
......@@ -15,12 +15,13 @@ import org.postgresql.util.PGbytea;
import org.postgresql.util.PSQLException;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.3 2002/07/25 22:45:28 barry Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.4 2002/08/14 20:35:39 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
*/
public class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet {
public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet {
protected String sqlQuery = null;
//needed for updateable result set support
......@@ -237,9 +238,7 @@ public class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1Re
}
public Blob getBlob(int i) throws SQLException {
return new org.postgresql.largeobject.PGblob(connection, getInt(i));
}
public abstract Blob getBlob(int i) throws SQLException;
public java.io.Reader getCharacterStream(String columnName) throws SQLException {
......@@ -276,9 +275,7 @@ public class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1Re
}
public Clob getClob(int i) throws SQLException {
return new org.postgresql.largeobject.PGclob(connection, getInt(i));
}
public abstract Clob getClob(int i) throws SQLException;
public int getConcurrency() throws SQLException {
......@@ -919,7 +916,7 @@ public class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1Re
selectStatement.setObject( i, ((PrimaryKey) primaryKeys.get(j)).getValue() );
}
Jdbc2ResultSet rs = (Jdbc2ResultSet) selectStatement.executeQuery();
AbstractJdbc2ResultSet rs = (AbstractJdbc2ResultSet) selectStatement.executeQuery();
if ( rs.first() ) {
rowBuffer = rs.rowBuffer;
......
......@@ -124,33 +124,33 @@ public class Array implements java.sql.Array
case Types.BIT:
retVal = new boolean[ count ];
for ( ; count > 0; count-- )
((boolean[])retVal)[i++] = Jdbc2ResultSet.toBoolean( arrayContents[(int)index++] );
((boolean[])retVal)[i++] = AbstractJdbc2ResultSet.toBoolean( arrayContents[(int)index++] );
break;
case Types.SMALLINT:
case Types.INTEGER:
retVal = new int[ count ];
for ( ; count > 0; count-- )
((int[])retVal)[i++] = Jdbc2ResultSet.toInt( arrayContents[(int)index++] );
((int[])retVal)[i++] = AbstractJdbc2ResultSet.toInt( arrayContents[(int)index++] );
break;
case Types.BIGINT:
retVal = new long[ count ];
for ( ; count > 0; count-- )
((long[])retVal)[i++] = Jdbc2ResultSet.toLong( arrayContents[(int)index++] );
((long[])retVal)[i++] = AbstractJdbc2ResultSet.toLong( arrayContents[(int)index++] );
break;
case Types.NUMERIC:
retVal = new BigDecimal[ count ];
for ( ; count > 0; count-- )
((BigDecimal[])retVal)[i++] = Jdbc2ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );
((BigDecimal[])retVal)[i++] = AbstractJdbc2ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );
break;
case Types.REAL:
retVal = new float[ count ];
for ( ; count > 0; count-- )
((float[])retVal)[i++] = Jdbc2ResultSet.toFloat( arrayContents[(int)index++] );
((float[])retVal)[i++] = AbstractJdbc2ResultSet.toFloat( arrayContents[(int)index++] );
break;
case Types.DOUBLE:
retVal = new double[ count ];
for ( ; count > 0; count-- )
((double[])retVal)[i++] = Jdbc2ResultSet.toDouble( arrayContents[(int)index++] );
((double[])retVal)[i++] = AbstractJdbc2ResultSet.toDouble( arrayContents[(int)index++] );
break;
case Types.CHAR:
case Types.VARCHAR:
......@@ -161,18 +161,18 @@ public class Array implements java.sql.Array
case Types.DATE:
retVal = new java.sql.Date[ count ];
for ( ; count > 0; count-- )
((java.sql.Date[])retVal)[i++] = Jdbc2ResultSet.toDate( arrayContents[(int)index++] );
((java.sql.Date[])retVal)[i++] = AbstractJdbc2ResultSet.toDate( arrayContents[(int)index++] );
break;
case Types.TIME:
retVal = new java.sql.Time[ count ];
for ( ; count > 0; count-- )
((java.sql.Time[])retVal)[i++] = Jdbc2ResultSet.toTime( arrayContents[(int)index++], rs, getBaseTypeName() );
((java.sql.Time[])retVal)[i++] = AbstractJdbc2ResultSet.toTime( arrayContents[(int)index++], rs, getBaseTypeName() );
break;
case Types.TIMESTAMP:
retVal = new Timestamp[ count ];
StringBuffer sbuf = null;
for ( ; count > 0; count-- )
((java.sql.Timestamp[])retVal)[i++] = Jdbc2ResultSet.toTimestamp( arrayContents[(int)index++], rs, getBaseTypeName() );
((java.sql.Timestamp[])retVal)[i++] = AbstractJdbc2ResultSet.toTimestamp( arrayContents[(int)index++], rs, getBaseTypeName() );
break;
// Other datatypes not currently supported. If you are really using other types ask
......@@ -340,7 +340,7 @@ public class Array implements java.sql.Array
default:
throw org.postgresql.Driver.notImplemented();
}
return ((Jdbc2Connection)conn).getResultSet(null, fields, rows, "OK", 1 );
return ((AbstractJdbc2Connection)conn).getResultSet(null, fields, rows, "OK", 1 );
}
public String toString()
......
package org.postgresql.jdbc2;
public class Jdbc2Blob extends AbstractJdbc2Blob implements java.sql.Blob
{
public Jdbc2Blob(org.postgresql.PGConnection conn, int oid) throws java.sql.SQLException
{
super(conn, oid);
}
}
......@@ -3,7 +3,7 @@ package org.postgresql.jdbc2;
import java.sql.*;
public class Jdbc2CallableStatement extends AbstractJdbc2Statement implements java.sql.CallableStatement
public class Jdbc2CallableStatement extends org.postgresql.jdbc2.AbstractJdbc2Statement implements java.sql.CallableStatement
{
public Jdbc2CallableStatement(Jdbc2Connection connection, String sql) throws SQLException
......
package org.postgresql.jdbc2;
public class Jdbc2Clob extends AbstractJdbc2Clob implements java.sql.Clob
{
public Jdbc2Clob(org.postgresql.PGConnection conn, int oid) throws java.sql.SQLException
{
super(conn, oid);
}
}
package org.postgresql.jdbc2;
public class Jdbc2DatabaseMetaData extends AbstractJdbc2DatabaseMetaData implements java.sql.DatabaseMetaData
public class Jdbc2DatabaseMetaData extends org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData implements java.sql.DatabaseMetaData
{
public Jdbc2DatabaseMetaData(Jdbc2Connection conn)
{
......
......@@ -3,7 +3,7 @@ package org.postgresql.jdbc2;
import java.sql.*;
public class Jdbc2PreparedStatement extends AbstractJdbc2Statement implements java.sql.PreparedStatement
public class Jdbc2PreparedStatement extends org.postgresql.jdbc2.AbstractJdbc2Statement implements java.sql.PreparedStatement
{
public Jdbc2PreparedStatement(Jdbc2Connection connection, String sql) throws SQLException
......
......@@ -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.3 2002/07/26 05:29:35 barry Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.4 2002/08/14 20:35:39 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
......@@ -23,5 +23,13 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
return new Jdbc2ResultSetMetaData(rows, fields);
}
public java.sql.Clob getClob(int i) throws SQLException {
return new org.postgresql.jdbc2.Jdbc2Clob(connection, getInt(i));
}
public java.sql.Blob getBlob(int i) throws SQLException {
return new org.postgresql.jdbc2.Jdbc2Blob(connection, getInt(i));
}
}
package org.postgresql.jdbc3;
import java.sql.*;
public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdbc2Blob
{
public AbstractJdbc3Blob(org.postgresql.PGConnection conn, int oid) throws SQLException
{
super(conn, oid);
}
/**
* Writes the given array of bytes to the <code>BLOB</code> value that
* this <code>Blob</code> object represents, starting at position
* <code>pos</code>, and returns the number of bytes written.
*
* @param pos the position in the <code>BLOB</code> object at which
* to start writing
* @param bytes the array of bytes to be written to the <code>BLOB</code>
* value that this <code>Blob</code> object represents
* @return the number of bytes written
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value
* @see #getBytes
* @since 1.4
*/
public int setBytes(long pos, byte[] bytes) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Writes all or part of the given <code>byte</code> array to the
* <code>BLOB</code> value that this <code>Blob</code> object represents
* and returns the number of bytes written.
* Writing starts at position <code>pos</code> in the <code>BLOB</code>
* value; <code>len</code> bytes from the given byte array are written.
*
* @param pos the position in the <code>BLOB</code> object at which
* to start writing
* @param bytes the array of bytes to be written to this <code>BLOB</code>
* object
* @param offset the offset into the array <code>bytes</code> at which
* to start reading the bytes to be set
* @param len the number of bytes to be written to the <code>BLOB</code>
* value from the array of bytes <code>bytes</code>
* @return the number of bytes written
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value
* @see #getBytes
* @since 1.4
*/
public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves a stream that can be used to write to the <code>BLOB</code>
* value that this <code>Blob</code> object represents. The stream begins
* at position <code>pos</code>.
*
* @param pos the position in the <code>BLOB</code> value at which
* to start writing
* @return a <code>java.io.OutputStream</code> object to which data can
* be written
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value
* @see #getBinaryStream
* @since 1.4
*/
public java.io.OutputStream setBinaryStream(long pos) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Truncates the <code>BLOB</code> value that this <code>Blob</code>
* object represents to be <code>len</code> bytes in length.
*
* @param len the length, in bytes, to which the <code>BLOB</code> value
* that this <code>Blob</code> object represents should be truncated
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value
* @since 1.4
*/
public void truncate(long len) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
}
package org.postgresql.jdbc3;
import java.sql.*;
public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdbc2Clob
{
public AbstractJdbc3Clob(org.postgresql.PGConnection conn, int oid) throws SQLException
{
super(conn, oid);
}
/**
* Writes the given Java <code>String</code> to the <code>CLOB</code>
* value that this <code>Clob</code> object designates at the position
* <code>pos</code>.
*
* @param pos the position at which to start writing to the <code>CLOB</code>
* value that this <code>Clob</code> object represents
* @param str the string to be written to the <code>CLOB</code>
* value that this <code>Clob</code> designates
* @return the number of characters written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value
*
* @since 1.4
*/
public int setString(long pos, String str) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Writes <code>len</code> characters of <code>str</code>, starting
* at character <code>offset</code>, to the <code>CLOB</code> value
* that this <code>Clob</code> represents.
*
* @param pos the position at which to start writing to this
* <code>CLOB</code> object
* @param str the string to be written to the <code>CLOB</code>
* value that this <code>Clob</code> object represents
* @param offset the offset into <code>str</code> to start reading
* the characters to be written
* @param len the number of characters to be written
* @return the number of characters written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value
*
* @since 1.4
*/
public int setString(long pos, String str, int offset, int len) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves a stream to be used to write Ascii characters to the
* <code>CLOB</code> value that this <code>Clob</code> object represents,
* starting at position <code>pos</code>.
*
* @param pos the position at which to start writing to this
* <code>CLOB</code> object
* @return the stream to which ASCII encoded characters can be written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value
* @see #getAsciiStream
*
* @since 1.4
*/
public java.io.OutputStream setAsciiStream(long pos) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves a stream to be used to write a stream of Unicode characters
* to the <code>CLOB</code> value that this <code>Clob</code> object
* represents, at position <code>pos</code>.
*
* @param pos the position at which to start writing to the
* <code>CLOB</code> value
*
* @return a stream to which Unicode encoded characters can be written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value
* @see #getCharacterStream
*
* @since 1.4
*/
public java.io.Writer setCharacterStream(long pos) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Truncates the <code>CLOB</code> value that this <code>Clob</code>
* designates to have a length of <code>len</code>
* characters.
* @param len the length, in bytes, to which the <code>CLOB</code> value
* should be truncated
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value
*
* @since 1.4
*/
public void truncate(long len) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
}
package org.postgresql.jdbc3;
import java.sql.*;
import java.util.Vector;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.1 2002/08/14 20:35:39 barry Exp $
* This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2ResultSet which provides the jdbc2
* methods. The real Statement class (for jdbc3) is org.postgresql.jdbc3.Jdbc3ResultSet
*/
public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet {
public AbstractJdbc3ResultSet(org.postgresql.PGConnection conn, Statement statement, org.postgresql.Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) {
super (conn, statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a <code>java.net.URL</code>
* object in the Java programming language.
*
* @param columnIndex the index of the column 1 is the first, 2 is the second,...
* @return the column value as a <code>java.net.URL</code> object;
* if the value is SQL <code>NULL</code>,
* the value returned is <code>null</code> in the Java programming language
* @exception SQLException if a database access error occurs,
* or if a URL is malformed
* @since 1.4
*/
public java.net.URL getURL(int columnIndex) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a <code>java.net.URL</code>
* object in the Java programming language.
*
* @param columnName the SQL name of the column
* @return the column value as a <code>java.net.URL</code> object;
* if the value is SQL <code>NULL</code>,
* the value returned is <code>null</code> in the Java programming language
* @exception SQLException if a database access error occurs
* or if a URL is malformed
* @since 1.4
*/
public java.net.URL getURL(String columnName) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Ref</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateRef(int columnIndex, java.sql.Ref x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Ref</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnName the name of the column
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateRef(String columnName, java.sql.Ref x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Blob</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateBlob(int columnIndex, java.sql.Blob x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Blob</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnName the name of the column
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateBlob(String columnName, java.sql.Blob x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Clob</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateClob(int columnIndex, java.sql.Clob x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Clob</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnName the name of the column
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateClob(String columnName, java.sql.Clob x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Array</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateArray(int columnIndex, java.sql.Array x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Updates the designated column with a <code>java.sql.Array</code> value.
* The updater methods are used to update column values in the
* current row or the insert row. The updater methods do not
* update the underlying database; instead the <code>updateRow</code> or
* <code>insertRow</code> methods are called to update the database.
*
* @param columnName the name of the column
* @param x the new column value
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public void updateArray(String columnName, java.sql.Array x) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
}
package org.postgresql.jdbc3;
import java.sql.*;
public class Jdbc3Blob extends org.postgresql.jdbc3.AbstractJdbc3Blob implements java.sql.Blob
{
public Jdbc3Blob(org.postgresql.PGConnection conn, int oid) throws SQLException
{
super(conn, oid);
}
}
package org.postgresql.jdbc3;
import java.sql.*;
public class Jdbc3CallableStatement extends org.postgresql.jdbc3.AbstractJdbc3Statement implements java.sql.CallableStatement
{
public Jdbc3CallableStatement(Jdbc3Connection connection, String sql) throws SQLException
{
super(connection, sql);
}
}
package org.postgresql.jdbc3;
public class Jdbc3Clob extends org.postgresql.jdbc3.AbstractJdbc3Clob implements java.sql.Clob
{
public Jdbc3Clob(org.postgresql.PGConnection conn, int oid) throws java.sql.SQLException
{
super(conn, oid);
}
}
package org.postgresql.jdbc3;
import java.sql.*;
import java.util.Vector;
import java.util.Hashtable;
import org.postgresql.Field;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Connection.java,v 1.1 2002/08/14 20:35:40 barry Exp $
* This class implements the java.sql.Connection interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Connection or one of it's parents
*/
public class Jdbc3Connection extends org.postgresql.jdbc3.AbstractJdbc3Connection implements java.sql.Connection
{
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
{
Jdbc3Statement s = new Jdbc3Statement(this);
s.setResultSetType(resultSetType);
s.setResultSetConcurrency(resultSetConcurrency);
return s;
}
public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
Jdbc3PreparedStatement s = new Jdbc3PreparedStatement(this, sql);
s.setResultSetType(resultSetType);
s.setResultSetConcurrency(resultSetConcurrency);
return s;
}
public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
Jdbc3CallableStatement s = new Jdbc3CallableStatement(this,sql);
s.setResultSetType(resultSetType);
s.setResultSetConcurrency(resultSetConcurrency);
return s;
}
public java.sql.DatabaseMetaData getMetaData() throws SQLException
{
if (metadata == null)
metadata = new Jdbc3DatabaseMetaData(this);
return metadata;
}
public java.sql.ResultSet getResultSet(Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc3ResultSet(this, statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
public java.sql.ResultSet getResultSet(Statement statement, Field[] fields, Vector tuples, String status, int updateCount) throws SQLException
{
return new Jdbc3ResultSet(this, statement, fields, tuples, status, updateCount, 0, false);
}
}
package org.postgresql.jdbc3;
public class Jdbc3DatabaseMetaData extends org.postgresql.jdbc3.AbstractJdbc3DatabaseMetaData implements java.sql.DatabaseMetaData
{
public Jdbc3DatabaseMetaData(Jdbc3Connection conn)
{
super(conn);
}
}
package org.postgresql.jdbc3;
import java.sql.*;
public class Jdbc3PreparedStatement extends org.postgresql.jdbc3.AbstractJdbc3Statement implements java.sql.PreparedStatement
{
public Jdbc3PreparedStatement(Jdbc3Connection connection, String sql) throws SQLException
{
super(connection, sql);
}
}
package org.postgresql.jdbc3;
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.1 2002/08/14 20:35:40 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
*/
public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet implements java.sql.ResultSet
{
public Jdbc3ResultSet(Jdbc3Connection conn, Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super(conn, statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
public java.sql.ResultSetMetaData getMetaData() throws SQLException
{
return new Jdbc3ResultSetMetaData(rows, fields);
}
public java.sql.Clob getClob(int i) throws SQLException {
return new Jdbc3Clob(connection, getInt(i));
}
public java.sql.Blob getBlob(int i) throws SQLException {
return new Jdbc3Blob(connection, getInt(i));
}
}
package org.postgresql.jdbc3;
public class Jdbc3ResultSetMetaData extends org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData implements java.sql.ResultSetMetaData
{
public Jdbc3ResultSetMetaData(java.util.Vector rows, org.postgresql.Field[] fields)
{
super(rows, fields);
}
}
package org.postgresql.jdbc3;
import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.1 2002/08/14 20:35:40 barry Exp $
* This class implements the java.sql.Statement interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Statement or one of it's parents
*/
public class Jdbc3Statement extends org.postgresql.jdbc3.AbstractJdbc3Statement implements java.sql.Statement
{
public Jdbc3Statement (Jdbc3Connection c)
{
super(c);
}
}
package org.postgresql.test;
import junit.framework.TestSuite;
import junit.framework.TestCase;
import junit.framework.Test;
import org.postgresql.test.jdbc2.*;
import java.sql.*;
import java.lang.reflect.Method;
import junit.framework.TestCase;
/*
* Executes all known tests for JDBC2 and includes some utility methods.
* Utility class for JDBC tests
*/
public class JDBC2Tests extends TestSuite
public class TestUtil
{
/*
* Returns the Test database JDBC URL
......@@ -45,7 +40,7 @@ public class JDBC2Tests extends TestSuite
try
{
Class.forName("org.postgresql.Driver");
return java.sql.DriverManager.getConnection(JDBC2Tests.getURL(), JDBC2Tests.getUser(), JDBC2Tests.getPassword());
return java.sql.DriverManager.getConnection(getURL(), getUser(), getPassword());
}
catch (ClassNotFoundException ex)
{
......@@ -180,68 +175,4 @@ public class JDBC2Tests extends TestSuite
String s = "0000000000".substring(0, l) + Integer.toString(v);
return s.substring(s.length() - l);
}
/*
* The main entry point for JUnit
*/
public static TestSuite suite()
{
TestSuite suite = new TestSuite();
//
// Add one line per class in our test cases. These should be in order of
// complexity.
// ANTTest should be first as it ensures that test parameters are
// being sent to the suite. It also initialises the database (if required)
// with some simple global tables (will make each testcase use its own later).
//
suite.addTestSuite(ANTTest.class);
// Basic Driver internals
suite.addTestSuite(DriverTest.class);
suite.addTestSuite(ConnectionTest.class);
suite.addTestSuite(DatabaseMetaDataTest.class);
suite.addTestSuite(EncodingTest.class);
// Connectivity/Protocols
// ResultSet
suite.addTestSuite(ResultSetTest.class);
// Time, Date, Timestamp
suite.addTestSuite(DateTest.class);
suite.addTestSuite(TimeTest.class);
suite.addTestSuite(TimestampTest.class);
// PreparedStatement
// BatchExecute
suite.addTestSuite(BatchExecuteTest.class);
// MetaData
// Other misc tests, based on previous problems users have had or specific
// features some applications require.
suite.addTestSuite(JBuilderTest.class);
suite.addTestSuite(MiscTest.class);
// Fastpath/LargeObject
suite.addTestSuite(BlobTest.class);
suite.addTestSuite( UpdateableResultTest.class );
suite.addTestSuite( CallableStmtTest.class );
// try to load the optional test classes
try {
Class cls = Class.forName("org.postgresql.test.jdbc2.optional.OptionalTestSuite");
Method meth = cls.getMethod("suite", new Class[0]);
suite.addTest((Test)meth.invoke(null, new Object[0]));
} catch (Exception e) {
System.err.println("Excluding JDBC 2 Optional Package (DataSource) tests");
}
// That's all folks
return suite;
}
}
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
......@@ -26,12 +26,12 @@ public class BatchExecuteTest extends TestCase
// a table for this test.
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
con = TestUtil.openDB();
Statement stmt = con.createStatement();
// Drop the test table if it already exists for some reason. It is
// not an error if it doesn't exist.
JDBC2Tests.createTable(con, "testbatch", "pk INTEGER, col1 INTEGER");
TestUtil.createTable(con, "testbatch", "pk INTEGER, col1 INTEGER");
stmt.executeUpdate("INSERT INTO testbatch VALUES (1, 0)");
......@@ -45,8 +45,8 @@ public class BatchExecuteTest extends TestCase
{
con.setAutoCommit(true);
JDBC2Tests.dropTable(con, "testbatch");
JDBC2Tests.closeDB(con);
TestUtil.dropTable(con, "testbatch");
TestUtil.closeDB(con);
}
public void testSupportsBatchUpdates() throws Exception
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.io.*;
import java.sql.*;
......@@ -8,7 +8,7 @@ import java.sql.*;
import org.postgresql.largeobject.*;
/*
* $Id: BlobTest.java,v 1.6 2002/07/23 03:59:55 barry Exp $
* $Id: BlobTest.java,v 1.7 2002/08/14 20:35:40 barry Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
......@@ -30,14 +30,14 @@ public class BlobTest extends TestCase
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
JDBC2Tests.createTable(con, "testblob", "id name,lo oid");
con = TestUtil.openDB();
TestUtil.createTable(con, "testblob", "id name,lo oid");
}
protected void tearDown() throws Exception
{
JDBC2Tests.dropTable(con, "testblob");
JDBC2Tests.closeDB(con);
TestUtil.dropTable(con, "testblob");
TestUtil.closeDB(con);
}
/*
......@@ -131,7 +131,7 @@ public class BlobTest extends TestCase
case JDBC_STREAM:
File f = new File(file);
PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testblob", "?"));
PreparedStatement ps = con.prepareStatement(TestUtil.insertSQL("testblob", "?"));
ps.setBinaryStream(1, fis, (int) f.length());
ps.execute();
break;
......@@ -145,7 +145,7 @@ public class BlobTest extends TestCase
// Insert into the table
Statement st = con.createStatement();
st.executeUpdate(JDBC2Tests.insertSQL("testblob", "id,lo", "'" + file + "'," + oid));
st.executeUpdate(TestUtil.insertSQL("testblob", "id,lo", "'" + file + "'," + oid));
con.commit();
st.close();
......@@ -163,7 +163,7 @@ public class BlobTest extends TestCase
LargeObjectManager lom = ((org.postgresql.PGConnection)con).getLargeObjectAPI();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(JDBC2Tests.selectSQL("testblob", "id,lo"));
ResultSet rs = st.executeQuery(TestUtil.selectSQL("testblob", "id,lo"));
assertNotNull(rs);
while (rs.next())
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.io.*;
import java.sql.*;
......@@ -20,7 +20,7 @@ public class CallableStmtTest extends TestCase
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
con = TestUtil.openDB();
Statement stmt = con.createStatement ();
stmt.execute ("CREATE OR REPLACE FUNCTION testspg__getString (varchar) " +
"RETURNS varchar AS ' DECLARE inString alias for $1; begin "+
......@@ -44,7 +44,7 @@ public class CallableStmtTest extends TestCase
stmt.execute ("drop FUNCTION testspg__getDouble (float);");
stmt.execute ("drop FUNCTION testspg__getInt (int);");
stmt.execute ("drop FUNCTION testspg__getNumeric (numeric);");
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
......@@ -10,7 +10,7 @@ import java.sql.*;
*
* PS: Do you know how difficult it is to type on a train? ;-)
*
* $Id: ConnectionTest.java,v 1.8 2002/07/23 03:59:55 barry Exp $
* $Id: ConnectionTest.java,v 1.9 2002/08/14 20:35:40 barry Exp $
*/
public class ConnectionTest extends TestCase
......@@ -27,23 +27,23 @@ public class ConnectionTest extends TestCase
// Set up the fixture for this testcase: the tables for this test.
protected void setUp() throws Exception
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
JDBC2Tests.createTable(con, "test_a", "imagename name,image oid,id int4");
JDBC2Tests.createTable(con, "test_c", "source text,cost money,imageid int4");
TestUtil.createTable(con, "test_a", "imagename name,image oid,id int4");
TestUtil.createTable(con, "test_c", "source text,cost money,imageid int4");
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
// Tear down the fixture for this test case.
protected void tearDown() throws Exception
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
JDBC2Tests.dropTable(con, "test_a");
JDBC2Tests.dropTable(con, "test_c");
TestUtil.dropTable(con, "test_a");
TestUtil.dropTable(con, "test_c");
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
/*
......@@ -53,7 +53,7 @@ public class ConnectionTest extends TestCase
{
try
{
java.sql.Connection conn = JDBC2Tests.openDB();
java.sql.Connection conn = TestUtil.openDB();
// A standard Statement
java.sql.Statement stat = conn.createStatement();
......@@ -79,7 +79,7 @@ public class ConnectionTest extends TestCase
{
try
{
java.sql.Connection conn = JDBC2Tests.openDB();
java.sql.Connection conn = TestUtil.openDB();
String sql = "select source,cost,imageid from test_c";
......@@ -121,7 +121,7 @@ public class ConnectionTest extends TestCase
{
try
{
java.sql.Connection con = JDBC2Tests.openDB();
java.sql.Connection con = TestUtil.openDB();
java.sql.Statement st;
java.sql.ResultSet rs;
......@@ -155,7 +155,7 @@ public class ConnectionTest extends TestCase
assertEquals(9876, rs.getInt(1)); // Should not change!
rs.close();
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
catch (SQLException ex)
{
......@@ -170,12 +170,12 @@ public class ConnectionTest extends TestCase
{
try
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
// Should not say closed
assertTrue(!con.isClosed());
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
// Should now say closed
assertTrue(con.isClosed());
......@@ -194,7 +194,7 @@ public class ConnectionTest extends TestCase
{
try
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
String testStr = "This Is OuR TeSt message";
......@@ -216,7 +216,7 @@ public class ConnectionTest extends TestCase
con.clearWarnings();
assertTrue(con.getWarnings() == null);
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
catch (SQLException ex)
{
......@@ -231,7 +231,7 @@ public class ConnectionTest extends TestCase
{
try
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
// PostgreSQL defaults to READ COMMITTED
assertEquals(Connection.TRANSACTION_READ_COMMITTED,
......@@ -301,7 +301,7 @@ public class ConnectionTest extends TestCase
assertEquals(Connection.TRANSACTION_READ_COMMITTED,
con.getTransactionIsolation());
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
catch ( SQLException ex )
{
......@@ -316,7 +316,7 @@ public class ConnectionTest extends TestCase
{
try
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
// preserve the current map
java.util.Map oldmap = con.getTypeMap();
......@@ -330,7 +330,7 @@ public class ConnectionTest extends TestCase
con.setTypeMap(oldmap);
assertEquals(oldmap, con.getTypeMap());
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
catch (SQLException ex)
{
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
......@@ -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.10 2002/07/30 13:22:38 davec Exp $
* $Id: DatabaseMetaDataTest.java,v 1.11 2002/08/14 20:35:40 barry Exp $
*/
public class DatabaseMetaDataTest extends TestCase
......@@ -26,14 +26,14 @@ public class DatabaseMetaDataTest extends TestCase
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
JDBC2Tests.createTable( con, "testmetadata", "id int4, name text, updated timestamp" );
con = TestUtil.openDB();
TestUtil.createTable( con, "testmetadata", "id int4, name text, updated timestamp" );
}
protected void tearDown() throws Exception
{
JDBC2Tests.dropTable( con, "testmetadata" );
TestUtil.dropTable( con, "testmetadata" );
JDBC2Tests.closeDB( con );
TestUtil.closeDB( con );
}
/*
* The spec says this may return null, but we always do!
......@@ -233,11 +233,11 @@ public class DatabaseMetaDataTest extends TestCase
{
try
{
Connection con1 = JDBC2Tests.openDB();
Connection con1 = TestUtil.openDB();
JDBC2Tests.createTable( con1, "vv", "a int not null, b int not null, primary key ( a, b )" );
TestUtil.createTable( con1, "vv", "a int not null, b int not null, primary key ( a, b )" );
JDBC2Tests.createTable( con1, "ww", "m int not null, n int not null, primary key ( m, n ), foreign key ( m, n ) references vv ( a, b )" );
TestUtil.createTable( con1, "ww", "m int not null, n int not null, primary key ( m, n ), foreign key ( m, n ) references vv ( a, b )" );
DatabaseMetaData dbmd = con.getMetaData();
......@@ -271,8 +271,8 @@ public class DatabaseMetaDataTest extends TestCase
}
JDBC2Tests.dropTable( con1, "vv" );
JDBC2Tests.dropTable( con1, "ww" );
TestUtil.dropTable( con1, "vv" );
TestUtil.dropTable( con1, "ww" );
}
catch (SQLException ex)
......@@ -284,11 +284,11 @@ public class DatabaseMetaDataTest extends TestCase
{
try
{
Connection con1 = JDBC2Tests.openDB();
JDBC2Tests.createTable( con1, "people", "id int4 primary key, name text" );
JDBC2Tests.createTable( con1, "policy", "id int4 primary key, name text" );
Connection con1 = TestUtil.openDB();
TestUtil.createTable( con1, "people", "id int4 primary key, name text" );
TestUtil.createTable( con1, "policy", "id int4 primary key, name text" );
JDBC2Tests.createTable( con1, "users", "id int4 primary key, people_id int4, policy_id int4,"+
TestUtil.createTable( con1, "users", "id int4 primary key, people_id int4, policy_id int4,"+
"CONSTRAINT people FOREIGN KEY (people_id) references people(id),"+
"constraint policy FOREIGN KEY (policy_id) references policy(id)" );
......@@ -337,9 +337,9 @@ public class DatabaseMetaDataTest extends TestCase
assertTrue( rs.getString( "FK_NAME" ).equals( "people" ) );
JDBC2Tests.dropTable( con1, "users" );
JDBC2Tests.dropTable( con1, "people" );
JDBC2Tests.dropTable( con1, "policy" );
TestUtil.dropTable( con1, "users" );
TestUtil.dropTable( con1, "people" );
TestUtil.dropTable( con1, "policy" );
}
catch (SQLException ex)
......@@ -405,8 +405,8 @@ public class DatabaseMetaDataTest extends TestCase
DatabaseMetaData dbmd = con.getMetaData();
assertNotNull(dbmd);
assertTrue(dbmd.getURL().equals(JDBC2Tests.getURL()));
assertTrue(dbmd.getUserName().equals(JDBC2Tests.getUser()));
assertTrue(dbmd.getURL().equals(TestUtil.getURL()));
assertTrue(dbmd.getUserName().equals(TestUtil.getUser()));
}
catch (SQLException ex)
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
/*
* $Id: DateTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
* $Id: DateTest.java,v 1.5 2002/08/14 20:35:40 barry Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
......@@ -23,14 +23,14 @@ public class DateTest extends TestCase
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
JDBC2Tests.createTable(con, "testdate", "dt date");
con = TestUtil.openDB();
TestUtil.createTable(con, "testdate", "dt date");
}
protected void tearDown() throws Exception
{
JDBC2Tests.dropTable(con, "testdate");
JDBC2Tests.closeDB(con);
TestUtil.dropTable(con, "testdate");
TestUtil.closeDB(con);
}
/*
......@@ -42,10 +42,10 @@ public class DateTest extends TestCase
{
Statement stmt = con.createStatement();
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'1950-02-07'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'1970-06-02'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'1999-08-11'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testdate", "'2001-02-13'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1950-02-07'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1970-06-02'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'1999-08-11'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testdate", "'2001-02-13'")));
/* dateTest() contains all of the tests */
dateTest();
......@@ -67,7 +67,7 @@ public class DateTest extends TestCase
try
{
Statement stmt = con.createStatement();
PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testdate", "?"));
PreparedStatement ps = con.prepareStatement(TestUtil.insertSQL("testdate", "?"));
ps.setDate(1, makeDate(1950, 2, 7));
assertEquals(1, ps.executeUpdate());
......@@ -104,7 +104,7 @@ public class DateTest extends TestCase
ResultSet rs;
java.sql.Date d;
rs = st.executeQuery(JDBC2Tests.selectSQL("testdate", "dt"));
rs = st.executeQuery(TestUtil.selectSQL("testdate", "dt"));
assertNotNull(rs);
assertTrue(rs.next());
......@@ -135,8 +135,8 @@ public class DateTest extends TestCase
private java.sql.Date makeDate(int y, int m, int d)
{
return java.sql.Date.valueOf(JDBC2Tests.fix(y, 4) + "-" +
JDBC2Tests.fix(m, 2) + "-" +
JDBC2Tests.fix(d, 2));
return java.sql.Date.valueOf(TestUtil.fix(y, 4) + "-" +
TestUtil.fix(m, 2) + "-" +
TestUtil.fix(d, 2));
}
}
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
/*
* $Id: DriverTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
* $Id: DriverTest.java,v 1.5 2002/08/14 20:35:40 barry Exp $
*
* Tests the dynamically created class org.postgresql.Driver
*
......@@ -63,12 +63,12 @@ public class DriverTest extends TestCase
Class.forName("org.postgresql.Driver");
// Test with the url, username & password
con = DriverManager.getConnection(JDBC2Tests.getURL(), JDBC2Tests.getUser(), JDBC2Tests.getPassword());
con = DriverManager.getConnection(TestUtil.getURL(), TestUtil.getUser(), TestUtil.getPassword());
assertNotNull(con);
con.close();
// Test with the username in the url
con = DriverManager.getConnection(JDBC2Tests.getURL() + "?user=" + JDBC2Tests.getUser() + "&password=" + JDBC2Tests.getPassword());
con = DriverManager.getConnection(TestUtil.getURL() + "?user=" + TestUtil.getUser() + "&password=" + TestUtil.getPassword());
assertNotNull(con);
con.close();
}
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
import java.math.BigDecimal;
/*
* $Id: JBuilderTest.java,v 1.5 2001/11/19 22:33:39 momjian Exp $
* $Id: JBuilderTest.java,v 1.6 2002/08/14 20:35:40 barry Exp $
*
* Some simple tests to check that the required components needed for JBuilder
* stay working
......@@ -23,20 +23,20 @@ public class JBuilderTest extends TestCase
// Set up the fixture for this testcase: the tables for this test.
protected void setUp() throws Exception
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
JDBC2Tests.createTable( con, "test_c",
TestUtil.createTable( con, "test_c",
"source text,cost money,imageid int4" );
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
// Tear down the fixture for this test case.
protected void tearDown() throws Exception
{
Connection con = JDBC2Tests.openDB();
JDBC2Tests.dropTable(con, "test_c");
JDBC2Tests.closeDB(con);
Connection con = TestUtil.openDB();
TestUtil.dropTable(con, "test_c");
TestUtil.closeDB(con);
}
/*
......@@ -46,7 +46,7 @@ public class JBuilderTest extends TestCase
{
try
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select cost from test_c");
......@@ -60,7 +60,7 @@ public class JBuilderTest extends TestCase
rs.close();
st.close();
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
catch (Exception ex)
{
......
package org.postgresql.test.jdbc2;
import junit.framework.TestSuite;
import junit.framework.TestCase;
import junit.framework.Test;
import java.sql.*;
import java.lang.reflect.Method;
/*
* Executes all known tests for JDBC2 and includes some utility methods.
*/
public class Jdbc2TestSuite extends TestSuite
{
/*
* The main entry point for JUnit
*/
public static TestSuite suite()
{
TestSuite suite = new TestSuite();
//
// Add one line per class in our test cases. These should be in order of
// complexity.
// ANTTest should be first as it ensures that test parameters are
// being sent to the suite. It also initialises the database (if required)
// with some simple global tables (will make each testcase use its own later).
//
suite.addTestSuite(ANTTest.class);
// Basic Driver internals
suite.addTestSuite(DriverTest.class);
suite.addTestSuite(ConnectionTest.class);
suite.addTestSuite(DatabaseMetaDataTest.class);
suite.addTestSuite(EncodingTest.class);
// Connectivity/Protocols
// ResultSet
suite.addTestSuite(ResultSetTest.class);
// Time, Date, Timestamp
suite.addTestSuite(DateTest.class);
suite.addTestSuite(TimeTest.class);
suite.addTestSuite(TimestampTest.class);
// PreparedStatement
// BatchExecute
suite.addTestSuite(BatchExecuteTest.class);
// MetaData
// Other misc tests, based on previous problems users have had or specific
// features some applications require.
suite.addTestSuite(JBuilderTest.class);
suite.addTestSuite(MiscTest.class);
// Fastpath/LargeObject
suite.addTestSuite(BlobTest.class);
suite.addTestSuite( UpdateableResultTest.class );
suite.addTestSuite( CallableStmtTest.class );
// That's all folks
return suite;
}
}
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
/*
* $Id: MiscTest.java,v 1.6 2002/06/14 10:56:13 davec Exp $
* $Id: MiscTest.java,v 1.7 2002/08/14 20:35:40 barry Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
......@@ -30,7 +30,7 @@ public class MiscTest extends TestCase
{
try
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select datname from pg_database");
......@@ -44,7 +44,7 @@ public class MiscTest extends TestCase
rs.close();
st.close();
JDBC2Tests.closeDB(con);
TestUtil.closeDB(con);
}
catch (Exception ex)
{
......@@ -54,7 +54,7 @@ public class MiscTest extends TestCase
public void testError()
{
Connection con = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
try
{
......@@ -81,17 +81,17 @@ public class MiscTest extends TestCase
System.out.println("testing lock");
try
{
Connection con = JDBC2Tests.openDB();
Connection con2 = JDBC2Tests.openDB();
Connection con = TestUtil.openDB();
Connection con2 = TestUtil.openDB();
JDBC2Tests.createTable(con, "test_lock", "name text");
TestUtil.createTable(con, "test_lock", "name text");
Statement st = con.createStatement();
Statement st2 = con2.createStatement();
con.setAutoCommit(false);
st.execute("lock table test_lock");
st2.executeUpdate( "insert into test_lock ( name ) values ('hello')" );
con.commit();
JDBC2Tests.dropTable(con, "test_lock");
TestUtil.dropTable(con, "test_lock");
con.close();
}
catch ( Exception ex )
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.io.*;
import java.sql.*;
......@@ -19,10 +19,10 @@ public class ResultSetTest extends TestCase
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
con = TestUtil.openDB();
Statement stmt = con.createStatement();
JDBC2Tests.createTable(con, "testrs", "id integer");
TestUtil.createTable(con, "testrs", "id integer");
stmt.executeUpdate("INSERT INTO testrs VALUES (1)");
stmt.executeUpdate("INSERT INTO testrs VALUES (2)");
......@@ -36,8 +36,8 @@ public class ResultSetTest extends TestCase
protected void tearDown() throws Exception
{
JDBC2Tests.dropTable(con, "testrs");
JDBC2Tests.closeDB(con);
TestUtil.dropTable(con, "testrs");
TestUtil.closeDB(con);
}
public void testAbsolute() throws Exception
......
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
/*
* $Id: TimeTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
* $Id: TimeTest.java,v 1.5 2002/08/14 20:35:40 barry Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
......@@ -23,14 +23,14 @@ public class TimeTest extends TestCase
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
JDBC2Tests.createTable(con, "testtime", "tm time");
con = TestUtil.openDB();
TestUtil.createTable(con, "testtime", "tm time");
}
protected void tearDown() throws Exception
{
JDBC2Tests.dropTable(con, "testtime");
JDBC2Tests.closeDB(con);
TestUtil.dropTable(con, "testtime");
TestUtil.closeDB(con);
}
/*
......@@ -42,8 +42,8 @@ public class TimeTest extends TestCase
{
Statement stmt = con.createStatement();
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testtime", "'01:02:03'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL("testtime", "'23:59:59'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testtime", "'01:02:03'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL("testtime", "'23:59:59'")));
// Fall through helper
timeTest();
......@@ -64,7 +64,7 @@ public class TimeTest extends TestCase
{
try
{
PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testtime", "?"));
PreparedStatement ps = con.prepareStatement(TestUtil.insertSQL("testtime", "?"));
Statement stmt = con.createStatement();
ps.setTime(1, makeTime(1, 2, 3));
......@@ -95,7 +95,7 @@ public class TimeTest extends TestCase
ResultSet rs;
java.sql.Time t;
rs = st.executeQuery(JDBC2Tests.selectSQL("testtime", "tm"));
rs = st.executeQuery(TestUtil.selectSQL("testtime", "tm"));
assertNotNull(rs);
assertTrue(rs.next());
......@@ -115,8 +115,8 @@ public class TimeTest extends TestCase
private java.sql.Time makeTime(int h, int m, int s)
{
return java.sql.Time.valueOf(JDBC2Tests.fix(h, 2) + ":" +
JDBC2Tests.fix(m, 2) + ":" +
JDBC2Tests.fix(s, 2));
return java.sql.Time.valueOf(TestUtil.fix(h, 2) + ":" +
TestUtil.fix(m, 2) + ":" +
TestUtil.fix(s, 2));
}
}
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
/*
* $Id: TimestampTest.java,v 1.7 2002/07/23 03:59:55 barry Exp $
* $Id: TimestampTest.java,v 1.8 2002/08/14 20:35:40 barry Exp $
*
* Test get/setTimestamp for both timestamp with time zone and
* timestamp without time zone datatypes
......@@ -23,18 +23,18 @@ public class TimestampTest extends TestCase
protected void setUp() throws Exception
{
con = JDBC2Tests.openDB();
con = TestUtil.openDB();
Statement stmt = con.createStatement();
JDBC2Tests.createTable(con, TSWTZ_TABLE, "ts timestamp with time zone");
JDBC2Tests.createTable(con, TSWOTZ_TABLE, "ts timestamp without time zone");
TestUtil.createTable(con, TSWTZ_TABLE, "ts timestamp with time zone");
TestUtil.createTable(con, TSWOTZ_TABLE, "ts timestamp without time zone");
}
protected void tearDown() throws Exception
{
JDBC2Tests.dropTable(con, TSWTZ_TABLE);
JDBC2Tests.dropTable(con, TSWOTZ_TABLE);
JDBC2Tests.closeDB(con);
TestUtil.dropTable(con, TSWTZ_TABLE);
TestUtil.dropTable(con, TSWOTZ_TABLE);
TestUtil.closeDB(con);
}
/*
......@@ -49,9 +49,9 @@ public class TimestampTest extends TestCase
Statement stmt = con.createStatement();
//Insert the three timestamp values in raw pg format
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL(TSWTZ_TABLE,"'" + TS1WTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL(TSWTZ_TABLE,"'" + TS2WTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL(TSWTZ_TABLE,"'" + TS3WTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE,"'" + TS1WTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE,"'" + TS2WTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWTZ_TABLE,"'" + TS3WTZ_PGFORMAT + "'")));
// Fall through helper
timestampTestWTZ();
......@@ -77,7 +77,7 @@ public class TimestampTest extends TestCase
try
{
Statement stmt = con.createStatement();
PreparedStatement pstmt = con.prepareStatement(JDBC2Tests.insertSQL(TSWTZ_TABLE, "?"));
PreparedStatement pstmt = con.prepareStatement(TestUtil.insertSQL(TSWTZ_TABLE, "?"));
pstmt.setTimestamp(1, TS1WTZ);
assertEquals(1, pstmt.executeUpdate());
......@@ -114,9 +114,9 @@ public class TimestampTest extends TestCase
Statement stmt = con.createStatement();
//Insert the three timestamp values in raw pg format
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL(TSWOTZ_TABLE,"'" + TS1WOTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL(TSWOTZ_TABLE,"'" + TS2WOTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(JDBC2Tests.insertSQL(TSWOTZ_TABLE,"'" + TS3WOTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE,"'" + TS1WOTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE,"'" + TS2WOTZ_PGFORMAT + "'")));
assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE,"'" + TS3WOTZ_PGFORMAT + "'")));
// Fall through helper
timestampTestWOTZ();
......@@ -143,7 +143,7 @@ public class TimestampTest extends TestCase
try
{
Statement stmt = con.createStatement();
PreparedStatement pstmt = con.prepareStatement(JDBC2Tests.insertSQL(TSWOTZ_TABLE, "?"));
PreparedStatement pstmt = con.prepareStatement(TestUtil.insertSQL(TSWOTZ_TABLE, "?"));
pstmt.setTimestamp(1, TS1WOTZ);
assertEquals(1, pstmt.executeUpdate());
......@@ -240,12 +240,12 @@ public class TimestampTest extends TestCase
java.text.DateFormat l_df;
try {
String l_ts;
l_ts = JDBC2Tests.fix(y, 4) + "-" +
JDBC2Tests.fix(m, 2) + "-" +
JDBC2Tests.fix(d, 2) + " " +
JDBC2Tests.fix(h, 2) + ":" +
JDBC2Tests.fix(mn, 2) + ":" +
JDBC2Tests.fix(se, 2) + " ";
l_ts = TestUtil.fix(y, 4) + "-" +
TestUtil.fix(m, 2) + "-" +
TestUtil.fix(d, 2) + " " +
TestUtil.fix(h, 2) + ":" +
TestUtil.fix(mn, 2) + ":" +
TestUtil.fix(se, 2) + " ";
if (tz == null) {
l_df = new java.text.SimpleDateFormat("y-M-d H:m:s");
......
......@@ -3,7 +3,7 @@ package org.postgresql.test.jdbc2;
import java.sql.*;
import junit.framework.TestCase;
import org.postgresql.test.JDBC2Tests;
import org.postgresql.test.TestUtil;
/**
* <p>Title: </p>
* <p>Description: </p>
......@@ -25,12 +25,12 @@ public class UpdateableResultTest extends TestCase
{
try
{
Connection con = JDBC2Tests.openDB();
JDBC2Tests.createTable(con, "updateable","id int primary key, name text, notselected text");
JDBC2Tests.createTable(con, "second","id1 int primary key, name1 text");
Connection con = TestUtil.openDB();
TestUtil.createTable(con, "updateable","id int primary key, name text, notselected text");
TestUtil.createTable(con, "second","id1 int primary key, name1 text");
Statement st1 = con.createStatement();
boolean retVal = st1.execute( "insert into updateable ( id, name, notselected ) values (1, 'jake', 'avalue')" );
assert( retVal== false );
assertTrue(!retVal);
retVal = st1.execute( "insert into second (id1, name1) values (1, 'jake')" );
assertTrue( !retVal );
......@@ -121,8 +121,8 @@ public class UpdateableResultTest extends TestCase
st.close();
JDBC2Tests.dropTable( con,"updateable" );
JDBC2Tests.closeDB( con );
TestUtil.dropTable( con,"updateable" );
TestUtil.closeDB( con );
}
catch (Exception ex)
{
......
package org.postgresql.test.jdbc3;
import junit.framework.TestSuite;
import junit.framework.TestCase;
import junit.framework.Test;
import java.sql.*;
/*
* Executes all known tests for JDBC3
*/
public class Jdbc3TestSuite extends TestSuite
{
/*
* The main entry point for JUnit
*/
public static TestSuite suite()
{
//Currently there are no specific jdbc3 tests so just run the jdbc2 tests
return org.postgresql.test.jdbc2.Jdbc2TestSuite.suite();
}
}
/*
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact info@exolab.org.
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: TwoPhaseConnection.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
*/
package org.postgresql.xa;
import java.sql.SQLException;
/*
* Defines two-phase commit support for a JDBC connection used by
* {@link XAConnection}. A JDBC connection that can implement any of
* these features should extend this interface and attempt to
* implement as much as it can.
* <p>
* {@link #prepare} is used as part of the two phase commit protocol
* to determine whether the transaction can commit or must rollback.
* Failure to implement this method will cause all connections to vote
* for commit, whether or not they can actually commit, leading to
* mixed heuristics.
* <p>
* {@link #enableSQLTransactions} allows the SQL begin/commit/rollback
* commands to be disabled for the duration of a transaction managed
* through an {@link javax.transaction.xaXAResource}, preventing the
* application from demarcating transactions directly.
* <p>
* {@link #isCriticalError} is used to tell if an exception thrown by
* the connection is fatal and the connection should not be returned
* to the pool.
*
*
* @author <a href="arkin@exoffice.com">Assaf Arkin</a>
* @version 1.0
*/
public interface TwoPhaseConnection
{
/*
* Enables or disables transaction demarcation through SQL commit
* and rollback. When the connection falls under control of
* {@link XAConnection}, SQL commit/rollback commands will be
* disabled to prevent direct transaction demarcation.
*
* @param flag True to enable SQL transactions (the default)
*/
public void enableSQLTransactions( boolean flag );
/*
* Called to prepare the transaction for commit. Returns true if
* the transaction is prepared, false if the transaction is
* read-only. If the transaction has been marked for rollback,
* throws a {@link RollbackException}.
*
* @return True if can commit, false if read-only
* @throws SQLException If transaction has been marked for
* rollback or cannot commit for any other reason
*/
public boolean prepare()
throws SQLException;
/*
* Returns true if the error issued by this connection is a
* critical error and the connection should be terminated.
*
* @param except The exception thrown by this connection
*/
public boolean isCriticalError( SQLException except );
}
/*
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact info@exolab.org.
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: TxConnection.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
*/
package org.postgresql.xa;
import java.sql.Connection;
import javax.transaction.xa.Xid;
/*
* Describes an open connection associated with a transaction. When a
* transaction is opened for a connection, this record is created for
* the connection. It indicates the underlying JDBC connection and
* transaction Xid. Multiple XA connection that fall under the same
* transaction Xid will share the same TxConnection object.
*
*
* @author <a href="arkin@exoffice.com">Assaf Arkin</a>
* @version 1.0
* @see Xid
* @see XAConnectionImpl
*/
final class TxConnection
{
/*
* The Xid of the transactions. Connections that are not
* associated with a transaction are not represented here.
*/
Xid xid;
/*
* Holds the underlying JDBC connection for as long as this
* connection is useable. If the connection has been rolled back,
* timed out or had any other error, this variable will null
* and the connection is considered failed.
*/
Connection conn;
/*
* Indicates the clock time (in ms) when the transaction should
* time out. The transaction times out when
* <tt>System.currentTimeMillis() > timeout</tt>.
*/
long timeout;
/*
* Indicates the clock time (in ms) when the transaction started.
*/
long started;
/*
* Reference counter indicates how many XA connections share this
* underlying connection and transaction. Always one or more.
*/
int count;
/*
* True if the transaction has failed due to time out.
*/
boolean timedOut;
/*
* True if the transaction has already been prepared.
*/
boolean prepared;
/*
* True if the transaction has been prepared and found out to be
* read-only. Read-only transactions do not require commit/rollback.
*/
boolean readOnly;
}
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