Commit 8bc9f001 authored by Peter Mount's avatar Peter Mount

Thu Jan 18 17:37:00 GMT 2001 peter@retep.org.uk

        - Added new error message into errors.properties "postgresql.notsensitive"
          This is used by jdbc2.ResultSet when a method is called that should
          fetch the current value of a row from the database refreshRow() for
          example.
        - These methods no longer throw the not implemented but the new noupdate
          error. This is in preparation for the Updateable ResultSet support
          which will overide these methods by extending the existing class to
          implement that functionality, but needed to show something other than
          notimplemented:
            moveToCurrentRow()
            moveToInsertRow()
            rowDeleted()
            rowInserted()
            all update*() methods, except those that took the column as a String
            as they were already implemented to convert the String to an int.
        - getFetchDirection() and setFetchDirection() now throws
          "postgresql.notimp" as we only support one direction.
          The CursorResultSet will overide this when its implemented.
        - Created a new class under jdbc2 UpdateableResultSet which extends
          ResultSet and overides the relevent update methods.
          This allows us to implement them easily at a later date.
        - In jdbc2.Connection, the following methods are now implemented:
            createStatement(type,concurrency);
            getTypeMap();
            setTypeMap(Map);
        - The JDBC2 type mapping scheme almost complete, just needs SQLInput &
          SQLOutput to be implemented.
        - Removed some Statement methods that somehow appeared in Connection.
        - In jdbc2.Statement()
            getResultSetConcurrency()
            getResultSetType()
            setResultSetConcurrency()
            setResultSetType()
        - Finally removed the old 6.5.x driver.
parent 45b5d792
Thu Jan 18 17:30:00 GMT 2001 peter@retep.org.uk
- Added new error message into errors.properties "postgresql.notsensitive"
This is used by jdbc2.ResultSet when a method is called that should
fetch the current value of a row from the database refreshRow() for
example.
- These methods no longer throw the not implemented but the new noupdate
error. This is in preparation for the Updateable ResultSet support
which will overide these methods by extending the existing class to
implement that functionality, but needed to show something other than
notimplemented:
moveToCurrentRow()
moveToInsertRow()
rowDeleted()
rowInserted()
all update*() methods, except those that took the column as a String
as they were already implemented to convert the String to an int.
- getFetchDirection() and setFetchDirection() now throws
"postgresql.notimp" as we only support one direction.
The CursorResultSet will overide this when its implemented.
- Created a new class under jdbc2 UpdateableResultSet which extends
ResultSet and overides the relevent update methods.
This allows us to implement them easily at a later date.
- In jdbc2.Connection, the following methods are now implemented:
createStatement(type,concurrency);
getTypeMap();
setTypeMap(Map);
- The JDBC2 type mapping scheme almost complete, just needs SQLInput &
SQLOutput to be implemented.
- Removed some Statement methods that somehow appeared in Connection.
- In jdbc2.Statement()
getResultSetConcurrency()
getResultSetType()
setResultSetConcurrency()
setResultSetType()
- Finally removed the old 6.5.x driver.
Thu Jan 18 12:24:00 GMT 2001 peter@retep.org.uk Thu Jan 18 12:24:00 GMT 2001 peter@retep.org.uk
- These methods in org.postgresql.jdbc2.ResultSet are now implemented: - These methods in org.postgresql.jdbc2.ResultSet are now implemented:
getBigDecimal(int) ie: without a scale (why did this get missed?) getBigDecimal(int) ie: without a scale (why did this get missed?)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
build file to allow ant (http://jakarta.apache.org/ant/) to be used build file to allow ant (http://jakarta.apache.org/ant/) to be used
to build the PostgreSQL JDBC Driver. to build the PostgreSQL JDBC Driver.
$Id: build.xml,v 1.3 2001/01/18 14:50:14 peter Exp $ $Id: build.xml,v 1.4 2001/01/18 17:37:11 peter Exp $
--> -->
...@@ -95,9 +95,28 @@ ...@@ -95,9 +95,28 @@
</copy> </copy>
</target> </target>
<!-- This builds the examples -->
<target name="examples" depends="compile">
<javac srcdir="${src}" destdir="${dest}">
<include name="example/**" />
<exclude name="example/corba/**"/>
</javac>
</target>
<!-- Builds the corba example -->
<target name="corba" if="jdk1.2+">
<exec dir="${src}/example/corba" executable="idl2java">
<arg value="stock.idl" />
</exec>
<javac srcdir="${src}" destdir="${dest}">
<include name="example/corba/**" />
</javac>
</target>
<!-- This builds the jar file containing the driver --> <!-- This builds the jar file containing the driver -->
<target name="jar" depends="compile"> <target name="jar" depends="compile,examples">
<jar jarfile="${jars}/postgresql.jar" basedir="${dest}" includes="org/**" /> <jar jarfile="${jars}/postgresql.jar" basedir="${dest}" includes="org/**" />
<jar jarfile="${jars}/postgresql-examples.jar" basedir="${dest}" includes="example/**" />
</target> </target>
<!-- <!--
......
...@@ -27,5 +27,6 @@ ...@@ -27,5 +27,6 @@
<file path="CHANGELOG" /> <file path="CHANGELOG" />
<file path="Implementation" /> <file path="Implementation" />
<file path="README" /> <file path="README" />
<file path="org/postgresql/jdbc2/UpdateableResultSet.java" />
</project> </project>
...@@ -10,7 +10,7 @@ import org.postgresql.largeobject.*; ...@@ -10,7 +10,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*; import org.postgresql.util.*;
/** /**
* $Id: Connection.java,v 1.12 2001/01/18 14:50:14 peter Exp $ * $Id: Connection.java,v 1.13 2001/01/18 17:37:12 peter Exp $
* *
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class. * JDBC2 versions of the Connection class.
...@@ -396,6 +396,23 @@ public abstract class Connection ...@@ -396,6 +396,23 @@ public abstract class Connection
* @exception SQLException if a database error occurs * @exception SQLException if a database error occurs
*/ */
public java.sql.ResultSet ExecSQL(String sql) throws SQLException public java.sql.ResultSet ExecSQL(String sql) throws SQLException
{
return ExecSQL(sql,null);
}
/**
* Send a query to the backend. Returns one of the ResultSet
* objects.
*
* <B>Note:</B> there does not seem to be any method currently
* in existance to return the update count.
*
* @param sql the SQL statement to be executed
* @param stat The Statement associated with this query (may be null)
* @return a ResultSet holding the results
* @exception SQLException if a database error occurs
*/
public java.sql.ResultSet ExecSQL(String sql,java.sql.Statement stat) throws SQLException
{ {
// added Oct 7 1998 to give us thread safety. // added Oct 7 1998 to give us thread safety.
synchronized(pg_stream) { synchronized(pg_stream) {
...@@ -541,7 +558,7 @@ public abstract class Connection ...@@ -541,7 +558,7 @@ public abstract class Connection
if (final_error != null) if (final_error != null)
throw final_error; throw final_error;
return getResultSet(this, fields, tuples, recv_status, update_count, insert_oid); return getResultSet(this, stat, fields, tuples, recv_status, update_count, insert_oid);
} }
} }
...@@ -852,7 +869,7 @@ public abstract class Connection ...@@ -852,7 +869,7 @@ public abstract class Connection
* This returns a resultset. It must be overridden, so that the correct * This returns a resultset. It must be overridden, so that the correct
* version (from jdbc1 or jdbc2) are returned. * version (from jdbc1 or jdbc2) are returned.
*/ */
protected abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn, Field[] fields, Vector tuples, String status, int updateCount,int insertOID) throws SQLException; protected abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn,java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount,int insertOID) throws SQLException;
public abstract void close() throws SQLException; public abstract void close() throws SQLException;
......
...@@ -35,7 +35,8 @@ postgresql.geo.point:Conversion of point failed - {0} ...@@ -35,7 +35,8 @@ postgresql.geo.point:Conversion of point failed - {0}
postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding. If that fails, try forcing the version supplying it to the command line using the argument -Djava.version=1.1 or -Djava.version=1.2\nException thrown was {0} postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding. If that fails, try forcing the version supplying it to the command line using the argument -Djava.version=1.1 or -Djava.version=1.2\nException thrown was {0}
postgresql.lo.init:failed to initialise LargeObject API postgresql.lo.init:failed to initialise LargeObject API
postgresql.money:conversion of money failed - {0}. postgresql.money:conversion of money failed - {0}.
postgresql.noupdate:This ResultSet is not updateable postgresql.noupdate:This ResultSet is not updateable.
postgresql.notsensitive:This ResultSet is not sensitive to realtime updates after the query has run.
postgresql.psqlnotimp:The backend currently does not support this feature. postgresql.psqlnotimp:The backend currently does not support this feature.
postgresql.prep.is:InputStream as parameter not supported postgresql.prep.is:InputStream as parameter not supported
postgresql.prep.param:No value specified for parameter {0}. postgresql.prep.param:No value specified for parameter {0}.
......
...@@ -17,7 +17,7 @@ import org.postgresql.largeobject.*; ...@@ -17,7 +17,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*; import org.postgresql.util.*;
/** /**
* $Id: Connection.java,v 1.4 2000/10/09 16:48:17 momjian Exp $ * $Id: Connection.java,v 1.5 2001/01/18 17:37:13 peter Exp $
* *
* A Connection represents a session with a specific database. Within the * A Connection represents a session with a specific database. Within the
* context of a Connection, SQL statements are executed and results are * context of a Connection, SQL statements are executed and results are
...@@ -34,11 +34,11 @@ import org.postgresql.util.*; ...@@ -34,11 +34,11 @@ import org.postgresql.util.*;
* *
* @see java.sql.Connection * @see java.sql.Connection
*/ */
public class Connection extends org.postgresql.Connection implements java.sql.Connection public class Connection extends org.postgresql.Connection implements java.sql.Connection
{ {
// This is a cache of the DatabaseMetaData instance for this connection // This is a cache of the DatabaseMetaData instance for this connection
protected DatabaseMetaData metadata; protected DatabaseMetaData metadata;
/** /**
* SQL statements without parameters are normally executed using * SQL statements without parameters are normally executed using
* Statement objects. If the same SQL statement is executed many * Statement objects. If the same SQL statement is executed many
...@@ -51,7 +51,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -51,7 +51,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return new Statement(this); return new Statement(this);
} }
/** /**
* A SQL statement with or without IN parameters can be pre-compiled * A SQL statement with or without IN parameters can be pre-compiled
* and stored in a PreparedStatement object. This object can then * and stored in a PreparedStatement object. This object can then
...@@ -74,7 +74,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -74,7 +74,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return new PreparedStatement(this, sql); return new PreparedStatement(this, sql);
} }
/** /**
* A SQL stored procedure call statement is handled by creating a * A SQL stored procedure call statement is handled by creating a
* CallableStatement for it. The CallableStatement provides methods * CallableStatement for it. The CallableStatement provides methods
...@@ -99,7 +99,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -99,7 +99,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
throw new PSQLException("postgresql.con.call"); throw new PSQLException("postgresql.con.call");
// return new CallableStatement(this, sql); // return new CallableStatement(this, sql);
} }
/** /**
* A driver may convert the JDBC sql grammar into its system's * A driver may convert the JDBC sql grammar into its system's
* native SQL grammar prior to sending it; nativeSQL returns the * native SQL grammar prior to sending it; nativeSQL returns the
...@@ -114,7 +114,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -114,7 +114,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return sql; return sql;
} }
/** /**
* If a connection is in auto-commit mode, than all its SQL * If a connection is in auto-commit mode, than all its SQL
* statements will be executed and committed as individual * statements will be executed and committed as individual
...@@ -143,10 +143,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -143,10 +143,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
ExecSQL("begin"); ExecSQL("begin");
this.autoCommit = autoCommit; this.autoCommit = autoCommit;
} }
/** /**
* gets the current auto-commit state * gets the current auto-commit state
* *
* @return Current state of the auto-commit mode * @return Current state of the auto-commit mode
* @exception SQLException (why?) * @exception SQLException (why?)
* @see setAutoCommit * @see setAutoCommit
...@@ -155,7 +155,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -155,7 +155,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return this.autoCommit; return this.autoCommit;
} }
/** /**
* The method commit() makes all changes made since the previous * The method commit() makes all changes made since the previous
* commit/rollback permanent and releases any database locks currently * commit/rollback permanent and releases any database locks currently
...@@ -175,11 +175,11 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -175,11 +175,11 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
ExecSQL("begin"); ExecSQL("begin");
autoCommit = false; autoCommit = false;
} }
/** /**
* The method rollback() drops all changes made since the previous * The method rollback() drops all changes made since the previous
* commit/rollback and releases any database locks currently held by * commit/rollback and releases any database locks currently held by
* the Connection. * the Connection.
* *
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @see commit * @see commit
...@@ -193,7 +193,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -193,7 +193,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
ExecSQL("begin"); ExecSQL("begin");
autoCommit = false; autoCommit = false;
} }
/** /**
* In some cases, it is desirable to immediately release a Connection's * In some cases, it is desirable to immediately release a Connection's
* database and JDBC resources instead of waiting for them to be * database and JDBC resources instead of waiting for them to be
...@@ -216,7 +216,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -216,7 +216,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
pg_stream = null; pg_stream = null;
} }
} }
/** /**
* Tests to see if a Connection is closed * Tests to see if a Connection is closed
* *
...@@ -227,7 +227,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -227,7 +227,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return (pg_stream == null); return (pg_stream == null);
} }
/** /**
* A connection's database is able to provide information describing * A connection's database is able to provide information describing
* its tables, its supported SQL grammar, its stored procedures, the * its tables, its supported SQL grammar, its stored procedures, the
...@@ -243,7 +243,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -243,7 +243,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
metadata = new DatabaseMetaData(this); metadata = new DatabaseMetaData(this);
return metadata; return metadata;
} }
/** /**
* You can put a connection in read-only mode as a hunt to enable * You can put a connection in read-only mode as a hunt to enable
* database optimizations * database optimizations
...@@ -258,7 +258,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -258,7 +258,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
this.readOnly = readOnly; this.readOnly = readOnly;
} }
/** /**
* Tests to see if the connection is in Read Only Mode. Note that * Tests to see if the connection is in Read Only Mode. Note that
* we cannot really put the database in read only mode, but we pretend * we cannot really put the database in read only mode, but we pretend
...@@ -271,7 +271,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -271,7 +271,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return readOnly; return readOnly;
} }
/** /**
* A sub-space of this Connection's database may be selected by * A sub-space of this Connection's database may be selected by
* setting a catalog name. If the driver does not support catalogs, * setting a catalog name. If the driver does not support catalogs,
...@@ -283,7 +283,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -283,7 +283,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
// No-op // No-op
} }
/** /**
* Return the connections current catalog name, or null if no * Return the connections current catalog name, or null if no
* catalog name is set, or we dont support catalogs. * catalog name is set, or we dont support catalogs.
...@@ -295,10 +295,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -295,10 +295,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return null; return null;
} }
/** /**
* You can call this method to try to change the transaction * You can call this method to try to change the transaction
* isolation level using one of the TRANSACTION_* values. * isolation level using one of the TRANSACTION_* values.
* *
* <B>Note:</B> setTransactionIsolation cannot be called while * <B>Note:</B> setTransactionIsolation cannot be called while
* in the middle of a transaction * in the middle of a transaction
...@@ -312,42 +312,42 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -312,42 +312,42 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
public void setTransactionIsolation(int level) throws SQLException public void setTransactionIsolation(int level) throws SQLException
{ {
String q = "SET TRANSACTION ISOLATION LEVEL"; String q = "SET TRANSACTION ISOLATION LEVEL";
switch(level) { switch(level) {
case java.sql.Connection.TRANSACTION_READ_COMMITTED: case java.sql.Connection.TRANSACTION_READ_COMMITTED:
ExecSQL(q + " READ COMMITTED"); ExecSQL(q + " READ COMMITTED");
return; return;
case java.sql.Connection.TRANSACTION_SERIALIZABLE: case java.sql.Connection.TRANSACTION_SERIALIZABLE:
ExecSQL(q + " SERIALIZABLE"); ExecSQL(q + " SERIALIZABLE");
return; return;
default: default:
throw new PSQLException("postgresql.con.isolevel",new Integer(level)); throw new PSQLException("postgresql.con.isolevel",new Integer(level));
} }
} }
/** /**
* Get this Connection's current transaction isolation mode. * Get this Connection's current transaction isolation mode.
* *
* @return the current TRANSACTION_* mode value * @return the current TRANSACTION_* mode value
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
*/ */
public int getTransactionIsolation() throws SQLException public int getTransactionIsolation() throws SQLException
{ {
ExecSQL("show xactisolevel"); ExecSQL("show xactisolevel");
SQLWarning w = getWarnings(); SQLWarning w = getWarnings();
if (w != null) { if (w != null) {
if (w.getMessage().indexOf("READ COMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_COMMITTED; else if (w.getMessage().indexOf("READ COMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_COMMITTED; else
if (w.getMessage().indexOf("READ UNCOMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; else if (w.getMessage().indexOf("READ UNCOMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; else
if (w.getMessage().indexOf("REPEATABLE READ") != -1) return java.sql.Connection.TRANSACTION_REPEATABLE_READ; else if (w.getMessage().indexOf("REPEATABLE READ") != -1) return java.sql.Connection.TRANSACTION_REPEATABLE_READ; else
if (w.getMessage().indexOf("SERIALIZABLE") != -1) return java.sql.Connection.TRANSACTION_SERIALIZABLE; if (w.getMessage().indexOf("SERIALIZABLE") != -1) return java.sql.Connection.TRANSACTION_SERIALIZABLE;
} }
return java.sql.Connection.TRANSACTION_READ_COMMITTED; return java.sql.Connection.TRANSACTION_READ_COMMITTED;
} }
/** /**
* The first warning reported by calls on this Connection is * The first warning reported by calls on this Connection is
* returned. * returned.
...@@ -362,7 +362,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -362,7 +362,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return firstWarning; return firstWarning;
} }
/** /**
* After this call, getWarnings returns null until a new warning * After this call, getWarnings returns null until a new warning
* is reported for this connection. * is reported for this connection.
...@@ -373,16 +373,17 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -373,16 +373,17 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
firstWarning = null; firstWarning = null;
} }
/** /**
* This overides the method in org.postgresql.Connection and returns a * This overides the method in org.postgresql.Connection and returns a
* ResultSet. * ResultSet.
*/ */
protected java.sql.ResultSet getResultSet(org.postgresql.Connection conn, Field[] fields, Vector tuples, String status, int updateCount,int insertOID) throws SQLException protected java.sql.ResultSet getResultSet(org.postgresql.Connection conn,java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount,int insertOID) throws SQLException
{ {
// in jdbc1 stat is ignored.
return new org.postgresql.jdbc1.ResultSet((org.postgresql.jdbc1.Connection)conn,fields,tuples,status,updateCount,insertOID); return new org.postgresql.jdbc1.ResultSet((org.postgresql.jdbc1.Connection)conn,fields,tuples,status,updateCount,insertOID);
} }
} }
// *********************************************************************** // ***********************************************************************
......
...@@ -17,7 +17,7 @@ import org.postgresql.largeobject.*; ...@@ -17,7 +17,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*; import org.postgresql.util.*;
/** /**
* $Id: Connection.java,v 1.4 2000/10/09 16:48:18 momjian Exp $ * $Id: Connection.java,v 1.5 2001/01/18 17:37:14 peter Exp $
* *
* A Connection represents a session with a specific database. Within the * A Connection represents a session with a specific database. Within the
* context of a Connection, SQL statements are executed and results are * context of a Connection, SQL statements are executed and results are
...@@ -34,11 +34,13 @@ import org.postgresql.util.*; ...@@ -34,11 +34,13 @@ import org.postgresql.util.*;
* *
* @see java.sql.Connection * @see java.sql.Connection
*/ */
public class Connection extends org.postgresql.Connection implements java.sql.Connection public class Connection extends org.postgresql.Connection implements java.sql.Connection
{ {
// This is a cache of the DatabaseMetaData instance for this connection // This is a cache of the DatabaseMetaData instance for this connection
protected DatabaseMetaData metadata; protected DatabaseMetaData metadata;
protected java.util.Map typemap;
/** /**
* SQL statements without parameters are normally executed using * SQL statements without parameters are normally executed using
* Statement objects. If the same SQL statement is executed many * Statement objects. If the same SQL statement is executed many
...@@ -49,9 +51,30 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -49,9 +51,30 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
*/ */
public java.sql.Statement createStatement() throws SQLException public java.sql.Statement createStatement() throws SQLException
{ {
return new Statement(this); // The spec says default of TYPE_FORWARD_ONLY but everyone is used to
// using TYPE_SCROLL_INSENSITIVE
return createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
}
/**
* SQL statements without parameters are normally executed using
* Statement objects. If the same SQL statement is executed many
* times, it is more efficient to use a PreparedStatement
*
* @param resultSetType to use
* @param resultSetCuncurrency to use
* @return a new Statement object
* @exception SQLException passed through from the constructor
*/
public java.sql.Statement createStatement(int resultSetType,int resultSetConcurrency) throws SQLException
{
Statement s = new Statement(this);
s.setResultSetType(resultSetType);
s.setResultSetConcurrency(resultSetConcurrency);
return s;
} }
/** /**
* A SQL statement with or without IN parameters can be pre-compiled * A SQL statement with or without IN parameters can be pre-compiled
* and stored in a PreparedStatement object. This object can then * and stored in a PreparedStatement object. This object can then
...@@ -72,9 +95,17 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -72,9 +95,17 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
*/ */
public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException
{ {
return new PreparedStatement(this, sql); return prepareStatement(sql,java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
}
public java.sql.PreparedStatement prepareStatement(String sql,int resultSetType,int resultSetConcurrency) throws SQLException
{
PreparedStatement s = new PreparedStatement(this,sql);
s.setResultSetType(resultSetType);
s.setResultSetConcurrency(resultSetConcurrency);
return s;
} }
/** /**
* A SQL stored procedure call statement is handled by creating a * A SQL stored procedure call statement is handled by creating a
* CallableStatement for it. The CallableStatement provides methods * CallableStatement for it. The CallableStatement provides methods
...@@ -95,11 +126,20 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -95,11 +126,20 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
*/ */
public java.sql.CallableStatement prepareCall(String sql) throws SQLException public java.sql.CallableStatement prepareCall(String sql) throws SQLException
{
return prepareCall(sql,java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
}
public java.sql.CallableStatement prepareCall(String sql,int resultSetType,int resultSetConcurrency) throws SQLException
{ {
throw new PSQLException("postgresql.con.call"); throw new PSQLException("postgresql.con.call");
// return new CallableStatement(this, sql); //CallableStatement s = new CallableStatement(this,sql);
//s.setResultSetType(resultSetType);
//s.setResultSetConcurrency(resultSetConcurrency);
//return s;
} }
/** /**
* A driver may convert the JDBC sql grammar into its system's * A driver may convert the JDBC sql grammar into its system's
* native SQL grammar prior to sending it; nativeSQL returns the * native SQL grammar prior to sending it; nativeSQL returns the
...@@ -114,7 +154,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -114,7 +154,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return sql; return sql;
} }
/** /**
* If a connection is in auto-commit mode, than all its SQL * If a connection is in auto-commit mode, than all its SQL
* statements will be executed and committed as individual * statements will be executed and committed as individual
...@@ -143,10 +183,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -143,10 +183,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
ExecSQL("begin"); ExecSQL("begin");
this.autoCommit = autoCommit; this.autoCommit = autoCommit;
} }
/** /**
* gets the current auto-commit state * gets the current auto-commit state
* *
* @return Current state of the auto-commit mode * @return Current state of the auto-commit mode
* @exception SQLException (why?) * @exception SQLException (why?)
* @see setAutoCommit * @see setAutoCommit
...@@ -155,7 +195,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -155,7 +195,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return this.autoCommit; return this.autoCommit;
} }
/** /**
* The method commit() makes all changes made since the previous * The method commit() makes all changes made since the previous
* commit/rollback permanent and releases any database locks currently * commit/rollback permanent and releases any database locks currently
...@@ -175,11 +215,11 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -175,11 +215,11 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
ExecSQL("begin"); ExecSQL("begin");
autoCommit = false; autoCommit = false;
} }
/** /**
* The method rollback() drops all changes made since the previous * The method rollback() drops all changes made since the previous
* commit/rollback and releases any database locks currently held by * commit/rollback and releases any database locks currently held by
* the Connection. * the Connection.
* *
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
* @see commit * @see commit
...@@ -193,7 +233,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -193,7 +233,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
ExecSQL("begin"); ExecSQL("begin");
autoCommit = false; autoCommit = false;
} }
/** /**
* In some cases, it is desirable to immediately release a Connection's * In some cases, it is desirable to immediately release a Connection's
* database and JDBC resources instead of waiting for them to be * database and JDBC resources instead of waiting for them to be
...@@ -216,7 +256,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -216,7 +256,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
pg_stream = null; pg_stream = null;
} }
} }
/** /**
* Tests to see if a Connection is closed * Tests to see if a Connection is closed
* *
...@@ -227,7 +267,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -227,7 +267,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return (pg_stream == null); return (pg_stream == null);
} }
/** /**
* A connection's database is able to provide information describing * A connection's database is able to provide information describing
* its tables, its supported SQL grammar, its stored procedures, the * its tables, its supported SQL grammar, its stored procedures, the
...@@ -243,7 +283,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -243,7 +283,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
metadata = new DatabaseMetaData(this); metadata = new DatabaseMetaData(this);
return metadata; return metadata;
} }
/** /**
* You can put a connection in read-only mode as a hunt to enable * You can put a connection in read-only mode as a hunt to enable
* database optimizations * database optimizations
...@@ -258,7 +298,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -258,7 +298,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
this.readOnly = readOnly; this.readOnly = readOnly;
} }
/** /**
* Tests to see if the connection is in Read Only Mode. Note that * Tests to see if the connection is in Read Only Mode. Note that
* we cannot really put the database in read only mode, but we pretend * we cannot really put the database in read only mode, but we pretend
...@@ -271,7 +311,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -271,7 +311,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return readOnly; return readOnly;
} }
/** /**
* A sub-space of this Connection's database may be selected by * A sub-space of this Connection's database may be selected by
* setting a catalog name. If the driver does not support catalogs, * setting a catalog name. If the driver does not support catalogs,
...@@ -283,7 +323,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -283,7 +323,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
// No-op // No-op
} }
/** /**
* Return the connections current catalog name, or null if no * Return the connections current catalog name, or null if no
* catalog name is set, or we dont support catalogs. * catalog name is set, or we dont support catalogs.
...@@ -295,10 +335,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -295,10 +335,10 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return null; return null;
} }
/** /**
* You can call this method to try to change the transaction * You can call this method to try to change the transaction
* isolation level using one of the TRANSACTION_* values. * isolation level using one of the TRANSACTION_* values.
* *
* <B>Note:</B> setTransactionIsolation cannot be called while * <B>Note:</B> setTransactionIsolation cannot be called while
* in the middle of a transaction * in the middle of a transaction
...@@ -318,7 +358,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -318,7 +358,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
case java.sql.Connection.TRANSACTION_READ_COMMITTED: case java.sql.Connection.TRANSACTION_READ_COMMITTED:
ExecSQL(q + " READ COMMITTED"); ExecSQL(q + " READ COMMITTED");
return; return;
case java.sql.Connection.TRANSACTION_SERIALIZABLE: case java.sql.Connection.TRANSACTION_SERIALIZABLE:
ExecSQL(q + " SERIALIZABLE"); ExecSQL(q + " SERIALIZABLE");
return; return;
...@@ -327,27 +367,27 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -327,27 +367,27 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
throw new PSQLException("postgresql.con.isolevel",new Integer(level)); throw new PSQLException("postgresql.con.isolevel",new Integer(level));
} }
} }
/** /**
* Get this Connection's current transaction isolation mode. * Get this Connection's current transaction isolation mode.
* *
* @return the current TRANSACTION_* mode value * @return the current TRANSACTION_* mode value
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
*/ */
public int getTransactionIsolation() throws SQLException public int getTransactionIsolation() throws SQLException
{ {
ExecSQL("show xactisolevel"); ExecSQL("show xactisolevel");
SQLWarning w = getWarnings(); SQLWarning w = getWarnings();
if (w != null) { if (w != null) {
if (w.getMessage().indexOf("READ COMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_COMMITTED; else if (w.getMessage().indexOf("READ COMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_COMMITTED; else
if (w.getMessage().indexOf("READ UNCOMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; else if (w.getMessage().indexOf("READ UNCOMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; else
if (w.getMessage().indexOf("REPEATABLE READ") != -1) return java.sql.Connection.TRANSACTION_REPEATABLE_READ; else if (w.getMessage().indexOf("REPEATABLE READ") != -1) return java.sql.Connection.TRANSACTION_REPEATABLE_READ; else
if (w.getMessage().indexOf("SERIALIZABLE") != -1) return java.sql.Connection.TRANSACTION_SERIALIZABLE; if (w.getMessage().indexOf("SERIALIZABLE") != -1) return java.sql.Connection.TRANSACTION_SERIALIZABLE;
} }
return java.sql.Connection.TRANSACTION_READ_COMMITTED; return java.sql.Connection.TRANSACTION_READ_COMMITTED;
} }
/** /**
* The first warning reported by calls on this Connection is * The first warning reported by calls on this Connection is
* returned. * returned.
...@@ -362,7 +402,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -362,7 +402,7 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
return firstWarning; return firstWarning;
} }
/** /**
* After this call, getWarnings returns null until a new warning * After this call, getWarnings returns null until a new warning
* is reported for this connection. * is reported for this connection.
...@@ -373,68 +413,61 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -373,68 +413,61 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
{ {
firstWarning = null; firstWarning = null;
} }
/** /**
* This overides the method in org.postgresql.Connection and returns a * This overides the method in org.postgresql.Connection and returns a
* ResultSet. * ResultSet.
*/ */
protected java.sql.ResultSet getResultSet(org.postgresql.Connection conn, Field[] fields, Vector tuples, String status, int updateCount, int insertOID) throws SQLException protected java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat,Field[] fields, Vector tuples, String status, int updateCount, int insertOID) throws SQLException
{ {
return new org.postgresql.jdbc2.ResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID); // In 7.1 we now test concurrency to see which class to return. If we are not working with a
// Statement then default to a normal ResultSet object.
if(stat!=null) {
if(stat.getResultSetConcurrency()==java.sql.ResultSet.CONCUR_UPDATABLE)
return new org.postgresql.jdbc2.UpdateableResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID);
}
return new org.postgresql.jdbc2.ResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID);
} }
// ***************** // *****************
// JDBC 2 extensions // JDBC 2 extensions
// ***************** // *****************
public java.sql.Statement createStatement(int resultSetType,int resultSetConcurrency) throws SQLException
{
// normal create followed by 2 sets?
throw org.postgresql.Driver.notImplemented();
}
public java.sql.PreparedStatement prepareStatement(String sql,int resultSetType,int resultSetConcurrency) throws SQLException
{
// normal prepare followed by 2 sets?
throw org.postgresql.Driver.notImplemented();
}
public java.sql.CallableStatement prepareCall(String sql,int resultSetType,int resultSetConcurrency) throws SQLException
{
// normal prepare followed by 2 sets?
throw org.postgresql.Driver.notImplemented();
}
public int getResultSetConcurrency() throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
public int getResultSetType() throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
public java.util.Map getTypeMap() throws SQLException public java.util.Map getTypeMap() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // new in 7.1
} return typemap;
public void setResultSetConcurrency(int value) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
} }
public void setResultSetType(int type) throws SQLException
public void setTypeMap(java.util.Map map) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // new in 7.1
typemap=map;
} }
public void setTypeMap(java.util.Map map) throws SQLException /**
* This overides the standard internal getObject method so that we can
* check the jdbc2 type map first
*
* @return PGobject for this type, and set to value
* @exception SQLException if value is not correct for this type
* @see org.postgresql.util.Serialize
*/
public Object getObject(String type,String value) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); if(typemap!=null) {
SQLData d = (SQLData) typemap.get(type);
if(d!=null) {
// Handle the type (requires SQLInput & SQLOutput classes to be implemented)
throw org.postgresql.Driver.notImplemented();
}
}
// Default to the original method
return super.getObject(type,value);
} }
} }
// *********************************************************************** // ***********************************************************************
......
...@@ -59,6 +59,8 @@ import org.postgresql.util.*; ...@@ -59,6 +59,8 @@ import org.postgresql.util.*;
*/ */
public class ResultSet extends org.postgresql.ResultSet implements java.sql.ResultSet public class ResultSet extends org.postgresql.ResultSet implements java.sql.ResultSet
{ {
protected org.postgresql.jdbc2.Statement statement;
/** /**
* Create a new ResultSet - Note that we create ResultSets to * Create a new ResultSet - Note that we create ResultSets to
* represent the results of everything. * represent the results of everything.
...@@ -1086,7 +1088,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1086,7 +1088,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void insertRow() throws SQLException public void insertRow() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public boolean isAfterLast() throws SQLException public boolean isAfterLast() throws SQLException
...@@ -1120,12 +1123,14 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1120,12 +1123,14 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void moveToCurrentRow() throws SQLException public void moveToCurrentRow() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void moveToInsertRow() throws SQLException public void moveToInsertRow() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public boolean previous() throws SQLException public boolean previous() throws SQLException
...@@ -1138,7 +1143,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1138,7 +1143,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void refreshRow() throws SQLException public void refreshRow() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); throw new PSQLException("postgresql.notsensitive");
} }
// Peter: Implemented in 7.0 // Peter: Implemented in 7.0
...@@ -1150,40 +1155,49 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1150,40 +1155,49 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public boolean rowDeleted() throws SQLException public boolean rowDeleted() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
return false; // javac complains about not returning a value!
} }
public boolean rowInserted() throws SQLException public boolean rowInserted() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
return false; // javac complains about not returning a value!
} }
public boolean rowUpdated() throws SQLException public boolean rowUpdated() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
return false; // javac complains about not returning a value!
} }
public void setFetchDirection(int direction) throws SQLException public void setFetchDirection(int direction) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // In 7.1, the backend doesn't yet support this
throw new PSQLException("postgresql.psqlnotimp");
} }
public void setFetchSize(int rows) throws SQLException public void setFetchSize(int rows) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // Sub-classes should implement this as part of their cursor support
throw org.postgresql.Driver.notImplemented();
} }
public void setKeysetSize(int keys) throws SQLException //public void setKeysetSize(int keys) throws SQLException
{ //{
throw org.postgresql.Driver.notImplemented(); //throw org.postgresql.Driver.notImplemented();
} //}
public void updateAsciiStream(int columnIndex, public void updateAsciiStream(int columnIndex,
java.io.InputStream x, java.io.InputStream x,
int length int length
) throws SQLException ) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateAsciiStream(String columnName, public void updateAsciiStream(String columnName,
...@@ -1191,21 +1205,22 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1191,21 +1205,22 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
int length int length
) throws SQLException ) throws SQLException
{ {
updateAsciiStream(findColumn(columnName),x,length); updateAsciiStream(findColumn(columnName),x,length);
} }
public void updateBigDecimal(int columnIndex, public void updateBigDecimal(int columnIndex,
java.math.BigDecimal x java.math.BigDecimal x
) throws SQLException ) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateBigDecimal(String columnName, public void updateBigDecimal(String columnName,
java.math.BigDecimal x java.math.BigDecimal x
) throws SQLException ) throws SQLException
{ {
updateBigDecimal(findColumn(columnName),x); updateBigDecimal(findColumn(columnName),x);
} }
public void updateBinaryStream(int columnIndex, public void updateBinaryStream(int columnIndex,
...@@ -1213,7 +1228,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1213,7 +1228,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
int length int length
) throws SQLException ) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateBinaryStream(String columnName, public void updateBinaryStream(String columnName,
...@@ -1226,7 +1242,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1226,7 +1242,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateBoolean(int columnIndex,boolean x) throws SQLException public void updateBoolean(int columnIndex,boolean x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateBoolean(String columnName,boolean x) throws SQLException public void updateBoolean(String columnName,boolean x) throws SQLException
...@@ -1236,7 +1253,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1236,7 +1253,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateByte(int columnIndex,byte x) throws SQLException public void updateByte(int columnIndex,byte x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateByte(String columnName,byte x) throws SQLException public void updateByte(String columnName,byte x) throws SQLException
...@@ -1251,7 +1269,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1251,7 +1269,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateBytes(int columnIndex,byte[] x) throws SQLException public void updateBytes(int columnIndex,byte[] x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateCharacterStream(int columnIndex, public void updateCharacterStream(int columnIndex,
...@@ -1259,7 +1278,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1259,7 +1278,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
int length int length
) throws SQLException ) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateCharacterStream(String columnName, public void updateCharacterStream(String columnName,
...@@ -1272,7 +1292,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1272,7 +1292,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateDate(int columnIndex,java.sql.Date x) throws SQLException public void updateDate(int columnIndex,java.sql.Date x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateDate(String columnName,java.sql.Date x) throws SQLException public void updateDate(String columnName,java.sql.Date x) throws SQLException
...@@ -1282,7 +1303,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1282,7 +1303,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateDouble(int columnIndex,double x) throws SQLException public void updateDouble(int columnIndex,double x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateDouble(String columnName,double x) throws SQLException public void updateDouble(String columnName,double x) throws SQLException
...@@ -1292,7 +1314,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1292,7 +1314,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateFloat(int columnIndex,float x) throws SQLException public void updateFloat(int columnIndex,float x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateFloat(String columnName,float x) throws SQLException public void updateFloat(String columnName,float x) throws SQLException
...@@ -1302,7 +1325,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1302,7 +1325,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateInt(int columnIndex,int x) throws SQLException public void updateInt(int columnIndex,int x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateInt(String columnName,int x) throws SQLException public void updateInt(String columnName,int x) throws SQLException
...@@ -1312,7 +1336,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1312,7 +1336,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateLong(int columnIndex,long x) throws SQLException public void updateLong(int columnIndex,long x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateLong(String columnName,long x) throws SQLException public void updateLong(String columnName,long x) throws SQLException
...@@ -1322,7 +1347,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1322,7 +1347,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateNull(int columnIndex) throws SQLException public void updateNull(int columnIndex) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateNull(String columnName) throws SQLException public void updateNull(String columnName) throws SQLException
...@@ -1332,7 +1358,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1332,7 +1358,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateObject(int columnIndex,Object x) throws SQLException public void updateObject(int columnIndex,Object x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateObject(String columnName,Object x) throws SQLException public void updateObject(String columnName,Object x) throws SQLException
...@@ -1342,7 +1369,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1342,7 +1369,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateObject(int columnIndex,Object x,int scale) throws SQLException public void updateObject(int columnIndex,Object x,int scale) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateObject(String columnName,Object x,int scale) throws SQLException public void updateObject(String columnName,Object x,int scale) throws SQLException
...@@ -1352,12 +1380,14 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1352,12 +1380,14 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateRow() throws SQLException public void updateRow() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateShort(int columnIndex,short x) throws SQLException public void updateShort(int columnIndex,short x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateShort(String columnName,short x) throws SQLException public void updateShort(String columnName,short x) throws SQLException
...@@ -1367,7 +1397,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1367,7 +1397,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateString(int columnIndex,String x) throws SQLException public void updateString(int columnIndex,String x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateString(String columnName,String x) throws SQLException public void updateString(String columnName,String x) throws SQLException
...@@ -1377,7 +1408,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1377,7 +1408,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateTime(int columnIndex,Time x) throws SQLException public void updateTime(int columnIndex,Time x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateTime(String columnName,Time x) throws SQLException public void updateTime(String columnName,Time x) throws SQLException
...@@ -1387,7 +1419,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1387,7 +1419,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
public void updateTimestamp(int columnIndex,Timestamp x) throws SQLException public void updateTimestamp(int columnIndex,Timestamp x) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // only sub-classes implement CONCUR_UPDATEABLE
notUpdateable();
} }
public void updateTimestamp(String columnName,Timestamp x) throws SQLException public void updateTimestamp(String columnName,Timestamp x) throws SQLException
...@@ -1406,7 +1439,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu ...@@ -1406,7 +1439,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
* It's used currently by getStatement() but may also with the new core * It's used currently by getStatement() but may also with the new core
* package. * package.
*/ */
public void setStatement(org.postgresql.Statement statement) { public void setStatement(org.postgresql.jdbc2.Statement statement) {
this.statement=statement; this.statement=statement;
} }
......
...@@ -13,7 +13,7 @@ import org.postgresql.util.*; ...@@ -13,7 +13,7 @@ import org.postgresql.util.*;
* A Statement object is used for executing a static SQL statement and * A Statement object is used for executing a static SQL statement and
* obtaining the results produced by it. * obtaining the results produced by it.
* *
* <p>Only one ResultSet per Statement can be open at any point in time. * <p>Only one ResultSet per Statement can be open at any point in time.
* Therefore, if the reading of one ResultSet is interleaved with the * Therefore, if the reading of one ResultSet is interleaved with the
* reading of another, each must have been generated by different * reading of another, each must have been generated by different
* Statements. All statement execute methods implicitly close a * Statements. All statement execute methods implicitly close a
...@@ -30,7 +30,9 @@ public class Statement implements java.sql.Statement ...@@ -30,7 +30,9 @@ public class Statement implements java.sql.Statement
int timeout = 0; // The timeout for a query (not used) int timeout = 0; // The timeout for a query (not used)
boolean escapeProcessing = true;// escape processing flag boolean escapeProcessing = true;// escape processing flag
private Vector batch=null; private Vector batch=null;
int resultsettype; // the resultset type to return
int concurrency; // is it updateable or not?
/** /**
* Constructor for a Statement. It simply sets the connection * Constructor for a Statement. It simply sets the connection
* that created us. * that created us.
...@@ -40,6 +42,8 @@ public class Statement implements java.sql.Statement ...@@ -40,6 +42,8 @@ public class Statement implements java.sql.Statement
public Statement (Connection c) public Statement (Connection c)
{ {
connection = c; connection = c;
resultsettype = java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE;
concurrency = java.sql.ResultSet.CONCUR_READ_ONLY;
} }
/** /**
...@@ -82,8 +86,8 @@ public class Statement implements java.sql.Statement ...@@ -82,8 +86,8 @@ public class Statement implements java.sql.Statement
* for this to happen when it is automatically closed. The * for this to happen when it is automatically closed. The
* close method provides this immediate release. * close method provides this immediate release.
* *
* <p><B>Note:</B> A Statement is automatically closed when it is * <p><B>Note:</B> A Statement is automatically closed when it is
* garbage collected. When a Statement is closed, its current * garbage collected. When a Statement is closed, its current
* ResultSet, if one exists, is also closed. * ResultSet, if one exists, is also closed.
* *
* @exception SQLException if a database access error occurs (why?) * @exception SQLException if a database access error occurs (why?)
...@@ -147,7 +151,7 @@ public class Statement implements java.sql.Statement ...@@ -147,7 +151,7 @@ public class Statement implements java.sql.Statement
/** /**
* If escape scanning is on (the default), the driver will do escape * If escape scanning is on (the default), the driver will do escape
* substitution before sending the SQL to the database. * substitution before sending the SQL to the database.
* *
* @param enable true to enable; false to disable * @param enable true to enable; false to disable
* @exception SQLException if a database access error occurs * @exception SQLException if a database access error occurs
...@@ -184,7 +188,7 @@ public class Statement implements java.sql.Statement ...@@ -184,7 +188,7 @@ public class Statement implements java.sql.Statement
/** /**
* Cancel can be used by one thread to cancel a statement that * Cancel can be used by one thread to cancel a statement that
* is being executed by another thread. However, PostgreSQL is * is being executed by another thread. However, PostgreSQL is
* a sync. sort of thing, so this really has no meaning - we * a sync. sort of thing, so this really has no meaning - we
* define it as a no-op (i.e. you can't cancel, but there is no * define it as a no-op (i.e. you can't cancel, but there is no
* error if you try.) * error if you try.)
* *
...@@ -257,7 +261,7 @@ public class Statement implements java.sql.Statement ...@@ -257,7 +261,7 @@ public class Statement implements java.sql.Statement
/** /**
* Execute a SQL statement that may return multiple results. We * Execute a SQL statement that may return multiple results. We
* don't have to worry about this since we do not support multiple * don't have to worry about this since we do not support multiple
* ResultSets. You can use getResultSet or getUpdateCount to * ResultSets. You can use getResultSet or getUpdateCount to
* retrieve the result. * retrieve the result.
* *
* @param sql any SQL statement * @param sql any SQL statement
...@@ -269,11 +273,15 @@ public class Statement implements java.sql.Statement ...@@ -269,11 +273,15 @@ public class Statement implements java.sql.Statement
{ {
if(escapeProcessing) if(escapeProcessing)
sql=connection.EscapeSQL(sql); sql=connection.EscapeSQL(sql);
result = connection.ExecSQL(sql); result = connection.ExecSQL(sql);
// New in 7.1, required for ResultSet.getStatement() to work
((org.postgresql.jdbc2.ResultSet)result).setStatement(this);
return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet()); return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
} }
/** /**
* getResultSet returns the current result as a ResultSet. It * getResultSet returns the current result as a ResultSet. It
* should only be called once per result. * should only be called once per result.
...@@ -313,7 +321,7 @@ public class Statement implements java.sql.Statement ...@@ -313,7 +321,7 @@ public class Statement implements java.sql.Statement
result = ((org.postgresql.ResultSet)result).getNext(); result = ((org.postgresql.ResultSet)result).getNext();
return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet()); return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
} }
/** /**
* Returns the status message from the current Result.<p> * Returns the status message from the current Result.<p>
* This is used internally by the driver. * This is used internally by the driver.
...@@ -326,27 +334,27 @@ public class Statement implements java.sql.Statement ...@@ -326,27 +334,27 @@ public class Statement implements java.sql.Statement
return null; return null;
return ((org.postgresql.ResultSet)result).getStatusString(); return ((org.postgresql.ResultSet)result).getStatusString();
} }
// ** JDBC 2 Extensions ** // ** JDBC 2 Extensions **
public void addBatch(String sql) throws SQLException public void addBatch(String sql) throws SQLException
{ {
if(batch==null) if(batch==null)
batch=new Vector(); batch=new Vector();
batch.addElement(sql); batch.addElement(sql);
} }
public void clearBatch() throws SQLException public void clearBatch() throws SQLException
{ {
if(batch!=null) if(batch!=null)
batch.removeAllElements(); batch.removeAllElements();
} }
public int[] executeBatch() throws SQLException public int[] executeBatch() throws SQLException
{ {
if(batch==null || batch.isEmpty()) if(batch==null || batch.isEmpty())
throw new PSQLException("postgresql.stat.batch.empty"); throw new PSQLException("postgresql.stat.batch.empty");
int size=batch.size(); int size=batch.size();
int[] result=new int[size]; int[] result=new int[size];
int i=0; int i=0;
...@@ -361,60 +369,63 @@ public class Statement implements java.sql.Statement ...@@ -361,60 +369,63 @@ public class Statement implements java.sql.Statement
} }
return result; return result;
} }
public java.sql.Connection getConnection() throws SQLException public java.sql.Connection getConnection() throws SQLException
{ {
return (java.sql.Connection)connection; return (java.sql.Connection)connection;
} }
public int getFetchDirection() throws SQLException public int getFetchDirection() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); throw new PSQLException("postgresql.psqlnotimp");
} }
public int getFetchSize() throws SQLException public int getFetchSize() throws SQLException
{ {
// This one can only return a valid value when were a cursor?
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
public int getKeysetSize() throws SQLException //public int getKeysetSize() throws SQLException
{ //{
throw org.postgresql.Driver.notImplemented(); // throw org.postgresql.Driver.notImplemented();
} //}
public int getResultSetConcurrency() throws SQLException public int getResultSetConcurrency() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // new in 7.1
return concurrency;
} }
public int getResultSetType() throws SQLException public int getResultSetType() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // new in 7.1
return resultsettype;
} }
public void setFetchDirection(int direction) throws SQLException public void setFetchDirection(int direction) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
public void setFetchSize(int rows) throws SQLException public void setFetchSize(int rows) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); throw org.postgresql.Driver.notImplemented();
} }
public void setKeysetSize(int keys) throws SQLException //public void setKeysetSize(int keys) throws SQLException
{ //{
throw org.postgresql.Driver.notImplemented(); // throw org.postgresql.Driver.notImplemented();
} //}
public void setResultSetConcurrency(int value) throws SQLException public void setResultSetConcurrency(int value) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); concurrency=value;
} }
public void setResultSetType(int value) throws SQLException public void setResultSetType(int value) throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); resultsettype=value;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment