mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Initial restructuring to add jdbc3 support. There was a significant amount
of duplicated code between the jdbc1 and jdbc2. This checkin restructures the code so that the duplication is removed so that the jdbc3 support can be added without adding yet another copy of everything. Also many classes were renamed to avoid confusion with multiple different objects having the same name. The timestamp tests were also updated to add support for testing timestamp without time zone in addition to timestamp with time zone Modified Files: jdbc/Makefile jdbc/build.xml jdbc/example/ImageViewer.java jdbc/example/basic.java jdbc/example/blobtest.java jdbc/example/threadsafe.java jdbc/org/postgresql/Driver.java.in jdbc/org/postgresql/Field.java jdbc/org/postgresql/core/QueryExecutor.java jdbc/org/postgresql/fastpath/Fastpath.java jdbc/org/postgresql/jdbc1/CallableStatement.java jdbc/org/postgresql/jdbc1/DatabaseMetaData.java jdbc/org/postgresql/jdbc1/PreparedStatement.java jdbc/org/postgresql/jdbc2/Array.java jdbc/org/postgresql/jdbc2/CallableStatement.java jdbc/org/postgresql/jdbc2/DatabaseMetaData.java jdbc/org/postgresql/jdbc2/PreparedStatement.java jdbc/org/postgresql/jdbc2/UpdateableResultSet.java jdbc/org/postgresql/largeobject/LargeObjectManager.java jdbc/org/postgresql/largeobject/PGblob.java jdbc/org/postgresql/largeobject/PGclob.java jdbc/org/postgresql/test/jdbc2/BlobTest.java jdbc/org/postgresql/test/jdbc2/ConnectionTest.java jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java jdbc/org/postgresql/test/jdbc2/TimestampTest.java jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java jdbc/org/postgresql/util/Serialize.java Added Files: jdbc/org/postgresql/PGConnection.java jdbc/org/postgresql/PGStatement.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/jdbc1/Jdbc1Connection.java jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java jdbc/org/postgresql/jdbc1/Jdbc1Statement.java jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java jdbc/org/postgresql/jdbc2/Jdbc2Connection.java jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java jdbc/org/postgresql/jdbc2/Jdbc2Statement.java Removed Files: jdbc/org/postgresql/Connection.java jdbc/org/postgresql/ResultSet.java jdbc/org/postgresql/Statement.java jdbc/org/postgresql/jdbc1/Connection.java jdbc/org/postgresql/jdbc1/ResultSet.java jdbc/org/postgresql/jdbc1/Statement.java jdbc/org/postgresql/jdbc2/Connection.java jdbc/org/postgresql/jdbc2/ResultSet.java jdbc/org/postgresql/jdbc2/Statement.java
This commit is contained in:
@ -0,0 +1,203 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.net.ConnectException;
|
||||
import java.sql.*;
|
||||
import org.postgresql.util.PSQLException;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.1 2002/07/23 03:59:55 barry Exp $
|
||||
* This class defines methods of the jdbc2 specification. This class extends
|
||||
* org.postgresql.jdbc1.AbstractJdbc1Connection which provides the jdbc1
|
||||
* methods. The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection
|
||||
*/
|
||||
public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.AbstractJdbc1Connection
|
||||
{
|
||||
/*
|
||||
* The current type mappings
|
||||
*/
|
||||
protected java.util.Map typemap;
|
||||
|
||||
public java.sql.Statement createStatement() throws SQLException
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
public abstract java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException;
|
||||
|
||||
public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException
|
||||
{
|
||||
return prepareStatement(sql, java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||
}
|
||||
|
||||
public abstract java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) 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 abstract java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException;
|
||||
|
||||
public java.util.Map getTypeMap() throws SQLException
|
||||
{
|
||||
return typemap;
|
||||
}
|
||||
|
||||
|
||||
public void setTypeMap(java.util.Map map) throws SQLException
|
||||
{
|
||||
typemap = map;
|
||||
}
|
||||
|
||||
public void cancelQuery() throws SQLException
|
||||
{
|
||||
org.postgresql.PG_Stream cancelStream = null;
|
||||
try {
|
||||
cancelStream = new org.postgresql.PG_Stream(PG_HOST, PG_PORT);
|
||||
} catch (ConnectException cex) {
|
||||
// Added by Peter Mount <peter@retep.org.uk>
|
||||
// ConnectException is thrown when the connection cannot be made.
|
||||
// we trap this an return a more meaningful message for the end user
|
||||
throw new PSQLException ("postgresql.con.refused");
|
||||
} catch (IOException e) {
|
||||
throw new PSQLException ("postgresql.con.failed",e);
|
||||
}
|
||||
|
||||
// Now we need to construct and send a cancel packet
|
||||
try {
|
||||
cancelStream.SendInteger(16, 4);
|
||||
cancelStream.SendInteger(80877102, 4);
|
||||
cancelStream.SendInteger(pid, 4);
|
||||
cancelStream.SendInteger(ckey, 4);
|
||||
cancelStream.flush();
|
||||
}
|
||||
catch(IOException e) {
|
||||
throw new PSQLException("postgresql.con.failed",e);
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if(cancelStream != null)
|
||||
cancelStream.close();
|
||||
}
|
||||
catch(IOException e) {} // Ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This overides the standard internal getObject method so that we can
|
||||
* check the jdbc2 type map first
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// Default to the original method
|
||||
return super.getObject(type, value);
|
||||
}
|
||||
|
||||
|
||||
//Because the get/setLogStream methods are deprecated in JDBC2
|
||||
//we use the get/setLogWriter methods here for JDBC2 by overriding
|
||||
//the base version of this method
|
||||
protected void enableDriverManagerLogging() {
|
||||
if (DriverManager.getLogWriter() == null) {
|
||||
DriverManager.setLogWriter(new PrintWriter(System.out));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This implemetation uses the jdbc2Types array to support the jdbc2
|
||||
* datatypes. Basically jdbc1 and jdbc2 are the same, except that
|
||||
* jdbc2 adds the Array types.
|
||||
*/
|
||||
public int getSQLType(String pgTypeName)
|
||||
{
|
||||
int sqlType = Types.OTHER; // default value
|
||||
for (int i = 0;i < jdbc2Types.length;i++)
|
||||
{
|
||||
if (pgTypeName.equals(jdbc2Types[i]))
|
||||
{
|
||||
sqlType = jdbc2Typei[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sqlType;
|
||||
}
|
||||
|
||||
/*
|
||||
* This table holds the org.postgresql names for the types supported.
|
||||
* Any types that map to Types.OTHER (eg POINT) don't go into this table.
|
||||
* They default automatically to Types.OTHER
|
||||
*
|
||||
* Note: This must be in the same order as below.
|
||||
*
|
||||
* Tip: keep these grouped together by the Types. value
|
||||
*/
|
||||
private static final String jdbc2Types[] = {
|
||||
"int2",
|
||||
"int4", "oid",
|
||||
"int8",
|
||||
"cash", "money",
|
||||
"numeric",
|
||||
"float4",
|
||||
"float8",
|
||||
"bpchar", "char", "char2", "char4", "char8", "char16",
|
||||
"varchar", "text", "name", "filename",
|
||||
"bytea",
|
||||
"bool",
|
||||
"date",
|
||||
"time",
|
||||
"abstime", "timestamp", "timestamptz",
|
||||
"_bool", "_char", "_int2", "_int4", "_text",
|
||||
"_oid", "_varchar", "_int8", "_float4", "_float8",
|
||||
"_abstime", "_date", "_time", "_timestamp", "_numeric",
|
||||
"_bytea"
|
||||
};
|
||||
|
||||
/*
|
||||
* This table holds the JDBC type for each entry above.
|
||||
*
|
||||
* Note: This must be in the same order as above
|
||||
*
|
||||
* Tip: keep these grouped together by the Types. value
|
||||
*/
|
||||
private static final int jdbc2Typei[] = {
|
||||
Types.SMALLINT,
|
||||
Types.INTEGER, Types.INTEGER,
|
||||
Types.BIGINT,
|
||||
Types.DOUBLE, Types.DOUBLE,
|
||||
Types.NUMERIC,
|
||||
Types.REAL,
|
||||
Types.DOUBLE,
|
||||
Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR,
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.BINARY,
|
||||
Types.BIT,
|
||||
Types.DATE,
|
||||
Types.TIME,
|
||||
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,
|
||||
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
|
||||
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
|
||||
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
|
||||
Types.ARRAY
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,752 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.*;
|
||||
import java.sql.*;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Vector;
|
||||
import org.postgresql.Field;
|
||||
import org.postgresql.core.Encoding;
|
||||
import org.postgresql.largeobject.*;
|
||||
import org.postgresql.util.PGbytea;
|
||||
import org.postgresql.util.PSQLException;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.1 2002/07/23 03:59:55 barry Exp $
|
||||
* This class defines methods of the jdbc2 specification. This class extends
|
||||
* org.postgresql.jdbc1.AbstractJdbc1ResultSet which provides the jdbc1
|
||||
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2ResultSet
|
||||
*/
|
||||
public class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet
|
||||
{
|
||||
protected Jdbc2Statement statement;
|
||||
|
||||
protected String sqlQuery=null;
|
||||
|
||||
public AbstractJdbc2ResultSet(org.postgresql.PGConnection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
|
||||
{
|
||||
super(conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
|
||||
}
|
||||
|
||||
public java.net.URL getURL(int columnIndex) throws SQLException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.net.URL getURL(String columnName) throws SQLException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the value of a column in the current row as a Java object
|
||||
*
|
||||
* <p>This method will return the value of the given column as a
|
||||
* Java object. The type of the Java object will be the default
|
||||
* Java Object type corresponding to the column's SQL type, following
|
||||
* the mapping specified in the JDBC specification.
|
||||
*
|
||||
* <p>This method may also be used to read database specific abstract
|
||||
* data types.
|
||||
*
|
||||
* @param columnIndex the first column is 1, the second is 2...
|
||||
* @return a Object holding the column value
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public Object getObject(int columnIndex) throws SQLException
|
||||
{
|
||||
Field field;
|
||||
|
||||
checkResultSet( columnIndex );
|
||||
|
||||
wasNullFlag = (this_row[columnIndex - 1] == null);
|
||||
if (wasNullFlag)
|
||||
return null;
|
||||
|
||||
field = fields[columnIndex - 1];
|
||||
|
||||
// some fields can be null, mainly from those returned by MetaData methods
|
||||
if (field == null)
|
||||
{
|
||||
wasNullFlag = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (field.getSQLType())
|
||||
{
|
||||
case Types.BIT:
|
||||
return getBoolean(columnIndex) ? Boolean.TRUE : Boolean.FALSE;
|
||||
case Types.SMALLINT:
|
||||
return new Short(getShort(columnIndex));
|
||||
case Types.INTEGER:
|
||||
return new Integer(getInt(columnIndex));
|
||||
case Types.BIGINT:
|
||||
return new Long(getLong(columnIndex));
|
||||
case Types.NUMERIC:
|
||||
return getBigDecimal
|
||||
(columnIndex, (field.getMod() == -1) ? -1 : ((field.getMod() - 4) & 0xffff));
|
||||
case Types.REAL:
|
||||
return new Float(getFloat(columnIndex));
|
||||
case Types.DOUBLE:
|
||||
return new Double(getDouble(columnIndex));
|
||||
case Types.CHAR:
|
||||
case Types.VARCHAR:
|
||||
return getString(columnIndex);
|
||||
case Types.DATE:
|
||||
return getDate(columnIndex);
|
||||
case Types.TIME:
|
||||
return getTime(columnIndex);
|
||||
case Types.TIMESTAMP:
|
||||
return getTimestamp(columnIndex);
|
||||
case Types.BINARY:
|
||||
case Types.VARBINARY:
|
||||
return getBytes(columnIndex);
|
||||
case Types.ARRAY:
|
||||
return getArray(columnIndex);
|
||||
default:
|
||||
String type = field.getPGType();
|
||||
// if the backend doesn't know the type then coerce to String
|
||||
if (type.equals("unknown"))
|
||||
{
|
||||
return getString(columnIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return connection.getObject(field.getPGType(), getString(columnIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean absolute(int index) throws SQLException
|
||||
{
|
||||
// index is 1-based, but internally we use 0-based indices
|
||||
int internalIndex;
|
||||
|
||||
if (index == 0)
|
||||
throw new SQLException("Cannot move to index of 0");
|
||||
|
||||
final int rows_size = rows.size();
|
||||
|
||||
//if index<0, count from the end of the result set, but check
|
||||
//to be sure that it is not beyond the first index
|
||||
if (index < 0)
|
||||
{
|
||||
if (index >= -rows_size)
|
||||
internalIndex = rows_size + index;
|
||||
else
|
||||
{
|
||||
beforeFirst();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//must be the case that index>0,
|
||||
//find the correct place, assuming that
|
||||
//the index is not too large
|
||||
if (index <= rows_size)
|
||||
internalIndex = index - 1;
|
||||
else
|
||||
{
|
||||
afterLast();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
current_row = internalIndex;
|
||||
this_row = (byte [][])rows.elementAt(internalIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void afterLast() throws SQLException
|
||||
{
|
||||
final int rows_size = rows.size();
|
||||
if (rows_size > 0)
|
||||
current_row = rows_size;
|
||||
}
|
||||
|
||||
public void beforeFirst() throws SQLException
|
||||
{
|
||||
if (rows.size() > 0)
|
||||
current_row = -1;
|
||||
}
|
||||
|
||||
public void cancelRowUpdates() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void deleteRow() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public boolean first() throws SQLException
|
||||
{
|
||||
if (rows.size() <= 0)
|
||||
return false;
|
||||
|
||||
current_row = 0;
|
||||
this_row = (byte [][])rows.elementAt(current_row);
|
||||
|
||||
rowBuffer=new byte[this_row.length][];
|
||||
System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public java.sql.Array getArray(String colName) throws SQLException
|
||||
{
|
||||
return getArray(findColumn(colName));
|
||||
}
|
||||
|
||||
public java.sql.Array getArray(int i) throws SQLException
|
||||
{
|
||||
wasNullFlag = (this_row[i - 1] == null);
|
||||
if (wasNullFlag)
|
||||
return null;
|
||||
|
||||
if (i < 1 || i > fields.length)
|
||||
throw new PSQLException("postgresql.res.colrange");
|
||||
return (java.sql.Array) new org.postgresql.jdbc2.Array( connection, i, fields[i - 1], (java.sql.ResultSet)this );
|
||||
}
|
||||
|
||||
public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException
|
||||
{
|
||||
return getBigDecimal(columnIndex, -1);
|
||||
}
|
||||
|
||||
public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException
|
||||
{
|
||||
return getBigDecimal(findColumn(columnName));
|
||||
}
|
||||
|
||||
public Blob getBlob(String columnName) throws SQLException
|
||||
{
|
||||
return getBlob(findColumn(columnName));
|
||||
}
|
||||
|
||||
public Blob getBlob(int i) throws SQLException
|
||||
{
|
||||
return new org.postgresql.largeobject.PGblob(connection, getInt(i));
|
||||
}
|
||||
|
||||
public java.io.Reader getCharacterStream(String columnName) throws SQLException
|
||||
{
|
||||
return getCharacterStream(findColumn(columnName));
|
||||
}
|
||||
|
||||
public java.io.Reader getCharacterStream(int i) throws SQLException
|
||||
{
|
||||
checkResultSet( i );
|
||||
wasNullFlag = (this_row[i - 1] == null);
|
||||
if (wasNullFlag)
|
||||
return null;
|
||||
|
||||
if (((AbstractJdbc2Connection)connection).haveMinimumCompatibleVersion("7.2"))
|
||||
{
|
||||
//Version 7.2 supports AsciiStream for all the PG text types
|
||||
//As the spec/javadoc for this method indicate this is to be used for
|
||||
//large text values (i.e. LONGVARCHAR) PG doesn't have a separate
|
||||
//long string datatype, but with toast the text datatype is capable of
|
||||
//handling very large values. Thus the implementation ends up calling
|
||||
//getString() since there is no current way to stream the value from the server
|
||||
return new CharArrayReader(getString(i).toCharArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
// In 7.1 Handle as BLOBS so return the LargeObject input stream
|
||||
Encoding encoding = connection.getEncoding();
|
||||
InputStream input = getBinaryStream(i);
|
||||
return encoding.getDecodingReader(input);
|
||||
}
|
||||
}
|
||||
|
||||
public Clob getClob(String columnName) throws SQLException
|
||||
{
|
||||
return getClob(findColumn(columnName));
|
||||
}
|
||||
|
||||
public Clob getClob(int i) throws SQLException
|
||||
{
|
||||
return new org.postgresql.largeobject.PGclob(connection, getInt(i));
|
||||
}
|
||||
|
||||
public int getConcurrency() throws SQLException
|
||||
{
|
||||
// The standard ResultSet class will now return
|
||||
// CONCUR_READ_ONLY. A sub-class will overide this if the query was
|
||||
// updateable.
|
||||
return java.sql.ResultSet.CONCUR_READ_ONLY;
|
||||
}
|
||||
|
||||
public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException
|
||||
{
|
||||
// If I read the specs, this should use cal only if we don't
|
||||
// store the timezone, and if we do, then act just like getDate()?
|
||||
// for now...
|
||||
return getDate(i);
|
||||
}
|
||||
|
||||
public Time getTime(int i, java.util.Calendar cal) throws SQLException
|
||||
{
|
||||
// If I read the specs, this should use cal only if we don't
|
||||
// store the timezone, and if we do, then act just like getTime()?
|
||||
// for now...
|
||||
return getTime(i);
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp(int i, java.util.Calendar cal) throws SQLException
|
||||
{
|
||||
// If I read the specs, this should use cal only if we don't
|
||||
// store the timezone, and if we do, then act just like getDate()?
|
||||
// for now...
|
||||
return getTimestamp(i);
|
||||
}
|
||||
|
||||
public java.sql.Date getDate(String c, java.util.Calendar cal) throws SQLException
|
||||
{
|
||||
return getDate(findColumn(c), cal);
|
||||
}
|
||||
|
||||
public Time getTime(String c, java.util.Calendar cal) throws SQLException
|
||||
{
|
||||
return getTime(findColumn(c), cal);
|
||||
}
|
||||
|
||||
public Timestamp getTimestamp(String c, java.util.Calendar cal) throws SQLException
|
||||
{
|
||||
return getTimestamp(findColumn(c), cal);
|
||||
}
|
||||
|
||||
public int getFetchDirection() throws SQLException
|
||||
{
|
||||
//PostgreSQL normally sends rows first->last
|
||||
return java.sql.ResultSet.FETCH_FORWARD;
|
||||
}
|
||||
|
||||
public int getFetchSize() throws SQLException
|
||||
{
|
||||
// In this implementation we return the entire result set, so
|
||||
// here return the number of rows we have. Sub-classes can return a proper
|
||||
// value
|
||||
return rows.size();
|
||||
}
|
||||
|
||||
public Object getObject(String columnName, java.util.Map map) throws SQLException
|
||||
{
|
||||
return getObject(findColumn(columnName), map);
|
||||
}
|
||||
|
||||
/*
|
||||
* This checks against map for the type of column i, and if found returns
|
||||
* an object based on that mapping. The class must implement the SQLData
|
||||
* interface.
|
||||
*/
|
||||
public Object getObject(int i, java.util.Map map) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
}
|
||||
|
||||
public Ref getRef(String columnName) throws SQLException
|
||||
{
|
||||
return getRef(findColumn(columnName));
|
||||
}
|
||||
|
||||
public Ref getRef(int i) throws SQLException
|
||||
{
|
||||
//The backend doesn't yet have SQL3 REF types
|
||||
throw new PSQLException("postgresql.psqlnotimp");
|
||||
}
|
||||
|
||||
public int getRow() throws SQLException
|
||||
{
|
||||
final int rows_size = rows.size();
|
||||
|
||||
if (current_row < 0 || current_row >= rows_size)
|
||||
return 0;
|
||||
|
||||
return current_row + 1;
|
||||
}
|
||||
|
||||
// This one needs some thought, as not all ResultSets come from a statement
|
||||
public java.sql.Statement getStatement() throws SQLException
|
||||
{
|
||||
return statement;
|
||||
}
|
||||
|
||||
public int getType() throws SQLException
|
||||
{
|
||||
// This implementation allows scrolling but is not able to
|
||||
// see any changes. Sub-classes may overide this to return a more
|
||||
// meaningful result.
|
||||
return java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE;
|
||||
}
|
||||
|
||||
public void insertRow() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public boolean isAfterLast() throws SQLException
|
||||
{
|
||||
final int rows_size = rows.size();
|
||||
return (current_row >= rows_size && rows_size > 0);
|
||||
}
|
||||
|
||||
public boolean isBeforeFirst() throws SQLException
|
||||
{
|
||||
return (current_row < 0 && rows.size() > 0);
|
||||
}
|
||||
|
||||
public boolean isFirst() throws SQLException
|
||||
{
|
||||
return (current_row == 0 && rows.size() >= 0);
|
||||
}
|
||||
|
||||
public boolean isLast() throws SQLException
|
||||
{
|
||||
final int rows_size = rows.size();
|
||||
return (current_row == rows_size - 1 && rows_size > 0);
|
||||
}
|
||||
|
||||
public boolean last() throws SQLException
|
||||
{
|
||||
final int rows_size = rows.size();
|
||||
if (rows_size <= 0)
|
||||
return false;
|
||||
|
||||
current_row = rows_size - 1;
|
||||
this_row = (byte [][])rows.elementAt(current_row);
|
||||
|
||||
rowBuffer=new byte[this_row.length][];
|
||||
System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void moveToCurrentRow() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void moveToInsertRow() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public boolean previous() throws SQLException
|
||||
{
|
||||
if (--current_row < 0)
|
||||
return false;
|
||||
this_row = (byte [][])rows.elementAt(current_row);
|
||||
System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void refreshRow() throws SQLException
|
||||
{
|
||||
throw new PSQLException("postgresql.notsensitive");
|
||||
}
|
||||
|
||||
public boolean relative(int rows) throws SQLException
|
||||
{
|
||||
//have to add 1 since absolute expects a 1-based index
|
||||
return absolute(current_row + 1 + rows);
|
||||
}
|
||||
|
||||
public boolean rowDeleted() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
return false; // javac complains about not returning a value!
|
||||
}
|
||||
|
||||
public boolean rowInserted() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
return false; // javac complains about not returning a value!
|
||||
}
|
||||
|
||||
public boolean rowUpdated() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
return false; // javac complains about not returning a value!
|
||||
}
|
||||
|
||||
public void setFetchDirection(int direction) throws SQLException
|
||||
{
|
||||
throw new PSQLException("postgresql.psqlnotimp");
|
||||
}
|
||||
|
||||
public void setFetchSize(int rows) throws SQLException
|
||||
{
|
||||
// Sub-classes should implement this as part of their cursor support
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
}
|
||||
|
||||
public void updateAsciiStream(int columnIndex,
|
||||
java.io.InputStream x,
|
||||
int length
|
||||
) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateAsciiStream(String columnName,
|
||||
java.io.InputStream x,
|
||||
int length
|
||||
) throws SQLException
|
||||
{
|
||||
updateAsciiStream(findColumn(columnName), x, length);
|
||||
}
|
||||
|
||||
public void updateBigDecimal(int columnIndex,
|
||||
java.math.BigDecimal x
|
||||
) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateBigDecimal(String columnName,
|
||||
java.math.BigDecimal x
|
||||
) throws SQLException
|
||||
{
|
||||
updateBigDecimal(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateBinaryStream(int columnIndex,
|
||||
java.io.InputStream x,
|
||||
int length
|
||||
) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateBinaryStream(String columnName,
|
||||
java.io.InputStream x,
|
||||
int length
|
||||
) throws SQLException
|
||||
{
|
||||
updateBinaryStream(findColumn(columnName), x, length);
|
||||
}
|
||||
|
||||
public void updateBoolean(int columnIndex, boolean x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateBoolean(String columnName, boolean x) throws SQLException
|
||||
{
|
||||
updateBoolean(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateByte(int columnIndex, byte x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateByte(String columnName, byte x) throws SQLException
|
||||
{
|
||||
updateByte(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateBytes(String columnName, byte[] x) throws SQLException
|
||||
{
|
||||
updateBytes(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateBytes(int columnIndex, byte[] x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateCharacterStream(int columnIndex,
|
||||
java.io.Reader x,
|
||||
int length
|
||||
) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateCharacterStream(String columnName,
|
||||
java.io.Reader x,
|
||||
int length
|
||||
) throws SQLException
|
||||
{
|
||||
updateCharacterStream(findColumn(columnName), x, length);
|
||||
}
|
||||
|
||||
public void updateDate(int columnIndex, java.sql.Date x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateDate(String columnName, java.sql.Date x) throws SQLException
|
||||
{
|
||||
updateDate(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateDouble(int columnIndex, double x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateDouble(String columnName, double x) throws SQLException
|
||||
{
|
||||
updateDouble(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateFloat(int columnIndex, float x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateFloat(String columnName, float x) throws SQLException
|
||||
{
|
||||
updateFloat(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateInt(int columnIndex, int x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateInt(String columnName, int x) throws SQLException
|
||||
{
|
||||
updateInt(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateLong(int columnIndex, long x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateLong(String columnName, long x) throws SQLException
|
||||
{
|
||||
updateLong(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateNull(int columnIndex) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateNull(String columnName) throws SQLException
|
||||
{
|
||||
updateNull(findColumn(columnName));
|
||||
}
|
||||
|
||||
public void updateObject(int columnIndex, Object x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateObject(String columnName, Object x) throws SQLException
|
||||
{
|
||||
updateObject(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateObject(int columnIndex, Object x, int scale) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateObject(String columnName, Object x, int scale) throws SQLException
|
||||
{
|
||||
updateObject(findColumn(columnName), x, scale);
|
||||
}
|
||||
|
||||
public void updateRow() throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateShort(int columnIndex, short x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateShort(String columnName, short x) throws SQLException
|
||||
{
|
||||
updateShort(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateString(int columnIndex, String x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateString(String columnName, String x) throws SQLException
|
||||
{
|
||||
updateString(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateTime(int columnIndex, Time x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateTime(String columnName, Time x) throws SQLException
|
||||
{
|
||||
updateTime(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException
|
||||
{
|
||||
// only sub-classes implement CONCUR_UPDATEABLE
|
||||
notUpdateable();
|
||||
}
|
||||
|
||||
public void updateTimestamp(String columnName, Timestamp x) throws SQLException
|
||||
{
|
||||
updateTimestamp(findColumn(columnName), x);
|
||||
}
|
||||
|
||||
// helper method. Throws an SQLException when an update is not possible
|
||||
public void notUpdateable() throws SQLException
|
||||
{
|
||||
throw new PSQLException("postgresql.noupdate");
|
||||
}
|
||||
|
||||
/*
|
||||
* It's used currently by getStatement() but may also with the new core
|
||||
* package.
|
||||
*/
|
||||
public void setStatement(Jdbc2Statement statement)
|
||||
{
|
||||
this.statement = statement;
|
||||
}
|
||||
|
||||
public void setSQLQuery(String sqlQuery) {
|
||||
this.sqlQuery=sqlQuery;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,142 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Vector;
|
||||
import org.postgresql.util.PSQLException;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.1 2002/07/23 03:59:55 barry Exp $
|
||||
* This class defines methods of the jdbc2 specification. This class extends
|
||||
* org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1
|
||||
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Statement
|
||||
*/
|
||||
public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.AbstractJdbc1Statement
|
||||
{
|
||||
|
||||
protected Vector batch = null;
|
||||
protected int resultsettype; // the resultset type to return
|
||||
protected int concurrency; // is it updateable or not?
|
||||
|
||||
/*
|
||||
* 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
|
||||
* retrieve the result.
|
||||
*
|
||||
* @param sql any SQL statement
|
||||
* @return true if the next result is a ResulSet, false if it is
|
||||
* an update count or there are no more results
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public boolean execute(String sql) throws SQLException
|
||||
{
|
||||
boolean l_return = super.execute(sql);
|
||||
|
||||
//Now do the jdbc2 specific stuff
|
||||
//required for ResultSet.getStatement() to work
|
||||
((AbstractJdbc2ResultSet)result).setStatement((Jdbc2Statement)this);
|
||||
|
||||
// Added this so that the Updateable resultset knows the query that gave this
|
||||
((AbstractJdbc2ResultSet)result).setSQLQuery(sql);
|
||||
|
||||
return l_return;
|
||||
}
|
||||
|
||||
// ** 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 = new Vector();
|
||||
int size = batch.size();
|
||||
int[] result = new int[size];
|
||||
int i = 0;
|
||||
try
|
||||
{
|
||||
for (i = 0;i < size;i++)
|
||||
result[i] = this.executeUpdate((String)batch.elementAt(i));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
int[] resultSucceeded = new int[i];
|
||||
System.arraycopy(result, 0, resultSucceeded, 0, i);
|
||||
|
||||
PBatchUpdateException updex =
|
||||
new PBatchUpdateException("postgresql.stat.batch.error",
|
||||
new Integer(i), batch.elementAt(i), resultSucceeded);
|
||||
updex.setNextException(e);
|
||||
|
||||
throw updex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
batch.removeAllElements();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void cancel() throws SQLException
|
||||
{
|
||||
((AbstractJdbc2Connection)connection).cancelQuery();
|
||||
}
|
||||
|
||||
public java.sql.Connection getConnection() throws SQLException
|
||||
{
|
||||
return (java.sql.Connection)connection;
|
||||
}
|
||||
|
||||
public int getFetchDirection() throws SQLException
|
||||
{
|
||||
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 getResultSetConcurrency() throws SQLException
|
||||
{
|
||||
return concurrency;
|
||||
}
|
||||
|
||||
public int getResultSetType() throws SQLException
|
||||
{
|
||||
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 setResultSetConcurrency(int value) throws SQLException
|
||||
{
|
||||
concurrency = value;
|
||||
}
|
||||
|
||||
public void setResultSetType(int value) throws SQLException
|
||||
{
|
||||
resultsettype = value;
|
||||
}
|
||||
|
||||
}
|
@ -25,9 +25,9 @@ import org.postgresql.util.*;
|
||||
|
||||
public class Array implements java.sql.Array
|
||||
{
|
||||
private org.postgresql.Connection conn = null;
|
||||
private org.postgresql.PGConnection conn = null;
|
||||
private org.postgresql.Field field = null;
|
||||
private org.postgresql.jdbc2.ResultSet rs = null;
|
||||
private ResultSet rs;
|
||||
private int idx = 0;
|
||||
private String rawString = null;
|
||||
|
||||
@ -39,14 +39,14 @@ public class Array implements java.sql.Array
|
||||
* @param field the Field descriptor for the field to load into this Array
|
||||
* @param rs the ResultSet from which to get the data for this Array
|
||||
*/
|
||||
public Array( org.postgresql.Connection conn, int idx, Field field, org.postgresql.jdbc2.ResultSet rs )
|
||||
public Array( org.postgresql.PGConnection conn, int idx, Field field, ResultSet rs )
|
||||
throws SQLException
|
||||
{
|
||||
this.conn = conn;
|
||||
this.field = field;
|
||||
this.rs = rs;
|
||||
this.rs = rs;
|
||||
this.idx = idx;
|
||||
this.rawString = rs.getFixedString(idx);
|
||||
this.rawString = ((AbstractJdbc2ResultSet)rs).getFixedString(idx);
|
||||
}
|
||||
|
||||
public Object getArray() throws SQLException
|
||||
@ -124,33 +124,33 @@ public class Array implements java.sql.Array
|
||||
case Types.BIT:
|
||||
retVal = new boolean[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((boolean[])retVal)[i++] = ResultSet.toBoolean( arrayContents[(int)index++] );
|
||||
((boolean[])retVal)[i++] = Jdbc2ResultSet.toBoolean( arrayContents[(int)index++] );
|
||||
break;
|
||||
case Types.SMALLINT:
|
||||
case Types.INTEGER:
|
||||
retVal = new int[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((int[])retVal)[i++] = ResultSet.toInt( arrayContents[(int)index++] );
|
||||
((int[])retVal)[i++] = Jdbc2ResultSet.toInt( arrayContents[(int)index++] );
|
||||
break;
|
||||
case Types.BIGINT:
|
||||
retVal = new long[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((long[])retVal)[i++] = ResultSet.toLong( arrayContents[(int)index++] );
|
||||
((long[])retVal)[i++] = Jdbc2ResultSet.toLong( arrayContents[(int)index++] );
|
||||
break;
|
||||
case Types.NUMERIC:
|
||||
retVal = new BigDecimal[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((BigDecimal[])retVal)[i++] = ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );
|
||||
((BigDecimal[])retVal)[i++] = Jdbc2ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );
|
||||
break;
|
||||
case Types.REAL:
|
||||
retVal = new float[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((float[])retVal)[i++] = ResultSet.toFloat( arrayContents[(int)index++] );
|
||||
((float[])retVal)[i++] = Jdbc2ResultSet.toFloat( arrayContents[(int)index++] );
|
||||
break;
|
||||
case Types.DOUBLE:
|
||||
retVal = new double[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((double[])retVal)[i++] = ResultSet.toDouble( arrayContents[(int)index++] );
|
||||
((double[])retVal)[i++] = Jdbc2ResultSet.toDouble( arrayContents[(int)index++] );
|
||||
break;
|
||||
case Types.CHAR:
|
||||
case Types.VARCHAR:
|
||||
@ -161,18 +161,18 @@ public class Array implements java.sql.Array
|
||||
case Types.DATE:
|
||||
retVal = new java.sql.Date[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((java.sql.Date[])retVal)[i++] = ResultSet.toDate( arrayContents[(int)index++] );
|
||||
((java.sql.Date[])retVal)[i++] = Jdbc2ResultSet.toDate( arrayContents[(int)index++] );
|
||||
break;
|
||||
case Types.TIME:
|
||||
retVal = new java.sql.Time[ count ];
|
||||
for ( ; count > 0; count-- )
|
||||
((java.sql.Time[])retVal)[i++] = ResultSet.toTime( arrayContents[(int)index++], rs, getBaseTypeName() );
|
||||
((java.sql.Time[])retVal)[i++] = Jdbc2ResultSet.toTime( arrayContents[(int)index++], rs, getBaseTypeName() );
|
||||
break;
|
||||
case Types.TIMESTAMP:
|
||||
retVal = new Timestamp[ count ];
|
||||
StringBuffer sbuf = null;
|
||||
for ( ; count > 0; count-- )
|
||||
((java.sql.Timestamp[])retVal)[i++] = ResultSet.toTimestamp( arrayContents[(int)index++], rs, getBaseTypeName() );
|
||||
((java.sql.Timestamp[])retVal)[i++] = Jdbc2ResultSet.toTimestamp( arrayContents[(int)index++], rs, getBaseTypeName() );
|
||||
break;
|
||||
|
||||
// Other datatypes not currently supported. If you are really using other types ask
|
||||
@ -216,12 +216,12 @@ public class Array implements java.sql.Array
|
||||
Object array = getArray( index, count, map );
|
||||
Vector rows = new Vector();
|
||||
Field[] fields = new Field[2];
|
||||
fields[0] = new Field(conn, "INDEX", conn.getOID("int2"), 2);
|
||||
fields[0] = new Field(conn, "INDEX", conn.getPGType("int2"), 2);
|
||||
switch ( getBaseType() )
|
||||
{
|
||||
case Types.BIT:
|
||||
boolean[] booleanArray = (boolean[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("bool"), 1);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("bool"), 1);
|
||||
for ( int i = 0; i < booleanArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -230,11 +230,11 @@ public class Array implements java.sql.Array
|
||||
rows.addElement(tuple);
|
||||
}
|
||||
case Types.SMALLINT:
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("int2"), 2);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("int2"), 2);
|
||||
case Types.INTEGER:
|
||||
int[] intArray = (int[]) array;
|
||||
if ( fields[1] == null )
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("int4"), 4);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("int4"), 4);
|
||||
for ( int i = 0; i < intArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -245,7 +245,7 @@ public class Array implements java.sql.Array
|
||||
break;
|
||||
case Types.BIGINT:
|
||||
long[] longArray = (long[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("int8"), 8);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("int8"), 8);
|
||||
for ( int i = 0; i < longArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -256,7 +256,7 @@ public class Array implements java.sql.Array
|
||||
break;
|
||||
case Types.NUMERIC:
|
||||
BigDecimal[] bdArray = (BigDecimal[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("numeric"), -1);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("numeric"), -1);
|
||||
for ( int i = 0; i < bdArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -267,7 +267,7 @@ public class Array implements java.sql.Array
|
||||
break;
|
||||
case Types.REAL:
|
||||
float[] floatArray = (float[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("float4"), 4);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("float4"), 4);
|
||||
for ( int i = 0; i < floatArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -278,7 +278,7 @@ public class Array implements java.sql.Array
|
||||
break;
|
||||
case Types.DOUBLE:
|
||||
double[] doubleArray = (double[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("float8"), 8);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("float8"), 8);
|
||||
for ( int i = 0; i < doubleArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -288,11 +288,11 @@ public class Array implements java.sql.Array
|
||||
}
|
||||
break;
|
||||
case Types.CHAR:
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("char"), 1);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("char"), 1);
|
||||
case Types.VARCHAR:
|
||||
String[] strArray = (String[]) array;
|
||||
if ( fields[1] == null )
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("varchar"), -1);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("varchar"), -1);
|
||||
for ( int i = 0; i < strArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -303,7 +303,7 @@ public class Array implements java.sql.Array
|
||||
break;
|
||||
case Types.DATE:
|
||||
java.sql.Date[] dateArray = (java.sql.Date[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("date"), 4);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("date"), 4);
|
||||
for ( int i = 0; i < dateArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -314,7 +314,7 @@ public class Array implements java.sql.Array
|
||||
break;
|
||||
case Types.TIME:
|
||||
java.sql.Time[] timeArray = (java.sql.Time[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("time"), 8);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("time"), 8);
|
||||
for ( int i = 0; i < timeArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -325,7 +325,7 @@ public class Array implements java.sql.Array
|
||||
break;
|
||||
case Types.TIMESTAMP:
|
||||
java.sql.Timestamp[] timestampArray = (java.sql.Timestamp[]) array;
|
||||
fields[1] = new Field(conn, "VALUE", conn.getOID("timestamp"), 8);
|
||||
fields[1] = new Field(conn, "VALUE", conn.getPGType("timestamp"), 8);
|
||||
for ( int i = 0; i < timestampArray.length; i++ )
|
||||
{
|
||||
byte[][] tuple = new byte[2][0];
|
||||
@ -340,7 +340,7 @@ public class Array implements java.sql.Array
|
||||
default:
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
}
|
||||
return new ResultSet((org.postgresql.jdbc2.Connection)conn, fields, rows, "OK", 1 );
|
||||
return new Jdbc2ResultSet((org.postgresql.jdbc2.Jdbc2Connection)conn, fields, rows, "OK", 1 );
|
||||
}
|
||||
|
||||
public String toString()
|
||||
|
@ -45,7 +45,7 @@ public class CallableStatement extends org.postgresql.jdbc2.PreparedStatement im
|
||||
/*
|
||||
* @exception SQLException on failure
|
||||
*/
|
||||
public CallableStatement(Connection c, String q) throws SQLException
|
||||
public CallableStatement(Jdbc2Connection c, String q) throws SQLException
|
||||
{
|
||||
super(c, q); // don't parse yet..
|
||||
}
|
||||
|
@ -1,332 +0,0 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
|
||||
// If you make any modifications to this file, you must make sure that the
|
||||
// changes are also made (if relevent) to the related JDBC 1 class in the
|
||||
// org.postgresql.jdbc1 package.
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.sql.*;
|
||||
import org.postgresql.Field;
|
||||
import org.postgresql.fastpath.*;
|
||||
import org.postgresql.largeobject.*;
|
||||
import org.postgresql.util.*;
|
||||
|
||||
/*
|
||||
* $Id: Connection.java,v 1.20 2002/06/24 06:16:27 barry Exp $
|
||||
*
|
||||
* A Connection represents a session with a specific database. Within the
|
||||
* context of a Connection, SQL statements are executed and results are
|
||||
* returned.
|
||||
*
|
||||
* <P>A Connection's database is able to provide information describing
|
||||
* its tables, its supported SQL grammar, its stored procedures, the
|
||||
* capabilities of this connection, etc. This information is obtained
|
||||
* with the getMetaData method.
|
||||
*
|
||||
* <p><B>Note:</B> By default, the Connection automatically commits changes
|
||||
* after executing each statement. If auto-commit has been disabled, an
|
||||
* explicit commit must be done or database changes will not be saved.
|
||||
*
|
||||
* @see 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
|
||||
protected DatabaseMetaData metadata;
|
||||
|
||||
/*
|
||||
* The current type mappings
|
||||
*/
|
||||
protected java.util.Map typemap;
|
||||
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* @return a new Statement object
|
||||
* @exception SQLException passed through from the constructor
|
||||
*/
|
||||
public java.sql.Statement createStatement() throws SQLException
|
||||
{
|
||||
// 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
|
||||
* and stored in a PreparedStatement object. This object can then
|
||||
* be used to efficiently execute this statement multiple times.
|
||||
*
|
||||
* <B>Note:</B> This method is optimized for handling parametric
|
||||
* SQL statements that benefit from precompilation if the drivers
|
||||
* supports precompilation. PostgreSQL does not support precompilation.
|
||||
* In this case, the statement is not sent to the database until the
|
||||
* PreparedStatement is executed. This has no direct effect on users;
|
||||
* however it does affect which method throws certain SQLExceptions
|
||||
*
|
||||
* @param sql a SQL statement that may contain one or more '?' IN
|
||||
* parameter placeholders
|
||||
* @return a new PreparedStatement object containing the pre-compiled
|
||||
* statement.
|
||||
* @exception SQLException if a database access error occurs.
|
||||
*/
|
||||
public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException
|
||||
{
|
||||
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
|
||||
* CallableStatement for it. The CallableStatement provides methods
|
||||
* for setting up its IN and OUT parameters and methods for executing
|
||||
* it.
|
||||
*
|
||||
* <B>Note:</B> This method is optimised for handling stored procedure
|
||||
* call statements. Some drivers may send the call statement to the
|
||||
* database when the prepareCall is done; others may wait until the
|
||||
* CallableStatement is executed. This has no direct effect on users;
|
||||
* however, it does affect which method throws certain SQLExceptions
|
||||
*
|
||||
* @param sql a SQL statement that may contain one or more '?' parameter
|
||||
* placeholders. Typically this statement is a JDBC function call
|
||||
* escape string.
|
||||
* @return a new CallableStatement object containing the pre-compiled
|
||||
* SQL statement
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
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
|
||||
{
|
||||
CallableStatement s = new CallableStatement(this,sql);
|
||||
s.setResultSetType(resultSetType);
|
||||
s.setResultSetConcurrency(resultSetConcurrency);
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests to see if a Connection is closed.
|
||||
*
|
||||
* Peter Feb 7 2000: Now I've discovered that this doesn't actually obey the
|
||||
* specifications. Under JDBC2.1, this should only be valid _after_ close()
|
||||
* has been called. It's result is not guraranteed to be valid before, and
|
||||
* client code should not use it to see if a connection is open. The spec says
|
||||
* that the client should monitor the SQLExceptions thrown when their queries
|
||||
* fail because the connection is dead.
|
||||
*
|
||||
* I don't like this definition. As it doesn't hurt breaking it here, our
|
||||
* isClosed() implementation does test the connection, so for PostgreSQL, you
|
||||
* can rely on isClosed() returning a valid result.
|
||||
*
|
||||
* @return the status of the connection
|
||||
* @exception SQLException (why?)
|
||||
*/
|
||||
public boolean isClosed() throws SQLException
|
||||
{
|
||||
// If the stream is gone, then close() was called
|
||||
if (pg_stream == null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* A connection's database is able to provide information describing
|
||||
* its tables, its supported SQL grammar, its stored procedures, the
|
||||
* capabilities of this connection, etc. This information is made
|
||||
* available through a DatabaseMetaData object.
|
||||
*
|
||||
* @return a DatabaseMetaData object for this connection
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public java.sql.DatabaseMetaData getMetaData() throws SQLException
|
||||
{
|
||||
if (metadata == null)
|
||||
metadata = new DatabaseMetaData(this);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/*
|
||||
* This overides the method in org.postgresql.Connection and returns a
|
||||
* ResultSet.
|
||||
*/
|
||||
public java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) 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, binaryCursor);
|
||||
}
|
||||
|
||||
return new org.postgresql.jdbc2.ResultSet((org.postgresql.jdbc2.Connection)conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
|
||||
}
|
||||
|
||||
// *****************
|
||||
// JDBC 2 extensions
|
||||
// *****************
|
||||
|
||||
public java.util.Map getTypeMap() throws SQLException
|
||||
{
|
||||
// new in 7.1
|
||||
return typemap;
|
||||
}
|
||||
|
||||
|
||||
public void setTypeMap(java.util.Map map) throws SQLException
|
||||
{
|
||||
// new in 7.1
|
||||
typemap = map;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
||||
// Default to the original method
|
||||
return super.getObject(type, value);
|
||||
}
|
||||
|
||||
/* An implementation of the abstract method in the parent class.
|
||||
* This implemetation uses the jdbc2Types array to support the jdbc2
|
||||
* datatypes. Basically jdbc1 and jdbc2 are the same, except that
|
||||
* jdbc2 adds the Array types.
|
||||
*/
|
||||
public int getSQLType(String pgTypeName)
|
||||
{
|
||||
int sqlType = Types.OTHER; // default value
|
||||
for (int i = 0;i < jdbc2Types.length;i++)
|
||||
{
|
||||
if (pgTypeName.equals(jdbc2Types[i]))
|
||||
{
|
||||
sqlType = jdbc2Typei[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sqlType;
|
||||
}
|
||||
|
||||
/*
|
||||
* This table holds the org.postgresql names for the types supported.
|
||||
* Any types that map to Types.OTHER (eg POINT) don't go into this table.
|
||||
* They default automatically to Types.OTHER
|
||||
*
|
||||
* Note: This must be in the same order as below.
|
||||
*
|
||||
* Tip: keep these grouped together by the Types. value
|
||||
*/
|
||||
private static final String jdbc2Types[] = {
|
||||
"int2",
|
||||
"int4", "oid",
|
||||
"int8",
|
||||
"cash", "money",
|
||||
"numeric",
|
||||
"float4",
|
||||
"float8",
|
||||
"bpchar", "char", "char2", "char4", "char8", "char16",
|
||||
"varchar", "text", "name", "filename",
|
||||
"bytea",
|
||||
"bool",
|
||||
"date",
|
||||
"time",
|
||||
"abstime", "timestamp", "timestamptz",
|
||||
"_bool", "_char", "_int2", "_int4", "_text",
|
||||
"_oid", "_varchar", "_int8", "_float4", "_float8",
|
||||
"_abstime", "_date", "_time", "_timestamp", "_numeric",
|
||||
"_bytea"
|
||||
};
|
||||
|
||||
/*
|
||||
* This table holds the JDBC type for each entry above.
|
||||
*
|
||||
* Note: This must be in the same order as above
|
||||
*
|
||||
* Tip: keep these grouped together by the Types. value
|
||||
*/
|
||||
private static final int jdbc2Typei[] = {
|
||||
Types.SMALLINT,
|
||||
Types.INTEGER, Types.INTEGER,
|
||||
Types.BIGINT,
|
||||
Types.DOUBLE, Types.DOUBLE,
|
||||
Types.NUMERIC,
|
||||
Types.REAL,
|
||||
Types.DOUBLE,
|
||||
Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR, Types.CHAR,
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.BINARY,
|
||||
Types.BIT,
|
||||
Types.DATE,
|
||||
Types.TIME,
|
||||
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,
|
||||
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
|
||||
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
|
||||
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
|
||||
Types.ARRAY
|
||||
};
|
||||
|
||||
//Because the get/setLogStream methods are deprecated in JDBC2
|
||||
//we use the get/setLogWriter methods here for JDBC2 by overriding
|
||||
//the base version of this method
|
||||
protected void enableDriverManagerLogging() {
|
||||
if (DriverManager.getLogWriter() == null) {
|
||||
DriverManager.setLogWriter(new PrintWriter(System.out));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ***********************************************************************
|
||||
|
@ -15,7 +15,7 @@ import org.postgresql.util.PSQLException;
|
||||
/*
|
||||
* This class provides information about the database as a whole.
|
||||
*
|
||||
* $Id: DatabaseMetaData.java,v 1.58 2002/07/12 13:07:48 davec Exp $
|
||||
* $Id: DatabaseMetaData.java,v 1.59 2002/07/23 03:59:55 barry Exp $
|
||||
*
|
||||
* <p>Many of the methods here return lists of information in ResultSets. You
|
||||
* can use the normal ResultSet methods such as getString and getInt to
|
||||
@ -39,7 +39,7 @@ import org.postgresql.util.PSQLException;
|
||||
*/
|
||||
public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
{
|
||||
Connection connection; // The connection association
|
||||
Jdbc2Connection connection; // The connection association
|
||||
|
||||
// These define various OID's. Hopefully they will stay constant.
|
||||
static final int iVarcharOid = 1043; // OID for varchar
|
||||
@ -48,7 +48,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
static final int iInt4Oid = 23; // OID for int4
|
||||
static final int VARHDRSZ = 4; // length for int4
|
||||
|
||||
public DatabaseMetaData(Connection conn)
|
||||
public DatabaseMetaData(Jdbc2Connection conn)
|
||||
{
|
||||
this.connection = conn;
|
||||
}
|
||||
@ -1653,7 +1653,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
|
||||
v.addElement(tuple);
|
||||
}
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1731,7 +1731,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
|
||||
// add query loop here
|
||||
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1825,7 +1825,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
|
||||
byte remarks[] = null;
|
||||
|
||||
if (((org.postgresql.ResultSet)dr).getTupleCount() == 1)
|
||||
if (((AbstractJdbc2ResultSet)dr).getTupleCount() == 1)
|
||||
{
|
||||
dr.next();
|
||||
remarks = dr.getBytes(1);
|
||||
@ -1866,7 +1866,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
v.addElement(tuple);
|
||||
}
|
||||
r.close();
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
// This array contains the valid values for the types argument
|
||||
@ -1913,7 +1913,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
f[0] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
|
||||
tuple[0] = "".getBytes();
|
||||
v.addElement(tuple);
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1958,7 +1958,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
tuple[0] = getTableTypes[i][0].getBytes();
|
||||
v.addElement(tuple);
|
||||
}
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2154,7 +2154,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
}
|
||||
r.close();
|
||||
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2218,7 +2218,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
//v.addElement(tuple);
|
||||
}
|
||||
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2281,7 +2281,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
//v.addElement(tuple);
|
||||
}
|
||||
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2337,7 +2337,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
||||
f[6] = new Field(connection, "DECIMAL_DIGITS", iInt2Oid, 2);
|
||||
f[7] = new Field(connection, "PSEUDO_COLUMN", iInt2Oid, 2);
|
||||
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2680,7 +2680,7 @@ WHERE
|
||||
tuples.addElement(tuple);
|
||||
}
|
||||
|
||||
return new ResultSet(connection, f, tuples, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, tuples, "OK", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2959,7 +2959,7 @@ WHERE
|
||||
v.addElement(tuple);
|
||||
}
|
||||
rs.close();
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
throw new PSQLException("postgresql.metadata.unavailable");
|
||||
@ -3097,7 +3097,7 @@ WHERE
|
||||
}
|
||||
}
|
||||
|
||||
return new ResultSet(connection, f, v, "OK", 1);
|
||||
return new Jdbc2ResultSet(connection, f, v, "OK", 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,62 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Vector;
|
||||
import org.postgresql.Field;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Connection.java,v 1.1 2002/07/23 03:59:55 barry Exp $
|
||||
* This class implements the java.sql.Connection interface for JDBC2.
|
||||
* However most of the implementation is really done in
|
||||
* org.postgresql.jdbc2.AbstractJdbc2Connection or one of it's parents
|
||||
*/
|
||||
public class Jdbc2Connection extends org.postgresql.jdbc2.AbstractJdbc2Connection implements java.sql.Connection
|
||||
{
|
||||
|
||||
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
|
||||
{
|
||||
Jdbc2Statement s = new Jdbc2Statement(this);
|
||||
s.setResultSetType(resultSetType);
|
||||
s.setResultSetConcurrency(resultSetConcurrency);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
|
||||
{
|
||||
org.postgresql.jdbc2.PreparedStatement s = new org.postgresql.jdbc2.PreparedStatement(this, sql);
|
||||
s.setResultSetType(resultSetType);
|
||||
s.setResultSetConcurrency(resultSetConcurrency);
|
||||
return s;
|
||||
}
|
||||
|
||||
public java.sql.CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
|
||||
{
|
||||
org.postgresql.jdbc2.CallableStatement s = new org.postgresql.jdbc2.CallableStatement(this,sql);
|
||||
s.setResultSetType(resultSetType);
|
||||
s.setResultSetConcurrency(resultSetConcurrency);
|
||||
return s;
|
||||
}
|
||||
|
||||
public java.sql.DatabaseMetaData getMetaData() throws SQLException
|
||||
{
|
||||
if (metadata == null)
|
||||
metadata = new org.postgresql.jdbc2.DatabaseMetaData(this);
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public java.sql.ResultSet getResultSet(java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
|
||||
{
|
||||
if (stat != null)
|
||||
{
|
||||
if (stat.getResultSetConcurrency() == java.sql.ResultSet.CONCUR_UPDATABLE)
|
||||
return new org.postgresql.jdbc2.UpdateableResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
|
||||
}
|
||||
|
||||
return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
32
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
Normal file
32
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
Normal file
@ -0,0 +1,32 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Vector;
|
||||
import org.postgresql.Field;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.1 2002/07/23 03:59:55 barry Exp $
|
||||
* This class implements the java.sql.ResultSet interface for JDBC2.
|
||||
* However most of the implementation is really done in
|
||||
* org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents
|
||||
*/
|
||||
public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet implements java.sql.ResultSet
|
||||
{
|
||||
|
||||
public Jdbc2ResultSet(Jdbc2Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
|
||||
{
|
||||
super(conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
|
||||
}
|
||||
|
||||
public Jdbc2ResultSet(Jdbc2Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
|
||||
{
|
||||
super(conn, fields, tuples, status, updateCount, 0, false);
|
||||
}
|
||||
|
||||
public java.sql.ResultSetMetaData getMetaData() throws SQLException
|
||||
{
|
||||
return new ResultSetMetaData(rows, fields);
|
||||
}
|
||||
|
||||
}
|
||||
|
21
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
Normal file
21
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
Normal file
@ -0,0 +1,21 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.1 2002/07/23 03:59:55 barry Exp $
|
||||
* This class implements the java.sql.Statement interface for JDBC2.
|
||||
* However most of the implementation is really done in
|
||||
* org.postgresql.jdbc2.AbstractJdbc2Statement or one of it's parents
|
||||
*/
|
||||
public class Jdbc2Statement extends org.postgresql.jdbc2.AbstractJdbc2Statement implements java.sql.Statement
|
||||
{
|
||||
|
||||
public Jdbc2Statement (Jdbc2Connection c)
|
||||
{
|
||||
connection = c;
|
||||
resultsettype = java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE;
|
||||
concurrency = java.sql.ResultSet.CONCUR_READ_ONLY;
|
||||
}
|
||||
|
||||
}
|
@ -29,12 +29,12 @@ import org.postgresql.util.*;
|
||||
* @see ResultSet
|
||||
* @see java.sql.PreparedStatement
|
||||
*/
|
||||
public class PreparedStatement extends Statement implements java.sql.PreparedStatement
|
||||
public class PreparedStatement extends Jdbc2Statement implements java.sql.PreparedStatement
|
||||
{
|
||||
String sql;
|
||||
String[] templateStrings;
|
||||
String[] inStrings;
|
||||
Connection connection;
|
||||
Jdbc2Connection connection;
|
||||
|
||||
// Some performance caches
|
||||
private StringBuffer sbuf = new StringBuffer();
|
||||
@ -49,7 +49,7 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
|
||||
* @param sql the SQL statement with ? for IN markers
|
||||
* @exception SQLException if something bad occurs
|
||||
*/
|
||||
public PreparedStatement(Connection connection, String sql) throws SQLException
|
||||
public PreparedStatement(Jdbc2Connection connection, String sql) throws SQLException
|
||||
{
|
||||
super(connection);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,381 +0,0 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
// IMPORTANT NOTE: This file implements the JDBC 2 version of the driver.
|
||||
// If you make any modifications to this file, you must make sure that the
|
||||
// changes are also made (if relevent) to the related JDBC 1 class in the
|
||||
// org.postgresql.jdbc1 package.
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Vector;
|
||||
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.
|
||||
* 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
|
||||
* statement's current ResultSet if an open one exists.
|
||||
*
|
||||
* @see java.sql.Statement
|
||||
* @see ResultSet
|
||||
*/
|
||||
public class Statement extends org.postgresql.Statement implements java.sql.Statement
|
||||
{
|
||||
private Connection connection; // The connection who created us
|
||||
private Vector batch = null;
|
||||
private int resultsettype; // the resultset type to return
|
||||
private int concurrency; // is it updateable or not?
|
||||
|
||||
/*
|
||||
* Constructor for a Statement. It simply sets the connection
|
||||
* that created us.
|
||||
*
|
||||
* @param c the Connection instantation that creates us
|
||||
*/
|
||||
public Statement (Connection c)
|
||||
{
|
||||
connection = c;
|
||||
resultsettype = java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE;
|
||||
concurrency = java.sql.ResultSet.CONCUR_READ_ONLY;
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute a SQL statement that retruns a single ResultSet
|
||||
*
|
||||
* @param sql typically a static SQL SELECT statement
|
||||
* @return a ResulSet that contains the data produced by the query
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public java.sql.ResultSet executeQuery(String sql) throws SQLException
|
||||
{
|
||||
this.execute(sql);
|
||||
while (result != null && !((org.postgresql.ResultSet)result).reallyResultSet())
|
||||
result = ((org.postgresql.ResultSet)result).getNext();
|
||||
if (result == null)
|
||||
throw new PSQLException("postgresql.stat.noresult");
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute a SQL INSERT, UPDATE or DELETE statement. In addition
|
||||
* SQL statements that return nothing such as SQL DDL statements
|
||||
* can be executed
|
||||
*
|
||||
* @param sql a SQL statement
|
||||
* @return either a row count, or 0 for SQL commands
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public int executeUpdate(String sql) throws SQLException
|
||||
{
|
||||
this.execute(sql);
|
||||
if (((org.postgresql.ResultSet)result).reallyResultSet())
|
||||
throw new PSQLException("postgresql.stat.result");
|
||||
return this.getUpdateCount();
|
||||
}
|
||||
|
||||
/*
|
||||
* setCursorName defines the SQL cursor name that will be used by
|
||||
* subsequent execute methods. This name can then be used in SQL
|
||||
* positioned update/delete statements to identify the current row
|
||||
* in the ResultSet generated by this statement. If a database
|
||||
* doesn't support positioned update/delete, this method is a
|
||||
* no-op.
|
||||
*
|
||||
* <p><B>Note:</B> By definition, positioned update/delete execution
|
||||
* must be done by a different Statement than the one which
|
||||
* generated the ResultSet being used for positioning. Also, cursor
|
||||
* names must be unique within a Connection.
|
||||
*
|
||||
* <p>We throw an additional constriction. There can only be one
|
||||
* cursor active at any one time.
|
||||
*
|
||||
* @param name the new cursor name
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public void setCursorName(String name) throws SQLException
|
||||
{
|
||||
connection.setCursorName(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
* retrieve the result.
|
||||
*
|
||||
* @param sql any SQL statement
|
||||
* @return true if the next result is a ResulSet, false if it is
|
||||
* an update count or there are no more results
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public boolean execute(String sql) throws SQLException
|
||||
{
|
||||
if (escapeProcessing)
|
||||
sql = escapeSQL(sql);
|
||||
|
||||
// New in 7.1, if we have a previous resultset then force it to close
|
||||
// This brings us nearer to compliance, and helps memory management.
|
||||
// Internal stuff will call ExecSQL directly, bypassing this.
|
||||
if (result != null)
|
||||
{
|
||||
java.sql.ResultSet rs = getResultSet();
|
||||
if (rs != null)
|
||||
rs.close();
|
||||
}
|
||||
|
||||
|
||||
// New in 7.1, pass Statement so that ExecSQL can customise to it
|
||||
result = connection.ExecSQL(sql, this);
|
||||
|
||||
// New in 7.1, required for ResultSet.getStatement() to work
|
||||
((org.postgresql.jdbc2.ResultSet)result).setStatement(this);
|
||||
|
||||
// Added this so that the Updateable resultset knows the query that gave this
|
||||
((org.postgresql.jdbc2.ResultSet)result).setSQLQuery(sql);
|
||||
|
||||
|
||||
return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
|
||||
}
|
||||
|
||||
/*
|
||||
* getUpdateCount returns the current result as an update count,
|
||||
* if the result is a ResultSet or there are no more results, -1
|
||||
* is returned. It should only be called once per result.
|
||||
*
|
||||
* @return the current result as an update count.
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public int getUpdateCount() throws SQLException
|
||||
{
|
||||
if (result == null)
|
||||
return -1;
|
||||
if (((org.postgresql.ResultSet)result).reallyResultSet())
|
||||
return -1;
|
||||
return ((org.postgresql.ResultSet)result).getResultCount();
|
||||
}
|
||||
|
||||
/*
|
||||
* getMoreResults moves to a Statement's next result. If it returns
|
||||
* true, this result is a ResulSet.
|
||||
*
|
||||
* @return true if the next ResultSet is valid
|
||||
* @exception SQLException if a database access error occurs
|
||||
*/
|
||||
public boolean getMoreResults() throws SQLException
|
||||
{
|
||||
result = ((org.postgresql.ResultSet)result).getNext();
|
||||
return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
|
||||
}
|
||||
|
||||
// ** 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 = new Vector();
|
||||
int size = batch.size();
|
||||
int[] result = new int[size];
|
||||
int i = 0;
|
||||
try
|
||||
{
|
||||
for (i = 0;i < size;i++)
|
||||
result[i] = this.executeUpdate((String)batch.elementAt(i));
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
int[] resultSucceeded = new int[i];
|
||||
System.arraycopy(result, 0, resultSucceeded, 0, i);
|
||||
|
||||
PBatchUpdateException updex =
|
||||
new PBatchUpdateException("postgresql.stat.batch.error",
|
||||
new Integer(i), batch.elementAt(i), resultSucceeded);
|
||||
updex.setNextException(e);
|
||||
|
||||
throw updex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
batch.removeAllElements();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void cancel() throws SQLException
|
||||
{
|
||||
connection.cancelQuery();
|
||||
}
|
||||
|
||||
public java.sql.Connection getConnection() throws SQLException
|
||||
{
|
||||
return (java.sql.Connection)connection;
|
||||
}
|
||||
|
||||
public int getFetchDirection() throws SQLException
|
||||
{
|
||||
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 getResultSetConcurrency() throws SQLException
|
||||
{
|
||||
// new in 7.1
|
||||
return concurrency;
|
||||
}
|
||||
|
||||
public int getResultSetType() throws SQLException
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
|
||||
/*
|
||||
* New in 7.1
|
||||
*/
|
||||
public void setResultSetConcurrency(int value) throws SQLException
|
||||
{
|
||||
concurrency = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* New in 7.1
|
||||
*/
|
||||
public void setResultSetType(int value) throws SQLException
|
||||
{
|
||||
resultsettype = value;
|
||||
}
|
||||
|
||||
// In JDK 1.4 not implemented
|
||||
/**
|
||||
*
|
||||
* @param num
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public boolean getMoreResults(int num) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public java.sql.ResultSet getGeneratedKeys() throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public int executeUpdate(String a, int b) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public int executeUpdate(String a, int[] b) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
|
||||
}
|
||||
|
||||
public int executeUpdate(String a, String[] b) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public boolean execute(String a, int b) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public boolean execute(String a, int[] b) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public boolean execute(String a, String[] b) throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public int getResultSetHoldability() throws SQLException
|
||||
{
|
||||
throw org.postgresql.Driver.notImplemented();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package org.postgresql.jdbc2;
|
||||
|
||||
// IMPORTANT NOTE: This is the begining of supporting updateable ResultSets.
|
||||
// It is not a working solution (yet)!
|
||||
//
|
||||
// You will notice here we really do throw org.postgresql.Driver.notImplemented()
|
||||
// This is because here we should be updateable, so any unimplemented methods
|
||||
// must say so.
|
||||
//
|
||||
@ -27,7 +25,7 @@ import org.postgresql.Driver;
|
||||
* @see ResultSetMetaData
|
||||
* @see java.sql.ResultSet
|
||||
*/
|
||||
public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
|
||||
public class UpdateableResultSet extends org.postgresql.jdbc2.Jdbc2ResultSet
|
||||
{
|
||||
|
||||
|
||||
@ -118,7 +116,7 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
|
||||
* @param updateCount the number of rows affected by the operation
|
||||
* @param cursor the positioned update/delete cursor name
|
||||
*/
|
||||
public UpdateableResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
|
||||
public UpdateableResultSet(Jdbc2Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
|
||||
{
|
||||
super(conn, fields, tuples, status, updateCount, insertOID, binaryCursor);
|
||||
}
|
||||
@ -274,7 +272,7 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
|
||||
{
|
||||
// we have to get the last inserted OID and put it in the resultset
|
||||
|
||||
long insertedOID = ((org.postgresql.Statement)insertStatement).getLastOID();
|
||||
long insertedOID = ((AbstractJdbc2Statement)insertStatement).getLastOID();
|
||||
|
||||
updateValues.put("oid", new Long(insertedOID) );
|
||||
|
||||
@ -670,7 +668,7 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
|
||||
selectStatement.setObject( i, ((PrimaryKey)primaryKeys.get(j)).getValue() );
|
||||
}
|
||||
|
||||
org.postgresql.jdbc2.ResultSet rs = (org.postgresql.jdbc2.ResultSet) selectStatement.executeQuery();
|
||||
Jdbc2ResultSet rs = (Jdbc2ResultSet) selectStatement.executeQuery();
|
||||
|
||||
if( rs.first() )
|
||||
{
|
||||
@ -1274,7 +1272,7 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
|
||||
else
|
||||
{
|
||||
// otherwise go and get the primary keys and create a hashtable of keys
|
||||
java.sql.ResultSet rs = ((org.postgresql.jdbc2.Connection)connection).getMetaData().getPrimaryKeys("","",tableName);
|
||||
java.sql.ResultSet rs = ((java.sql.Connection)connection).getMetaData().getPrimaryKeys("","",tableName);
|
||||
|
||||
|
||||
for( ; rs.next(); i++ )
|
||||
|
Reference in New Issue
Block a user