提交 b3dd55c6 编写于 作者: B 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
上级 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>
/*
* 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: PostgresqlDataSource.java,v 1.5 2001/11/19 23:16:45 momjian Exp $
*/
package org.postgresql;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.Properties;
import java.util.Hashtable;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.DriverManager;
import java.rmi.Remote;
import javax.sql.DataSource;
import javax.naming.Referenceable;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.naming.RefAddr;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.naming.spi.ObjectFactory;
// FIXME
//import postgresql.util.PSQLException;
//import postgresql.xa.XADataSourceImpl;
import org.postgresql.util.PSQLException;
import org.postgresql.xa.XADataSourceImpl;
//---------
/*
* Implements a JDBC 2.0 {@link javax.sql.DataSource} for the
* PostgreSQL driver with JNDI persistance support. XA and pooled
* connection support is also available, but the application must
* used the designated DataSource interface to obtain them.
* <p>
* The supported data source properties are:
* <pre>
* description (optional)
* databaseName (required)
* loginTimeout (optional)
* user (optional)
* password (optional)
* serverName (optional)
* portNumber (optional)
* transactionTimeout (optional for XA connections)
* </pre>
* This data source may be serialized and stored in a JNDI
* directory. Example of how to create a new data source and
* register it with JNDI:
* <pre>
* PostgresqlDataSource ds;
* InitialContext ctx;
*
* ds = new PostgresqlDataSource();
* ds.setDatabaseName( "test" );
* ds.setUser( "me" );
* ds.setPassword( "secret" );
* ctx = new InitialContext();
* ctx.rebind( "/comp/jdbc/test", ds );
* </pre>
* Example for obtaining the data source from JNDI and
* opening a new connections:
* <pre>
* InitialContext ctx;
* DataSource ds;
*
* ctx = new InitialContext();
* ds = (DataSource) ctx.lookup( "/comp/jdbc/test" );
* ds.getConnection();
* </pre>
*
*
* @author <a href="arkin@exoffice.com">Assaf Arkin</a>
* @version 1.0
* @see XADataSourceImpl
* @see DataSource
* @see Connection
*/
public class PostgresqlDataSource
extends XADataSourceImpl
implements DataSource, Referenceable,
ObjectFactory, Serializable
{
/*
* Holds the timeout for opening a new connection, specified
* in seconds. The default is obtained from the JDBC driver.
*/
private int _loginTimeout;
/*
* Holds the user's account name.
*/
private String _user;
/*
* Holds the database password.
*/
private String _password;
/*
* Holds the name of the particular database on the server.
*/
private String _databaseName;
/*
* Description of this datasource.
*/
private String _description = "PostgreSQL DataSource";
/*
* Holds the database server name. If null, this is
* assumed to be the localhost.
*/
private String _serverName;
/*
* Holds the port number where a server is listening.
* The default value will open a connection with an
* unspecified port.
*/
private int _portNumber = DEFAULT_PORT;
/*
* The default port number. Since we open the connection
* without specifying the port if it's the default one,
* this value can be meaningless.
*/
private static final int DEFAULT_PORT = 0;
/*
* Holds the log writer to which all messages should be
* printed. The default writer is obtained from the driver
* manager, but it can be specified at the datasource level
* and will be passed to the driver. May be null.
*/
private transient PrintWriter _logWriter;
/*
* Each datasource maintains it's own driver, in case of
* driver-specific setup (e.g. pools, log writer).
*/
// FIXME
// private transient postgresql.Driver _driver;
private transient org.postgresql.Driver _driver;
public PostgresqlDataSource()
{
_logWriter = DriverManager.getLogWriter();
_loginTimeout = DriverManager.getLoginTimeout();
}
public Connection getConnection()
throws SQLException
{
// Uses the username and password specified for the datasource.
return getConnection( _user, _password );
}
public synchronized Connection getConnection( String user, String password )
throws SQLException
{
Connection conn;
Properties info;
String url;
if ( _driver == null )
{
try
{
// Constructs a driver for use just by this data source
// which will produce TwoPhaseConnection-s. This driver
// is not registered with the driver manager.
// FIXME
// _driver = new postgresql.Driver();
_driver = new org.postgresql.Driver();
//FIXME
// _driver.setLogWriter( _logWriter );
// Method seems to be unavailable. Just commented it out.
}
catch ( SQLException except )
{
if ( _logWriter != null )
_logWriter.println( "DataSource: Failed to initialize JDBC driver: " + except );
throw except;
}
}
// Use info to supply properties that are not in the URL.
info = new Properties();
info.put( "loginTimeout", Integer.toString( _loginTimeout ) );
// DriverManager will do that and not rely on the URL alone.
if ( user == null )
{
user = _user;
password = _password;
}
if ( user == null || password == null )
throw new PSQLException( "postgresql.ds.userpswd" );
info.put( "user", user );
info.put( "password", password );
if ( _serverName != null )
info.put( "PGHOST", _serverName );
if ( _portNumber != DEFAULT_PORT )
info.put( "PGPORT", Integer.toString( _portNumber ) );
if ( _databaseName != null )
info.put( "PGDBNAME", _databaseName );
// Construct the URL suitable for this driver.
url = "jdbc:postgresql:";
// Attempt to establish a connection. Report a successful
// attempt or a failure.
try
{
conn = _driver.connect( url, info );
// FIXME
// if ( ! ( conn instanceof postgresql.jdbc2.Connection ) ) {
if ( ! ( conn instanceof org.postgresql.jdbc2.Connection ) )
{
if ( _logWriter != null )
_logWriter.println( "DataSource: JDBC 1 connections not supported" );
throw new PSQLException( "postgresql.ds.onlyjdbc2" );
}
}
catch ( SQLException except )
{
if ( _logWriter != null )
_logWriter.println( "DataSource: getConnection failed " + except );
throw except;
}
if ( conn != null && _logWriter != null )
_logWriter.println( "DataSource: getConnection returning " + conn );
return conn;
}
public PrintWriter getLogWriter()
{
return _logWriter;
}
public synchronized void setLogWriter( PrintWriter writer )
{
// Once a log writer has been set, we cannot set it since some
// thread might be conditionally accessing it right now without
// synchronizing.
if ( writer != null )
{
if ( _driver != null )
// FIXME
// _driver.setLogWriter( writer );
// Method seems to be unavailable. Commented it out.
_logWriter = writer;
}
}
public void setLoginTimeout( int seconds )
{
_loginTimeout = seconds;
}
public synchronized int getLoginTimeout()
{
return _loginTimeout;
}
/*
* Sets the name of the particular database on the server.
* The standard name for this property is <tt>databaseName</tt>.
*
* @param databaseName The name of the particular database on the server
*/
public synchronized void setDatabaseName( String databaseName )
{
if ( databaseName == null )
throw new NullPointerException( "DataSource: Argument 'databaseName' is null" );
_databaseName = databaseName;
}
/*
* Returns the name of the particular database on the server.
* The standard name for this property is <tt>databaseName</tt>.
*
* @return The name of the particular database on the server
*/
public String getDatabaseName()
{
return _databaseName;
}
/*
* Sets the description of this datasource.
* The standard name for this property is <tt>description</tt>.
*
* @param description The description of this datasource
*/
public synchronized void setDescription( String description )
{
if ( description == null )
throw new NullPointerException( "DataSource: Argument 'description' is null" );
_description = description;
}
/*
* Returns the description of this datasource.
* The standard name for this property is <tt>description</tt>.
*
* @return The description of this datasource
*/
public String getDescription()
{
return _description;
}
/*
* Sets the database password.
* The standard name for this property is <tt>password</tt>.
*
* @param password The database password
*/
public synchronized void setPassword( String password )
{
_password = password;
}
/*
* Returns the database password.
* The standard name for this property is <tt>password</tt>.
*
* @return The database password
*/
public String getPassword()
{
return _password;
}
/*
* Sets the port number where a server is listening.
* The standard name for this property is <tt>portNumber</tt>.
*
* @param portNumber The port number where a server is listening
*/
public synchronized void setPortNumber( int portNumber )
{
_portNumber = portNumber;
}
/*
* Returns the port number where a server is listening.
* The standard name for this property is <tt>portNumber</tt>.
*
* @return The port number where a server is listening
*/
public int getPortNumber()
{
return _portNumber;
}
/*
* Sets the database server name.
* The standard name for this property is <tt>serverName</tt>.
*
* @param serverName The database server name
*/
public synchronized void setServerName( String serverName )
{
_serverName = serverName;
}
/*
* Returns the database server name.
* The standard name for this property is <tt>serverName</tt>.
*
* @return The database server name
*/
public String getServerName()
{
return _serverName;
}
/*
* Sets the user's account name.
* The standard name for this property is <tt>user</tt>.
*
* @param user The user's account name
*/
public synchronized void setUser( String user )
{
_user = user;
}
/*
* Returns the user's account name.
* The standard name for this property is <tt>user</tt>.
*
* @return The user's account name
*/
public String getUser()
{
return _user;
}
/*
* Returns true if this datasource and the other are equal.
* The two datasources are equal if and only if they will produce
* the exact same connections. Connection properties like database
* name, user name, etc are comapred. Setup properties like
* description, log writer, etc are not compared.
*/
public synchronized boolean equals( Object other )
{
if ( other == this )
return true;
if ( other == null || ! ( other instanceof PostgresqlDataSource ) )
return false;
PostgresqlDataSource with;
with = (PostgresqlDataSource) other;
if ( _databaseName != null && _databaseName.equals( with._databaseName ) )
if ( _portNumber == with._portNumber &&
( ( _serverName == null && with._serverName == null ) ||
( _serverName != null && _serverName.equals( with._serverName ) ) ) )
if ( ( _user == null && with._user == null ) ||
( _user != null && _password != null && _user.equals( with._user ) &&
_password.equals( with._password ) ) )
return true;
return false;
}
public String toString()
{
if ( _description != null )
return _description;
else
{
String url;
url = "jdbc:postgresql:";
if ( _serverName != null )
{
if ( _portNumber == DEFAULT_PORT )
url = url + "//" + _serverName + "/";
else
url = url + "//" + _serverName + ":" + _portNumber + "/";
}
else if ( _portNumber != DEFAULT_PORT )
url = url + "//localhost:" + _portNumber + "/";
if ( _databaseName != null )
url = url + _databaseName;
return "DataSource " + url;
}
}
public synchronized Reference getReference()
{
Reference ref;
// We use same object as factory.
ref = new Reference( getClass().getName(), getClass().getName(), null );
// Mandatory properties
ref.add( new StringRefAddr( "description", _description ) );
ref.add( new StringRefAddr( "databaseName", _databaseName ) );
ref.add( new StringRefAddr( "loginTimeout", Integer.toString( _loginTimeout ) ) );
// Optional properties
if ( _user != null )
ref.add( new StringRefAddr( "user", _user ) );
if ( _password != null )
ref.add( new StringRefAddr( "password", _password ) );
if ( _serverName != null )
ref.add( new StringRefAddr( "serverName", _serverName ) );
if ( _portNumber != DEFAULT_PORT )
ref.add( new StringRefAddr( "portNumber", Integer.toString( _portNumber ) ) );
ref.add( new StringRefAddr( "transactionTimeout", Integer.toString( getTransactionTimeout() ) ) );
return ref;
}
public Object getObjectInstance( Object refObj, Name name, Context nameCtx, Hashtable env )
throws NamingException
{
Reference ref;
// Can only reconstruct from a reference.
if ( refObj instanceof Reference )
{
ref = (Reference) refObj;
// Make sure reference is of datasource class.
if ( ref.getClassName().equals( getClass().getName() ) )
{
PostgresqlDataSource ds;
RefAddr addr;
try
{
ds = (PostgresqlDataSource) Class.forName( ref.getClassName() ).newInstance();
}
catch ( Exception except )
{
throw new NamingException( except.toString() );
}
// Mandatory properties
ds._description = (String) ref.get( "description" ).getContent();
ds._databaseName = (String) ref.get( "databaseName" ).getContent();
ds._loginTimeout = Integer.parseInt( (String) ref.get( "loginTimeout" ).getContent() );
// Optional properties
addr = ref.get( "user" );
if ( addr != null )
ds._user = (String) addr.getContent();
addr = ref.get( "password" );
if ( addr != null )
ds._password = (String) addr.getContent();
addr = ref.get( "serverName" );
if ( addr != null )
ds._serverName = (String) addr.getContent();
addr = ref.get( "portNumber" );
if ( addr != null )
ds._portNumber = Integer.parseInt( (String) addr.getContent() );
addr = ref.get( "transactionTimeout" );
if ( addr != null )
setTransactionTimeout( Integer.parseInt( (String) addr.getContent() ) );
return ds;
}
else
throw new NamingException( "DataSource: Reference not constructed from class " + getClass().getName() );
}
else if ( refObj instanceof Remote )
return refObj;
else
return null;
}
}
......@@ -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.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.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.AbstractJdbc2Connection which provides the jdbc2
* methods. The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection
*/
public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.AbstractJdbc2Connection
{
/**
* Changes the holdability of <code>ResultSet</code> objects
* created using this <code>Connection</code> object to the given
* holdability.
*
* @param holdability a <code>ResultSet</code> holdability constant; one of
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @throws SQLException if a database access occurs, the given parameter
* is not a <code>ResultSet</code> constant indicating holdability,
* or the given holdability is not supported
* @see #getHoldability
* @see ResultSet
* @since 1.4
*/
public void setHoldability(int holdability) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves the current holdability of <code>ResultSet</code> objects
* created using this <code>Connection</code> object.
*
* @return the holdability, one of
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @throws SQLException if a database access occurs
* @see #setHoldability
* @see ResultSet
* @since 1.4
*/
public int getHoldability() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates an unnamed savepoint in the current transaction and
* returns the new <code>Savepoint</code> object that represents it.
*
* @return the new <code>Savepoint</code> object
* @exception SQLException if a database access error occurs
* or this <code>Connection</code> object is currently in
* auto-commit mode
* @see Savepoint
* @since 1.4
*/
public Savepoint setSavepoint() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates a savepoint with the given name in the current transaction
* and returns the new <code>Savepoint</code> object that represents it.
*
* @param name a <code>String</code> containing the name of the savepoint
* @return the new <code>Savepoint</code> object
* @exception SQLException if a database access error occurs
* or this <code>Connection</code> object is currently in
* auto-commit mode
* @see Savepoint
* @since 1.4
*/
public Savepoint setSavepoint(String name) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Undoes all changes made after the given <code>Savepoint</code> object
* was set.
* <P>
* This method should be used only when auto-commit has been disabled.
*
* @param savepoint the <code>Savepoint</code> object to roll back to
* @exception SQLException if a database access error occurs,
* the <code>Savepoint</code> object is no longer valid,
* or this <code>Connection</code> object is currently in
* auto-commit mode
* @see Savepoint
* @see #rollback
* @since 1.4
*/
public void rollback(Savepoint savepoint) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Removes the given <code>Savepoint</code> object from the current
* transaction. Any reference to the savepoint after it have been removed
* will cause an <code>SQLException</code> to be thrown.
*
* @param savepoint the <code>Savepoint</code> object to be removed
* @exception SQLException if a database access error occurs or
* the given <code>Savepoint</code> object is not a valid
* savepoint in the current transaction
* @since 1.4
*/
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates a <code>Statement</code> object that will generate
* <code>ResultSet</code> objects with the given type, concurrency,
* and holdability.
* This method is the same as the <code>createStatement</code> method
* above, but it allows the default result set
* type, concurrency, and holdability to be overridden.
*
* @param resultSetType one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.TYPE_FORWARD_ONLY</code>,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
* @param resultSetConcurrency one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.CONCUR_READ_ONLY</code> or
* <code>ResultSet.CONCUR_UPDATABLE</code>
* @param resultSetHoldability one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @return a new <code>Statement</code> object that will generate
* <code>ResultSet</code> objects with the given type,
* concurrency, and holdability
* @exception SQLException if a database access error occurs
* or the given parameters are not <code>ResultSet</code>
* constants indicating type, concurrency, and holdability
* @see ResultSet
* @since 1.4
*/
public Statement createStatement(int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates a <code>PreparedStatement</code> object that will generate
* <code>ResultSet</code> objects with the given type, concurrency,
* and holdability.
* <P>
* This method is the same as the <code>prepareStatement</code> method
* above, but it allows the default result set
* type, concurrency, and holdability to be overridden.
*
* @param sql a <code>String</code> object that is the SQL statement to
* be sent to the database; may contain one or more ? IN
* parameters
* @param resultSetType one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.TYPE_FORWARD_ONLY</code>,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
* @param resultSetConcurrency one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.CONCUR_READ_ONLY</code> or
* <code>ResultSet.CONCUR_UPDATABLE</code>
* @param resultSetHoldability one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @return a new <code>PreparedStatement</code> object, containing the
* pre-compiled SQL statement, that will generate
* <code>ResultSet</code> objects with the given type,
* concurrency, and holdability
* @exception SQLException if a database access error occurs
* or the given parameters are not <code>ResultSet</code>
* constants indicating type, concurrency, and holdability
* @see ResultSet
* @since 1.4
*/
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates a <code>CallableStatement</code> object that will generate
* <code>ResultSet</code> objects with the given type and concurrency.
* This method is the same as the <code>prepareCall</code> method
* above, but it allows the default result set
* type, result set concurrency type and holdability to be overridden.
*
* @param sql a <code>String</code> object that is the SQL statement to
* be sent to the database; may contain on or more ? parameters
* @param resultSetType one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.TYPE_FORWARD_ONLY</code>,
* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or
* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
* @param resultSetConcurrency one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.CONCUR_READ_ONLY</code> or
* <code>ResultSet.CONCUR_UPDATABLE</code>
* @param resultSetHoldability one of the following <code>ResultSet</code>
* constants:
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @return a new <code>CallableStatement</code> object, containing the
* pre-compiled SQL statement, that will generate
* <code>ResultSet</code> objects with the given type,
* concurrency, and holdability
* @exception SQLException if a database access error occurs
* or the given parameters are not <code>ResultSet</code>
* constants indicating type, concurrency, and holdability
* @see ResultSet
* @since 1.4
*/
public CallableStatement prepareCall(String sql, int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates a default <code>PreparedStatement</code> object that has
* the capability to retrieve auto-generated keys. The given constant
* tells the driver whether it should make auto-generated keys
* available for retrieval. This parameter is ignored if the SQL
* statement is not an <code>INSERT</code> statement.
* <P>
* <B>Note:</B> This method is optimized for handling
* parametric SQL statements that benefit from precompilation. If
* the driver supports precompilation,
* the method <code>prepareStatement</code> will send
* the statement to the database for precompilation. Some drivers
* may not support precompilation. In this case, the statement may
* not be sent to the database until the <code>PreparedStatement</code>
* object is executed. This has no direct effect on users; however, it does
* affect which methods throw certain SQLExceptions.
* <P>
* Result sets created using the returned <code>PreparedStatement</code>
* object will by default be type <code>TYPE_FORWARD_ONLY</code>
* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
*
* @param sql an SQL statement that may contain one or more '?' IN
* parameter placeholders
* @param autoGeneratedKeys a flag indicating whether auto-generated keys
* should be returned; one of the following <code>Statement</code>
* constants:
* @param autoGeneratedKeys a flag indicating that auto-generated keys should be returned, one of
* <code>Statement.RETURN_GENERATED_KEYS</code> or
* <code>Statement.NO_GENERATED_KEYS</code>.
* @return a new <code>PreparedStatement</code> object, containing the
* pre-compiled SQL statement, that will have the capability of
* returning auto-generated keys
* @exception SQLException if a database access error occurs
* or the given parameter is not a <code>Statement</code>
* constant indicating whether auto-generated keys should be
* returned
* @since 1.4
*/
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates a default <code>PreparedStatement</code> object capable
* of returning the auto-generated keys designated by the given array.
* This array contains the indexes of the columns in the target
* table that contain the auto-generated keys that should be made
* available. This array is ignored if the SQL
* statement is not an <code>INSERT</code> statement.
* <P>
* An SQL statement with or without IN parameters can be
* pre-compiled and stored in a <code>PreparedStatement</code> object. This
* object can then be used to efficiently execute this statement
* multiple times.
* <P>
* <B>Note:</B> This method is optimized for handling
* parametric SQL statements that benefit from precompilation. If
* the driver supports precompilation,
* the method <code>prepareStatement</code> will send
* the statement to the database for precompilation. Some drivers
* may not support precompilation. In this case, the statement may
* not be sent to the database until the <code>PreparedStatement</code>
* object is executed. This has no direct effect on users; however, it does
* affect which methods throw certain SQLExceptions.
* <P>
* Result sets created using the returned <code>PreparedStatement</code>
* object will by default be type <code>TYPE_FORWARD_ONLY</code>
* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
*
* @param sql an SQL statement that may contain one or more '?' IN
* parameter placeholders
* @param columnIndexes an array of column indexes indicating the columns
* that should be returned from the inserted row or rows
* @return a new <code>PreparedStatement</code> object, containing the
* pre-compiled statement, that is capable of returning the
* auto-generated keys designated by the given array of column
* indexes
* @exception SQLException if a database access error occurs
*
* @since 1.4
*/
public PreparedStatement prepareStatement(String sql, int columnIndexes[])
throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Creates a default <code>PreparedStatement</code> object capable
* of returning the auto-generated keys designated by the given array.
* This array contains the names of the columns in the target
* table that contain the auto-generated keys that should be returned.
* This array is ignored if the SQL
* statement is not an <code>INSERT</code> statement.
* <P>
* An SQL statement with or without IN parameters can be
* pre-compiled and stored in a <code>PreparedStatement</code> object. This
* object can then be used to efficiently execute this statement
* multiple times.
* <P>
* <B>Note:</B> This method is optimized for handling
* parametric SQL statements that benefit from precompilation. If
* the driver supports precompilation,
* the method <code>prepareStatement</code> will send
* the statement to the database for precompilation. Some drivers
* may not support precompilation. In this case, the statement may
* not be sent to the database until the <code>PreparedStatement</code>
* object is executed. This has no direct effect on users; however, it does
* affect which methods throw certain SQLExceptions.
* <P>
* Result sets created using the returned <code>PreparedStatement</code>
* object will by default be type <code>TYPE_FORWARD_ONLY</code>
* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.
*
* @param sql an SQL statement that may contain one or more '?' IN
* parameter placeholders
* @param columnNames an array of column names indicating the columns
* that should be returned from the inserted row or rows
* @return a new <code>PreparedStatement</code> object, containing the
* pre-compiled statement, that is capable of returning the
* auto-generated keys designated by the given array of column
* names
* @exception SQLException if a database access error occurs
*
* @since 1.4
*/
public PreparedStatement prepareStatement(String sql, String columnNames[])
throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
}
package org.postgresql.jdbc3;
import java.sql.*;
public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData
{
public AbstractJdbc3DatabaseMetaData(AbstractJdbc3Connection conn)
{
super(conn);
}
/**
* Retrieves whether this database supports savepoints.
*
* @return <code>true</code> if savepoints are supported;
* <code>false</code> otherwise
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public boolean supportsSavepoints() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves whether this database supports named parameters to callable
* statements.
*
* @return <code>true</code> if named parameters are supported;
* <code>false</code> otherwise
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public boolean supportsNamedParameters() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves whether it is possible to have multiple <code>ResultSet</code> objects
* returned from a <code>CallableStatement</code> object
* simultaneously.
*
* @return <code>true</code> if a <code>CallableStatement</code> object
* can return multiple <code>ResultSet</code> objects
* simultaneously; <code>false</code> otherwise
* @exception SQLException if a datanase access error occurs
* @since 1.4
*/
public boolean supportsMultipleOpenResults() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves whether auto-generated keys can be retrieved after
* a statement has been executed.
*
* @return <code>true</code> if auto-generated keys can be retrieved
* after a statement has executed; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public boolean supportsGetGeneratedKeys() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves a description of the user-defined type (UDT) hierarchies defined in a
* particular schema in this database. Only the immediate super type/
* sub type relationship is modeled.
* <P>
* Only supertype information for UDTs matching the catalog,
* schema, and type name is returned. The type name parameter
* may be a fully-qualified name. When the UDT name supplied is a
* fully-qualified name, the catalog and schemaPattern parameters are
* ignored.
* <P>
* If a UDT does not have a direct super type, it is not listed here.
* A row of the <code>ResultSet</code> object returned by this method
* describes the designated UDT and a direct supertype. A row has the following
* columns:
* <OL>
* <LI><B>TYPE_CAT</B> String => the UDT's catalog (may be <code>null</code>)
* <LI><B>TYPE_SCHEM</B> String => UDT's schema (may be <code>null</code>)
* <LI><B>TYPE_NAME</B> String => type name of the UDT
* <LI><B>SUPERTYPE_CAT</B> String => the direct super type's catalog
* (may be <code>null</code>)
* <LI><B>SUPERTYPE_SCHEM</B> String => the direct super type's schema
* (may be <code>null</code>)
* <LI><B>SUPERTYPE_NAME</B> String => the direct super type's name
* </OL>
*
* <P><B>Note:</B> If the driver does not support type hierarchies, an
* empty result set is returned.
*
* @param catalog a catalog name; "" retrieves those without a catalog;
* <code>null</code> means drop catalog name from the selection criteria
* @param schemaPattern a schema name pattern; "" retrieves those
* without a schema
* @param typeNamePattern a UDT name pattern; may be a fully-qualified
* name
* @return a <code>ResultSet</code> object in which a row gives information
* about the designated UDT
* @throws SQLException if a database access error occurs
* @since 1.4
*/
public ResultSet getSuperTypes(String catalog, String schemaPattern,
String typeNamePattern) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves a description of the table hierarchies defined in a particular
* schema in this database.
*
* <P>Only supertable information for tables matching the catalog, schema
* and table name are returned. The table name parameter may be a fully-
* qualified name, in which case, the catalog and schemaPattern parameters
* are ignored. If a table does not have a super table, it is not listed here.
* Supertables have to be defined in the same catalog and schema as the
* sub tables. Therefore, the type description does not need to include
* this information for the supertable.
*
* <P>Each type description has the following columns:
* <OL>
* <LI><B>TABLE_CAT</B> String => the type's catalog (may be <code>null</code>)
* <LI><B>TABLE_SCHEM</B> String => type's schema (may be <code>null</code>)
* <LI><B>TABLE_NAME</B> String => type name
* <LI><B>SUPERTABLE_NAME</B> String => the direct super type's name
* </OL>
*
* <P><B>Note:</B> If the driver does not support type hierarchies, an
* empty result set is returned.
*
* @param catalog a catalog name; "" retrieves those without a catalog;
* <code>null</code> means drop catalog name from the selection criteria
* @param schemaPattern a schema name pattern; "" retrieves those
* without a schema
* @param tableNamePattern a table name pattern; may be a fully-qualified
* name
* @return a <code>ResultSet</code> object in which each row is a type description
* @throws SQLException if a database access error occurs
* @since 1.4
*/
public ResultSet getSuperTables(String catalog, String schemaPattern,
String tableNamePattern) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves a description of the given attribute of the given type
* for a user-defined type (UDT) that is available in the given schema
* and catalog.
* <P>
* Descriptions are returned only for attributes of UDTs matching the
* catalog, schema, type, and attribute name criteria. They are ordered by
* TYPE_SCHEM, TYPE_NAME and ORDINAL_POSITION. This description
* does not contain inherited attributes.
* <P>
* The <code>ResultSet</code> object that is returned has the following
* columns:
* <OL>
* <LI><B>TYPE_CAT</B> String => type catalog (may be <code>null</code>)
* <LI><B>TYPE_SCHEM</B> String => type schema (may be <code>null</code>)
* <LI><B>TYPE_NAME</B> String => type name
* <LI><B>ATTR_NAME</B> String => attribute name
* <LI><B>DATA_TYPE</B> short => attribute type SQL type from java.sql.Types
* <LI><B>ATTR_TYPE_NAME</B> String => Data source dependent type name.
* For a UDT, the type name is fully qualified. For a REF, the type name is
* fully qualified and represents the target type of the reference type.
* <LI><B>ATTR_SIZE</B> int => column size. For char or date
* types this is the maximum number of characters; for numeric or
* decimal types this is precision.
* <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
* <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
* <LI><B>NULLABLE</B> int => whether NULL is allowed
* <UL>
* <LI> attributeNoNulls - might not allow NULL values
* <LI> attributeNullable - definitely allows NULL values
* <LI> attributeNullableUnknown - nullability unknown
* </UL>
* <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>)
* <LI><B>ATTR_DEF</B> String => default value (may be <code>null</code>)
* <LI><B>SQL_DATA_TYPE</B> int => unused
* <LI><B>SQL_DATETIME_SUB</B> int => unused
* <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
* maximum number of bytes in the column
* <LI><B>ORDINAL_POSITION</B> int => index of column in table
* (starting at 1)
* <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
* does not allow NULL values; "YES" means the column might
* allow NULL values. An empty string means unknown.
* <LI><B>SCOPE_CATALOG</B> String => catalog of table that is the
* scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
* <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the
* scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF)
* <LI><B>SCOPE_TABLE</B> String => table name that is the scope of a
* reference attribute (<code>null</code> if the DATA_TYPE isn't REF)
* <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated
* Ref type,SQL type from java.sql.Types (<code>null</code> if DATA_TYPE
* isn't DISTINCT or user-generated REF)
* </OL>
* @param catalog a catalog name; must match the catalog name as it
* is stored in the database; "" retrieves those without a catalog;
* <code>null</code> means that the catalog name should not be used to narrow
* the search
* @param schemaPattern a schema name pattern; must match the schema name
* as it is stored in the database; "" retrieves those without a schema;
* <code>null</code> means that the schema name should not be used to narrow
* the search
* @param typeNamePattern a type name pattern; must match the
* type name as it is stored in the database
* @param attributeNamePattern an attribute name pattern; must match the attribute
* name as it is declared in the database
* @return a <code>ResultSet</code> object in which each row is an
* attribute description
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public ResultSet getAttributes(String catalog, String schemaPattern,
String typeNamePattern, String attributeNamePattern)
throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves whether this database supports the given result set holdability.
*
* @param holdability one of the following constants:
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT<code>
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
* @see Connection
* @since 1.4
*/
public boolean supportsResultSetHoldability(int holdability) throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves the default holdability of this <code>ResultSet</code>
* object.
*
* @return the default holdability; either
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public int getResultSetHoldability() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves the major version number of the underlying database.
*
* @return the underlying database's major version
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public int getDatabaseMajorVersion() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves the minor version number of the underlying database.
*
* @return underlying database's minor version
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public int getDatabaseMinorVersion() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves the major JDBC version number for this
* driver.
*
* @return JDBC version major number
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public int getJDBCMajorVersion() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves the minor JDBC version number for this
* driver.
*
* @return JDBC version minor number
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public int getJDBCMinorVersion() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Indicates whether the SQLSTATEs returned by <code>SQLException.getSQLState</code>
* is X/Open (now known as Open Group) SQL CLI or SQL99.
* @return the type of SQLSTATEs, one of:
* sqlStateXOpen or
* sqlStateSQL99
* @throws SQLException if a database access error occurs
* @since 1.4
*/
public int getSQLStateType() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Indicates whether updates made to a LOB are made on a copy or directly
* to the LOB.
* @return <code>true</code> if updates are made to a copy of the LOB;
* <code>false</code> if updates are made directly to the LOB
* @throws SQLException if a database access error occurs
* @since 1.4
*/
public boolean locatorsUpdateCopy() throws SQLException {
throw org.postgresql.Driver.notImplemented();
}
/**
* Retrieves weather this database supports statement pooling.
*
* @return <code>true</code> is so;
<code>false</code> otherwise
* @throws SQLExcpetion if a database access error occurs
* @since 1.4
*/
public boolean supportsStatementPooling() 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册