1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

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.
This commit is contained in:
Peter Mount
2001-01-18 17:37:15 +00:00
parent 45b5d792af
commit 8bc9f0016b
9 changed files with 347 additions and 195 deletions

View File

@ -13,7 +13,7 @@ import org.postgresql.util.*;
* A Statement object is used for executing a static SQL statement and
* 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
* reading of another, each must have been generated by different
* Statements. All statement execute methods implicitly close a
@ -30,7 +30,9 @@ public class Statement implements java.sql.Statement
int timeout = 0; // The timeout for a query (not used)
boolean escapeProcessing = true;// escape processing flag
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
* that created us.
@ -40,6 +42,8 @@ public class Statement implements java.sql.Statement
public Statement (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
* for this to happen when it is automatically closed. The
* close method provides this immediate release.
*
* <p><B>Note:</B> A Statement is automatically closed when it is
* garbage collected. When a Statement is closed, its current
* <p><B>Note:</B> A Statement is automatically closed when it is
* garbage collected. When a Statement is closed, its current
* ResultSet, if one exists, is also closed.
*
* @exception SQLException if a database access error occurs (why?)
@ -147,7 +151,7 @@ public class Statement implements java.sql.Statement
/**
* 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
* @exception SQLException if a database access error occurs
@ -184,7 +188,7 @@ public class Statement implements java.sql.Statement
/**
* Cancel can be used by one thread to cancel a statement that
* 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
* error if you try.)
*
@ -257,7 +261,7 @@ public class Statement implements java.sql.Statement
/**
* Execute a SQL statement that may return multiple results. We
* 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.
*
* @param sql any SQL statement
@ -269,11 +273,15 @@ public class Statement implements java.sql.Statement
{
if(escapeProcessing)
sql=connection.EscapeSQL(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());
}
/**
* getResultSet returns the current result as a ResultSet. It
* should only be called once per result.
@ -313,7 +321,7 @@ public class Statement implements java.sql.Statement
result = ((org.postgresql.ResultSet)result).getNext();
return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
}
/**
* Returns the status message from the current Result.<p>
* This is used internally by the driver.
@ -326,27 +334,27 @@ public class Statement implements java.sql.Statement
return null;
return ((org.postgresql.ResultSet)result).getStatusString();
}
// ** JDBC 2 Extensions **
public void addBatch(String sql) throws SQLException
{
if(batch==null)
batch=new Vector();
batch.addElement(sql);
}
public void clearBatch() throws SQLException
{
if(batch!=null)
batch.removeAllElements();
}
public int[] executeBatch() throws SQLException
{
if(batch==null || batch.isEmpty())
throw new PSQLException("postgresql.stat.batch.empty");
int size=batch.size();
int[] result=new int[size];
int i=0;
@ -361,60 +369,63 @@ public class Statement implements java.sql.Statement
}
return result;
}
public java.sql.Connection getConnection() throws SQLException
{
return (java.sql.Connection)connection;
}
public int getFetchDirection() throws SQLException
{
throw org.postgresql.Driver.notImplemented();
throw new PSQLException("postgresql.psqlnotimp");
}
public int getFetchSize() throws SQLException
{
// This one can only return a valid value when were a cursor?
throw org.postgresql.Driver.notImplemented();
}
public int getKeysetSize() throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
//public int getKeysetSize() throws SQLException
//{
// throw org.postgresql.Driver.notImplemented();
//}
public int getResultSetConcurrency() throws SQLException
{
throw org.postgresql.Driver.notImplemented();
// new in 7.1
return concurrency;
}
public int getResultSetType() throws SQLException
{
throw org.postgresql.Driver.notImplemented();
// new in 7.1
return resultsettype;
}
public void setFetchDirection(int direction) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
public void setFetchSize(int rows) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
public void setKeysetSize(int keys) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
}
//public void setKeysetSize(int keys) throws SQLException
//{
// throw org.postgresql.Driver.notImplemented();
//}
public void setResultSetConcurrency(int value) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
concurrency=value;
}
public void setResultSetType(int value) throws SQLException
{
throw org.postgresql.Driver.notImplemented();
resultsettype=value;
}
}