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
...@@ -378,8 +378,9 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -378,8 +378,9 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
* 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
...@@ -39,6 +39,8 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -39,6 +39,8 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
// 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,7 +95,15 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -72,7 +95,15 @@ 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;
} }
/** /**
...@@ -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
...@@ -378,8 +418,15 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -378,8 +418,15 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
* 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 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); return new org.postgresql.jdbc2.ResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID);
} }
...@@ -387,54 +434,40 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co ...@@ -387,54 +434,40 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
// JDBC 2 extensions // JDBC 2 extensions
// ***************** // *****************
public java.sql.Statement createStatement(int resultSetType,int resultSetConcurrency) throws SQLException public java.util.Map getTypeMap() 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? // new in 7.1
throw org.postgresql.Driver.notImplemented(); return typemap;
} }
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 public void setTypeMap(java.util.Map map) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
public int getResultSetType() throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
public java.util.Map getTypeMap() throws SQLException
{ {
throw org.postgresql.Driver.notImplemented(); // new in 7.1
typemap=map;
} }
public void setResultSetConcurrency(int value) 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
{ {
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(); throw org.postgresql.Driver.notImplemented();
} }
public void setResultSetType(int type) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
} }
public void setTypeMap(java.util.Map map) throws SQLException // Default to the original method
{ return super.getObject(type,value);
throw org.postgresql.Driver.notImplemented();
} }
} }
// *********************************************************************** // ***********************************************************************
......
...@@ -30,6 +30,8 @@ public class Statement implements java.sql.Statement ...@@ -30,6 +30,8 @@ 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
...@@ -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;
} }
/** /**
...@@ -271,6 +275,10 @@ public class Statement implements java.sql.Statement ...@@ -271,6 +275,10 @@ public class Statement implements java.sql.Statement
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());
} }
...@@ -369,27 +377,30 @@ public class Statement implements java.sql.Statement ...@@ -369,27 +377,30 @@ public class Statement implements java.sql.Statement
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
...@@ -402,19 +413,19 @@ public class Statement implements java.sql.Statement ...@@ -402,19 +413,19 @@ public class Statement implements java.sql.Statement
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