Commit 6a061da2 authored by Marc G. Fournier's avatar Marc G. Fournier

Update patch from Peter <patches@maidast.demon.co.uk>

parent 0b6dc93b
package postgresql;
import java.math.*;
import java.sql.*;
import java.math.*;
/**
* @version 1.0 15-APR-1997
* @author <A HREF="mailto:adrian@hottub.org">Adrian Hall</A>
*
* CallableStatement is used to execute SQL stored procedures.
*
* JDBC provides a stored procedure SQL escape that allows stored procedures
* to be called in a standard way for all RDBMS's. This escape syntax has
* one form that includes a result parameter and one that does not. If used,
* the result parameter must be generated as an OUT parameter. The other
* parameters may be used for input, output or both. Parameters are refered
* to sequentially, by number. The first parameter is 1.
*
* <PRE>
* {?= call <procedure-name>[<arg1>,<arg2>, ...]}
* {call <procedure-name>[<arg1>,<arg2>, ...]}
* </PRE>
*
* IN parameters are set using the set methods inherited from
* PreparedStatement. The type of all OUT parameters must be registered
* prior to executing the stored procedure; their values are retrieved
* after execution via the get methods provided here.
*
* A CallableStatement may return a ResultSet or multiple ResultSets. Multiple
* ResultSets are handled using operations inherited from Statement.
*
* For maximum portability, a call's ResultSets and update counts should be
* processed prior to getting the values of output parameters.
*
* @see java.sql.Connection#prepareCall
* @see java.sql.ResultSet
* @see java.sql.CallableStatement
* JDBC Interface to Postgres95 functions
*/
public class CallableStatement implements java.sql.CallableStatement
// Copy methods from the Result set object here.
public class CallableStatement extends PreparedStatement implements java.sql.CallableStatement
{
public void registerOutParameter (int paramterIndex, int sqlType) throws SQLException
CallableStatement(Connection c,String q) throws SQLException
{
// XXX-Not Implemented
super(c,q);
}
public void registerOutParameter (int parameterIndex, int sqlType, int scale) throws SQLException
{
// XXX-Not Implemented
// Before executing a stored procedure call you must explicitly
// call registerOutParameter to register the java.sql.Type of each
// out parameter.
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
}
public boolean wasNull () throws SQLException
// You must also specify the scale for numeric/decimal types:
public void registerOutParameter(int parameterIndex, int sqlType,
int scale) throws SQLException
{
// XXX-Not Implemented
}
public String getString (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
public boolean isNull(int parameterIndex) throws SQLException {
return true;
}
public boolean getBoolean (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// New API (JPM)
public boolean wasNull() throws SQLException {
// check to see if the last access threw an exception
return false; // fake it for now
}
public byte getByte (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// Methods for retrieving OUT parameters from this statement.
public String getChar(int parameterIndex) throws SQLException {
return null;
}
public short getShort (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// New API (JPM)
public String getString(int parameterIndex) throws SQLException {
return null;
}
//public String getVarChar(int parameterIndex) throws SQLException {
// return null;
//}
public int getInt (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
public String getLongVarChar(int parameterIndex) throws SQLException {
return null;
}
public long getLong (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// New API (JPM) (getBit)
public boolean getBoolean(int parameterIndex) throws SQLException {
return false;
}
public float getFloat (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// New API (JPM) (getTinyInt)
public byte getByte(int parameterIndex) throws SQLException {
return 0;
}
public double getDouble (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// New API (JPM) (getSmallInt)
public short getShort(int parameterIndex) throws SQLException {
return 0;
}
public BigDecimal getBigDecimal (int parameterIndex, int scale) throws SQLException
{
// XXX-Not Implemented
// New API (JPM) (getInteger)
public int getInt(int parameterIndex) throws SQLException {
return 0;
}
public byte[] getBytes (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// New API (JPM) (getBigInt)
public long getLong(int parameterIndex) throws SQLException {
return 0;
}
public Date getDate (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
public float getFloat(int parameterIndex) throws SQLException {
return (float) 0.0;
}
public Time getTime (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
public double getDouble(int parameterIndex) throws SQLException {
return 0.0;
}
public Timestamp getTimestamp (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
public BigDecimal getBigDecimal(int parameterIndex, int scale)
throws SQLException {
return null;
}
public Object getObject (int parameterIndex) throws SQLException
{
// XXX-Not Implemented
// New API (JPM) (getBinary)
public byte[] getBytes(int parameterIndex) throws SQLException {
return null;
}
// New API (JPM) (getLongVarBinary)
public byte[] getBinaryStream(int parameterIndex) throws SQLException {
return null;
}
public java.sql.Date getDate(int parameterIndex) throws SQLException {
return null;
}
public java.sql.Time getTime(int parameterIndex) throws SQLException {
return null;
}
public java.sql.Timestamp getTimestamp(int parameterIndex)
throws SQLException {
return null;
}
//----------------------------------------------------------------------
// Advanced features:
// You can obtain a ParameterMetaData object to get information
// about the parameters to this CallableStatement.
public DatabaseMetaData getMetaData() {
return null;
}
// getObject returns a Java object for the parameter.
// See the JDBC spec's "Dynamic Programming" chapter for details.
public Object getObject(int parameterIndex)
throws SQLException {
return null;
}
}
......@@ -45,7 +45,7 @@ public class Connection implements java.sql.Connection
private boolean autoCommit = true;
private boolean readOnly = false;
private Driver this_driver;
protected Driver this_driver;
private String this_url;
private String cursor = null; // The positioned update cursor name
......@@ -153,7 +153,7 @@ public class Connection implements java.sql.Connection
public java.sql.CallableStatement prepareCall(String sql) throws SQLException
{
throw new SQLException("Callable Statements are not supported at this time");
// return new CallableStatement(this, sql);
// return new CallableStatement(this, sql);
}
/**
......@@ -295,8 +295,7 @@ public class Connection implements java.sql.Connection
*/
public java.sql.DatabaseMetaData getMetaData() throws SQLException
{
// return new DatabaseMetaData(this);
throw new SQLException("DatabaseMetaData not supported");
return new DatabaseMetaData(this);
}
/**
......
package postgresql;
import java.sql.*;
import java.util.*;
/**
* @version 1.0 15-APR-1997
......@@ -163,7 +164,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public String getDatabaseProductVersion() throws SQLException
{
return ("6.1");
return ("6.2");
}
/**
......@@ -187,7 +188,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public String getDriverVersion() throws SQLException
{
return new String("1.0");
return new String(Integer.toString(connection.this_driver.getMajorVersion())+"."+Integer.toString(connection.this_driver.getMinorVersion()));
}
/**
......@@ -197,7 +198,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public int getDriverMajorVersion()
{
return 1;
return connection.this_driver.getMajorVersion();
}
/**
......@@ -207,7 +208,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public int getDriverMinorVersion()
{
return 0;
return connection.this_driver.getMinorVersion();
}
/**
......@@ -372,21 +373,25 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public String getNumericFunctions() throws SQLException
{
// XXX-Not Implemented
return "";
}
public String getStringFunctions() throws SQLException
{
// XXX-Not Implemented
return "";
}
public String getSystemFunctions() throws SQLException
{
// XXX-Not Implemented
return "";
}
public String getTimeDateFunctions() throws SQLException
{
// XXX-Not Implemented
return "";
}
/**
......@@ -477,21 +482,25 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public boolean supportsConvert() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsConvert(int fromType, int toType) throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsTableCorrelationNames() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsDifferentTableCorrelationNames() throws SQLException
{
// XXX-Not Implemented
return false;
}
/**
......@@ -504,7 +513,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public boolean supportsExpressionsInOrderBy() throws SQLException
{
return false;
return true;
}
/**
......@@ -931,36 +940,43 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public boolean supportsSelectForUpdate() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsStoredProcedures() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsSubqueriesInComparisons() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsSubqueriesInExists() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsSubqueriesInIns() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsSubqueriesInQuantifieds() throws SQLException
{
// XXX-Not Implemented
return false;
}
public boolean supportsCorrelatedSubqueries() throws SQLException
{
// XXX-Not Implemented
return false;
}
/**
......@@ -1185,6 +1201,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public int getMaxSchemaNameLength() throws SQLException
{
// XXX-Not Implemented
return 0;
}
/**
......@@ -1203,6 +1220,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public int getMaxCatalogNameLength() throws SQLException
{
// XXX-Not Implemented
return 0;
}
/**
......@@ -1430,24 +1448,25 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
* @return ResultSet - each row is a procedure description
* @exception SQLException if a database access error occurs
*/
public java.sql.ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException
{
Field[] f = new Field[8]; // the field descriptors for the new ResultSet
static final int iVarcharOid = 1043; // This is the OID for a varchar()
static final int iInt2Oid = 21; // This is the OID for an int2
public java.sql.ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException
{
// the field descriptors for the new ResultSet
Field f[] = new Field[8];
ResultSet r; // ResultSet for the SQL query that we need to do
Vector v; // The new ResultSet tuple stuff
Vector v = new Vector(); // The new ResultSet tuple stuff
String remarks = new String("no remarks");
Field[0] = new Field(conn, new String("PROCEDURE_CAT"), iVarcharOid, 32);
Field[1] = new Field(conn, new String("PROCEDURE_SCHEM"), iVarcharOid, 32);
Field[2] = new Field(conn, new String("PROCEDURE_NAME"), iVarcharOid, 32);
Field[3] = null;
Field[4] = null;
Field[5] = null;
Field[6] = new Field(conn, new String("REMARKS"), iVarcharOid, 8192);
Field[7] = new Field(conn, new String("PROCEDURE_TYPE"), iInt2Oid, 2);
r = conn.ExecSQL("select proname, proretset from pg_proc order by proname");
f[0] = new Field(connection, new String("PROCEDURE_CAT"), iVarcharOid, 32);
f[1] = new Field(connection, new String("PROCEDURE_SCHEM"), iVarcharOid, 32);
f[2] = new Field(connection, new String("PROCEDURE_NAME"), iVarcharOid, 32);
f[3] = null;
f[4] = null;
f[5] = null;
f[6] = new Field(connection, new String("REMARKS"), iVarcharOid, 8192);
f[7] = new Field(connection, new String("PROCEDURE_TYPE"), iInt2Oid, 2);
r = connection.ExecSQL("select proname, proretset from pg_proc order by proname");
if (r.getColumnCount() != 2 || r.getTupleCount() <= 1)
throw new SQLException("Unexpected return from query for procedure list");
while (r.next())
......@@ -1455,102 +1474,610 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
byte[][] tuple = new byte[8][0];
String name = r.getString(1);
String remarks = new String("no remarks");
remarks = new String("no remarks");
boolean retset = r.getBoolean(2);
byte[0] = null; // Catalog name
byte[1] = null; // Schema name
byte[2] = name.getBytes(); // Procedure name
byte[3] = null; // Reserved
byte[4] = null; // Reserved
byte[5] = null; // Reserved
byte[6] = remarks.getBytes(); // Remarks
tuple[0] = null; // Catalog name
tuple[1] = null; // Schema name
tuple[2] = name.getBytes(); // Procedure name
tuple[3] = null; // Reserved
tuple[4] = null; // Reserved
tuple[5] = null; // Reserved
tuple[6] = remarks.getBytes(); // Remarks
tuple[7] = new byte[1];
if (retset)
byte[7] = procedureReturnsResult;
tuple[7][0] = (byte)java.sql.DatabaseMetaData.procedureReturnsResult;
else
byte[7] = procedureNoResult;
v.addElement(byte);
tuple[7][0] = (byte)java.sql.DatabaseMetaData.procedureNoResult;
v.addElement(tuple);
}
return new ResultSet(conn, f, v, "OK", 1);
return new ResultSet(connection, f, v, "OK", 1);
}
public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException
{
// XXX-Not Implemented
return null;
}
public java.sql.ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException
{
// XXX-Not Implemented
return connection.createStatement().executeQuery("SELECT '' as TABLE_CAT,'' AS TABLE_SCHEM,relname AS TABLE_NAME,'TABLE' AS TABLE_TYPE,'' AS REMARKS FROM pg_class WHERE relkind = 'r' and relname !~ '^pg_' and relname !~ '^Inv' and relname ~ '"+tableNamePattern+"' ORDER BY TABLE_NAME");
}
/**
* Get the schema names available in this database. The results
* are ordered by schema name.
*
* <P>The schema column is:
* <OL>
* <LI><B>TABLE_SCHEM</B> String => schema name
* </OL>
*
* @return ResultSet each row has a single String column that is a
* schema name
*/
public java.sql.ResultSet getSchemas() throws SQLException
{
// XXX-Not Implemented
return null;
}
/**
* Get the catalog names available in this database. The results
* are ordered by catalog name.
*
* <P>The catalog column is:
* <OL>
* <LI><B>TABLE_CAT</B> String => catalog name
* </OL>
*
* @return ResultSet each row has a single String column that is a
* catalog name
*/
// We don't use catalog names, so this returns a single catalog
public java.sql.ResultSet getCatalogs() throws SQLException
{
// XXX-Not Implemented
return connection.createStatement().executeQuery("SELECT '' as TABLE_CAT");
}
/**
* Get the table types available in this database. The results
* are ordered by table type.
*
* <P>The table type is:
* <OL>
* <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
* "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
* "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
* </OL>
*
* @return ResultSet each row has a single String column that is a
* table type
*/
public java.sql.ResultSet getTableTypes() throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of table columns available in a catalog.
*
* <P>Only column descriptions matching the catalog, schema, table
* and column name criteria are returned. They are ordered by
* TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
*
* <P>Each column description has the following columns:
* <OL>
* <LI><B>TABLE_CAT</B> String => table catalog (may be null)
* <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
* <LI><B>TABLE_NAME</B> String => table name
* <LI><B>COLUMN_NAME</B> String => column name
* <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
* <LI><B>TYPE_NAME</B> String => Data source dependent type name
* <LI><B>COLUMN_SIZE</B> int => column size. For char or date
* types this is the maximum number of characters, for numeric or
* decimal types this is precision.
* <LI><B>BUFFER_LENGTH</B> is not used.
* <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
* <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
* <LI><B>NULLABLE</B> int => is NULL allowed?
* <UL>
* <LI> columnNoNulls - might not allow NULL values
* <LI> columnNullable - definitely allows NULL values
* <LI> columnNullableUnknown - nullability unknown
* </UL>
* <LI><B>REMARKS</B> String => comment describing column (may be null)
* <LI><B>COLUMN_DEF</B> String => default value (may be null)
* <LI><B>SQL_DATA_TYPE</B> int => unused
* <LI><B>SQL_DATETIME_SUB</B> int => unused
* <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
* maximum number of bytes in the column
* <LI><B>ORDINAL_POSITION</B> int => index of column in table
* (starting at 1)
* <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
* does not allow NULL values; "YES" means the column might
* allow NULL values. An empty string means nobody knows.
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schemaPattern a schema name pattern; "" retrieves those
* without a schema
* @param tableNamePattern a table name pattern
* @param columnNamePattern a column name pattern
* @return ResultSet each row is a column description
* @see #getSearchStringEscape
*/
public java.sql.ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException
{
// XXX-Not Implemented
}
// PM: this will be implemented, as soon as I sort out how to convert the
// code from the other driver (private note: look at getProcedures() )
return null;
}
/**
* Get a description of the access rights for a table's columns.
*
* <P>Only privileges matching the column name criteria are
* returned. They are ordered by COLUMN_NAME and PRIVILEGE.
*
* <P>Each privilige description has the following columns:
* <OL>
* <LI><B>TABLE_CAT</B> String => table catalog (may be null)
* <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
* <LI><B>TABLE_NAME</B> String => table name
* <LI><B>COLUMN_NAME</B> String => column name
* <LI><B>GRANTOR</B> => grantor of access (may be null)
* <LI><B>GRANTEE</B> String => grantee of access
* <LI><B>PRIVILEGE</B> String => name of access (SELECT,
* INSERT, UPDATE, REFRENCES, ...)
* <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
* to grant to others; "NO" if not; null if unknown
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name; "" retrieves those without a schema
* @param table a table name
* @param columnNamePattern a column name pattern
* @return ResultSet each row is a column privilege description
* @see #getSearchStringEscape
*/
public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of the access rights for each table available
* in a catalog.
*
* <P>Only privileges matching the schema and table name
* criteria are returned. They are ordered by TABLE_SCHEM,
* TABLE_NAME, and PRIVILEGE.
*
* <P>Each privilige description has the following columns:
* <OL>
* <LI><B>TABLE_CAT</B> String => table catalog (may be null)
* <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
* <LI><B>TABLE_NAME</B> String => table name
* <LI><B>COLUMN_NAME</B> String => column name
* <LI><B>GRANTOR</B> => grantor of access (may be null)
* <LI><B>GRANTEE</B> String => grantee of access
* <LI><B>PRIVILEGE</B> String => name of access (SELECT,
* INSERT, UPDATE, REFRENCES, ...)
* <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
* to grant to others; "NO" if not; null if unknown
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schemaPattern a schema name pattern; "" retrieves those
* without a schema
* @param tableNamePattern a table name pattern
* @return ResultSet each row is a table privilege description
* @see #getSearchStringEscape
*/
public java.sql.ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of a table's optimal set of columns that
* uniquely identifies a row. They are ordered by SCOPE.
*
* <P>Each column description has the following columns:
* <OL>
* <LI><B>SCOPE</B> short => actual scope of result
* <UL>
* <LI> bestRowTemporary - very temporary, while using row
* <LI> bestRowTransaction - valid for remainder of current transaction
* <LI> bestRowSession - valid for remainder of current session
* </UL>
* <LI><B>COLUMN_NAME</B> String => column name
* <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
* <LI><B>TYPE_NAME</B> String => Data source dependent type name
* <LI><B>COLUMN_SIZE</B> int => precision
* <LI><B>BUFFER_LENGTH</B> int => not used
* <LI><B>DECIMAL_DIGITS</B> short => scale
* <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
* like an Oracle ROWID
* <UL>
* <LI> bestRowUnknown - may or may not be pseudo column
* <LI> bestRowNotPseudo - is NOT a pseudo column
* <LI> bestRowPseudo - is a pseudo column
* </UL>
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name; "" retrieves those without a schema
* @param table a table name
* @param scope the scope of interest; use same values as SCOPE
* @param nullable include columns that are nullable?
* @return ResultSet each row is a column description
*/
public java.sql.ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of a table's columns that are automatically
* updated when any value in a row is updated. They are
* unordered.
*
* <P>Each column description has the following columns:
* <OL>
* <LI><B>SCOPE</B> short => is not used
* <LI><B>COLUMN_NAME</B> String => column name
* <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
* <LI><B>TYPE_NAME</B> String => Data source dependent type name
* <LI><B>COLUMN_SIZE</B> int => precision
* <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
* <LI><B>DECIMAL_DIGITS</B> short => scale
* <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
* like an Oracle ROWID
* <UL>
* <LI> versionColumnUnknown - may or may not be pseudo column
* <LI> versionColumnNotPseudo - is NOT a pseudo column
* <LI> versionColumnPseudo - is a pseudo column
* </UL>
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name; "" retrieves those without a schema
* @param table a table name
* @return ResultSet each row is a column description
*/
public java.sql.ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException
{
// XXX-Not Implemented
return null;
}
/**
* Get a description of a table's primary key columns. They
* are ordered by COLUMN_NAME.
*
* <P>Each column description has the following columns:
* <OL>
* <LI><B>TABLE_CAT</B> String => table catalog (may be null)
* <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
* <LI><B>TABLE_NAME</B> String => table name
* <LI><B>COLUMN_NAME</B> String => column name
* <LI><B>KEY_SEQ</B> short => sequence number within primary key
* <LI><B>PK_NAME</B> String => primary key name (may be null)
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name pattern; "" retrieves those
* without a schema
* @param table a table name
* @return ResultSet each row is a primary key column description
*/
public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
{
// XXX-Not Implemented
}
return connection.createStatement().executeQuery("SELECT " +
"'' as TABLE_CAT," +
"'' AS TABLE_SCHEM," +
"bc.relname AS TABLE_NAME," +
"ic.relname AS COLUMN_NAME," +
"'1' as KEY_SEQ,"+ // -- fake it as a String for now
"t.typname as PK_NAME " +
" FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a " +
" WHERE relkind = 'r' " + // -- not indices
" and bc.relname ~ '"+table+"'" +
" and i.indrelid = bc.oid" +
" and i.indexrelid = ic.oid" +
" and i.indkey[0] = a.attnum" +
" and i.indproc = '0'::oid" +
" and a.attrelid = bc.oid" +
" ORDER BY TABLE_NAME, COLUMN_NAME;"
);
}
/**
* Get a description of the primary key columns that are
* referenced by a table's foreign key columns (the primary keys
* imported by a table). They are ordered by PKTABLE_CAT,
* PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
*
* <P>Each primary key column description has the following columns:
* <OL>
* <LI><B>PKTABLE_CAT</B> String => primary key table catalog
* being imported (may be null)
* <LI><B>PKTABLE_SCHEM</B> String => primary key table schema
* being imported (may be null)
* <LI><B>PKTABLE_NAME</B> String => primary key table name
* being imported
* <LI><B>PKCOLUMN_NAME</B> String => primary key column name
* being imported
* <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
* <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
* <LI><B>FKTABLE_NAME</B> String => foreign key table name
* <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
* <LI><B>KEY_SEQ</B> short => sequence number within foreign key
* <LI><B>UPDATE_RULE</B> short => What happens to
* foreign key when primary is updated:
* <UL>
* <LI> importedKeyCascade - change imported key to agree
* with primary key update
* <LI> importedKeyRestrict - do not allow update of primary
* key if it has been imported
* <LI> importedKeySetNull - change imported key to NULL if
* its primary key has been updated
* </UL>
* <LI><B>DELETE_RULE</B> short => What happens to
* the foreign key when primary is deleted.
* <UL>
* <LI> importedKeyCascade - delete rows that import a deleted key
* <LI> importedKeyRestrict - do not allow delete of primary
* key if it has been imported
* <LI> importedKeySetNull - change imported key to NULL if
* its primary key has been deleted
* </UL>
* <LI><B>FK_NAME</B> String => foreign key name (may be null)
* <LI><B>PK_NAME</B> String => primary key name (may be null)
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name pattern; "" retrieves those
* without a schema
* @param table a table name
* @return ResultSet each row is a primary key column description
* @see #getExportedKeys
*/
public java.sql.ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of a foreign key columns that reference a
* table's primary key columns (the foreign keys exported by a
* table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
* FKTABLE_NAME, and KEY_SEQ.
*
* <P>Each foreign key column description has the following columns:
* <OL>
* <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
* <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
* <LI><B>PKTABLE_NAME</B> String => primary key table name
* <LI><B>PKCOLUMN_NAME</B> String => primary key column name
* <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
* being exported (may be null)
* <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
* being exported (may be null)
* <LI><B>FKTABLE_NAME</B> String => foreign key table name
* being exported
* <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
* being exported
* <LI><B>KEY_SEQ</B> short => sequence number within foreign key
* <LI><B>UPDATE_RULE</B> short => What happens to
* foreign key when primary is updated:
* <UL>
* <LI> importedKeyCascade - change imported key to agree
* with primary key update
* <LI> importedKeyRestrict - do not allow update of primary
* key if it has been imported
* <LI> importedKeySetNull - change imported key to NULL if
* its primary key has been updated
* </UL>
* <LI><B>DELETE_RULE</B> short => What happens to
* the foreign key when primary is deleted.
* <UL>
* <LI> importedKeyCascade - delete rows that import a deleted key
* <LI> importedKeyRestrict - do not allow delete of primary
* key if it has been imported
* <LI> importedKeySetNull - change imported key to NULL if
* its primary key has been deleted
* </UL>
* <LI><B>FK_NAME</B> String => foreign key identifier (may be null)
* <LI><B>PK_NAME</B> String => primary key identifier (may be null)
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name pattern; "" retrieves those
* without a schema
* @param table a table name
* @return ResultSet each row is a foreign key column description
* @see #getImportedKeys
*/
public java.sql.ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of the foreign key columns in the foreign key
* table that reference the primary key columns of the primary key
* table (describe how one table imports another's key.) This
* should normally return a single foreign key/primary key pair
* (most tables only import a foreign key from a table once.) They
* are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
* KEY_SEQ.
*
* <P>Each foreign key column description has the following columns:
* <OL>
* <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
* <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
* <LI><B>PKTABLE_NAME</B> String => primary key table name
* <LI><B>PKCOLUMN_NAME</B> String => primary key column name
* <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
* being exported (may be null)
* <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
* being exported (may be null)
* <LI><B>FKTABLE_NAME</B> String => foreign key table name
* being exported
* <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
* being exported
* <LI><B>KEY_SEQ</B> short => sequence number within foreign key
* <LI><B>UPDATE_RULE</B> short => What happens to
* foreign key when primary is updated:
* <UL>
* <LI> importedKeyCascade - change imported key to agree
* with primary key update
* <LI> importedKeyRestrict - do not allow update of primary
* key if it has been imported
* <LI> importedKeySetNull - change imported key to NULL if
* its primary key has been updated
* </UL>
* <LI><B>DELETE_RULE</B> short => What happens to
* the foreign key when primary is deleted.
* <UL>
* <LI> importedKeyCascade - delete rows that import a deleted key
* <LI> importedKeyRestrict - do not allow delete of primary
* key if it has been imported
* <LI> importedKeySetNull - change imported key to NULL if
* its primary key has been deleted
* </UL>
* <LI><B>FK_NAME</B> String => foreign key identifier (may be null)
* <LI><B>PK_NAME</B> String => primary key identifier (may be null)
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name pattern; "" retrieves those
* without a schema
* @param table a table name
* @return ResultSet each row is a foreign key column description
* @see #getImportedKeys
*/
public java.sql.ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of all the standard SQL types supported by
* this database. They are ordered by DATA_TYPE and then by how
* closely the data type maps to the corresponding JDBC SQL type.
*
* <P>Each type description has the following columns:
* <OL>
* <LI><B>TYPE_NAME</B> String => Type name
* <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
* <LI><B>PRECISION</B> int => maximum precision
* <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
* (may be null)
* <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
(may be null)
* <LI><B>CREATE_PARAMS</B> String => parameters used in creating
* the type (may be null)
* <LI><B>NULLABLE</B> short => can you use NULL for this type?
* <UL>
* <LI> typeNoNulls - does not allow NULL values
* <LI> typeNullable - allows NULL values
* <LI> typeNullableUnknown - nullability unknown
* </UL>
* <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
* <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
* <UL>
* <LI> typePredNone - No support
* <LI> typePredChar - Only supported with WHERE .. LIKE
* <LI> typePredBasic - Supported except for WHERE .. LIKE
* <LI> typeSearchable - Supported for all WHERE ..
* </UL>
* <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
* <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
* <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an
* auto-increment value?
* <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
* (may be null)
* <LI><B>MINIMUM_SCALE</B> short => minimum scale supported
* <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
* <LI><B>SQL_DATA_TYPE</B> int => unused
* <LI><B>SQL_DATETIME_SUB</B> int => unused
* <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
* </OL>
*
* @return ResultSet each row is a SQL type description
*/
public java.sql.ResultSet getTypeInfo() throws SQLException
{
// XXX-Not Implemented
}
return null;
}
/**
* Get a description of a table's indices and statistics. They are
* ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
*
* <P>Each index column description has the following columns:
* <OL>
* <LI><B>TABLE_CAT</B> String => table catalog (may be null)
* <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
* <LI><B>TABLE_NAME</B> String => table name
* <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique?
* false when TYPE is tableIndexStatistic
* <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
* null when TYPE is tableIndexStatistic
* <LI><B>INDEX_NAME</B> String => index name; null when TYPE is
* tableIndexStatistic
* <LI><B>TYPE</B> short => index type:
* <UL>
* <LI> tableIndexStatistic - this identifies table statistics that are
* returned in conjuction with a table's index descriptions
* <LI> tableIndexClustered - this is a clustered index
* <LI> tableIndexHashed - this is a hashed index
* <LI> tableIndexOther - this is some other style of index
* </UL>
* <LI><B>ORDINAL_POSITION</B> short => column sequence number
* within index; zero when TYPE is tableIndexStatistic
* <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
* tableIndexStatistic
* <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending,
* "D" => descending, may be null if sort sequence is not supported;
* null when TYPE is tableIndexStatistic
* <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatisic then
* this is the number of rows in the table; otherwise it is the
* number of unique values in the index.
* <LI><B>PAGES</B> int => When TYPE is tableIndexStatisic then
* this is the number of pages used for the table, otherwise it
* is the number of pages used for the current index.
* <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
* (may be null)
* </OL>
*
* @param catalog a catalog name; "" retrieves those without a catalog
* @param schema a schema name pattern; "" retrieves those without a schema
* @param table a table name
* @param unique when true, return only indices for unique values;
* when false, return indices regardless of whether unique or not
* @param approximate when true, result is allowed to reflect approximate
* or out of data values; when false, results are requested to be
* accurate
* @return ResultSet each row is an index column description
*/
public java.sql.ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException
{
// XXX-Not Implemented
return null;
}
}
......@@ -2,12 +2,8 @@ package postgresql;
import java.sql.*;
import java.util.*;
import postgresql.*;
/**
* @version 1.0 15-APR-1997
* @author <A HREF="mailto:adrian@hottub.org">Adrian Hall</A>
*
* The Java SQL framework allows for multiple database drivers. Each
* driver should supply a class that implements the Driver interface
*
......@@ -28,12 +24,19 @@ import postgresql.*;
*/
public class Driver implements java.sql.Driver
{
// These should be in sync with the backend that the driver was
// distributed with
static final int MAJORVERSION = 6;
static final int MINORVERSION = 2;
static
{
try
{
new Driver();
try {
// moved the registerDriver from the constructor to here
// because some clients call the driver themselves (I know, as
// my early jdbc work did - and that was based on other examples).
// Placing it here, means that the driver is registered once only.
java.sql.DriverManager.registerDriver(new Driver());
} catch (SQLException e) {
e.printStackTrace();
}
......@@ -46,7 +49,6 @@ public class Driver implements java.sql.Driver
*/
public Driver() throws SQLException
{
java.sql.DriverManager.registerDriver(this);
}
/**
......@@ -79,19 +81,10 @@ public class Driver implements java.sql.Driver
*/
public java.sql.Connection connect(String url, Properties info) throws SQLException
{
DriverURL dr = new DriverURL(url);
int port;
if (!(dr.protocol().equals("jdbc")))
if((props = parseURL(url,info))==null)
return null;
if (!(dr.subprotocol().equals("postgresql")))
return null;
if (dr.host().equals("unknown"))
return null;
port = dr.port();
if (port == -1)
port = 5432; // Default PostgreSQL port
return new Connection (dr.host(), port, info, dr.database(), url, this);
return new Connection (host(), port(), props, database(), url, this);
}
/**
......@@ -108,12 +101,9 @@ public class Driver implements java.sql.Driver
*/
public boolean acceptsURL(String url) throws SQLException
{
DriverURL dr = new DriverURL(url);
if (dr.protocol().equals("jdbc"))
if (dr.subprotocol().equals("postgresql"))
return true;
if(parseURL(url,null)==null)
return false;
return true;
}
/**
......@@ -146,7 +136,7 @@ public class Driver implements java.sql.Driver
*/
public int getMajorVersion()
{
return 1;
return MAJORVERSION;
}
/**
......@@ -156,7 +146,7 @@ public class Driver implements java.sql.Driver
*/
public int getMinorVersion()
{
return 0;
return MINORVERSION;
}
/**
......@@ -170,76 +160,105 @@ public class Driver implements java.sql.Driver
{
return false;
}
}
/**
* The DriverURL class splits a JDBC URL into its subcomponents
*
* protocol:subprotocol:/[/host[:port]/][database]
*/
class DriverURL
{
private String protocol, subprotocol, host, database;
private int port = -1;
private Properties props;
static private String[] protocols = { "jdbc","postgresql" };
/**
* Constructs a new DriverURL, splitting the specified URL into its
* component parts
*/
public DriverURL(String url) throws SQLException
Properties parseURL(String url,Properties defaults) throws SQLException
{
int a, b, c;
String tmp, hostport, dbportion;
int state = -1;
Properties urlProps = new Properties(defaults);
String key = new String();
String value = new String();
a = url.indexOf(':');
if (a == -1)
throw new SQLException("Bad URL Protocol specifier");
b = url.indexOf(':', a+1);
if (b == -1)
throw new SQLException("Bad URL Subprotocol specifier");
protocol = new String(url.substring(0, a));
subprotocol = new String(url.substring(a+1, b));
tmp = new String(url.substring(b+1, url.length()));
if (tmp.length() < 2)
throw new SQLException("Bad URL Database specifier");
if (!tmp.substring(0, 2).equals("//"))
{
host = new String("unknown");
port = -1;
database = new String(tmp.substring(1, tmp.length()));
return;
StringTokenizer st = new StringTokenizer(url, ":/;=&?", true);
for (int count = 0; (st.hasMoreTokens()); count++) {
String token = st.nextToken();
// PM June 29 1997
// Added this, to help me understand how this works.
// Unless you want each token to be processed, leave this commented out
// but don't delete it.
//DriverManager.println("wellFormedURL: state="+state+" count="+count+" token='"+token+"'");
// PM Aug 2 1997 - Modified to allow multiple backends
if (count <= 3) {
if ((count % 2) == 1 && token.equals(":"))
;
else if((count % 2) == 0) {
boolean found=(count==0)?true:false;
for(int tmp=0;tmp<protocols.length;tmp++) {
if(token.equals(protocols[tmp])) {
// PM June 29 1997 Added this property to enable the driver
// to handle multiple backend protocols.
if(count == 2 && tmp > 0) {
urlProps.put("Protocol",token);
found=true;
}
dbportion = new String(tmp.substring(2, tmp.length()));
c = dbportion.indexOf('/');
if (c == -1)
throw new SQLException("Bad URL Database specifier");
a = dbportion.indexOf(':');
if (a == -1)
{
host = new String(dbportion.substring(0, c));
port = -1;
database = new String(dbportion.substring(c+1, dbportion.length()));
} else {
host = new String(dbportion.substring(0, a));
port = Integer.valueOf(dbportion.substring(a+1, c)).intValue();
database = new String(dbportion.substring(c+1, dbportion.length()));
}
}
/**
* Returns the protocol name of the DriverURL
*/
public String protocol()
{
return protocol;
if(found == false)
return null;
} else return null;
}
else if (count > 3) {
if (count == 4 && token.equals("/")) state = 0;
else if (count == 4) {
urlProps.put("PGDBNAME", token);
state = -2;
}
else if (count == 5 && state == 0 && token.equals("/"))
state = 1;
else if (count == 5 && state == 0)
return null;
else if (count == 6 && state == 1)
urlProps.put("PGHOST", token);
else if (count == 7 && token.equals(":")) state = 2;
else if (count == 8 && state == 2) {
try {
Integer portNumber = Integer.decode(token);
urlProps.put("PGPORT", portNumber.toString());
} catch (Exception e) {
return null;
}
}
else if ((count == 7 || count == 9) &&
(state == 1 || state == 2) && token.equals("/"))
state = -1;
else if (state == -1) {
urlProps.put("PGDBNAME", token);
state = -2;
}
else if (state <= -2 && (count % 2) == 1) {
// PM Aug 2 1997 - added tests for ? and &
if (token.equals(";") || token.equals("?") || token.equals("&") ) state = -3;
else if (token.equals("=")) state = -5;
}
else if (state <= -2 && (count % 2) == 0) {
if (state == -3) key = token;
else if (state == -5) {
value = token;
//DriverManager.println("put("+key+","+value+")");
urlProps.put(key, value);
state = -2;
}
}
}
}
/**
* Returns the subprotocol name of the DriverURL
*/
public String subprotocol()
{
return subprotocol;
// PM June 29 1997
// This now outputs the properties only if we are logging
if(DriverManager.getLogStream() != null)
urlProps.list(DriverManager.getLogStream());
return urlProps;
}
/**
......@@ -247,7 +266,7 @@ class DriverURL
*/
public String host()
{
return host;
return props.getProperty("PGHOST","localhost");
}
/**
......@@ -256,7 +275,7 @@ class DriverURL
*/
public int port()
{
return port;
return Integer.parseInt(props.getProperty("PGPORT","5432"));
}
/**
......@@ -264,6 +283,15 @@ class DriverURL
*/
public String database()
{
return database;
return props.getProperty("PGDBNAME");
}
/**
* Returns any property
*/
public String property(String name)
{
return props.getProperty(name);
}
}
......@@ -54,20 +54,34 @@ public class Field
throw new SQLException("Unexpected return from query for type");
result.next();
type_name = result.getString(1);
if (type_name.equals("int2")) sql_type = Types.SMALLINT;
else if (type_name.equals("int4")) sql_type = Types.INTEGER;
else if (type_name.equals("int8")) sql_type = Types.BIGINT;
else if (type_name.equals("cash")) sql_type = Types.DECIMAL;
else if (type_name.equals("money")) sql_type = Types.DECIMAL;
else if (type_name.equals("float4")) sql_type = Types.REAL;
else if (type_name.equals("float8")) sql_type = Types.DOUBLE;
else if (type_name.equals("bpchar")) sql_type = Types.CHAR;
else if (type_name.equals("varchar")) sql_type = Types.VARCHAR;
else if (type_name.equals("bool")) sql_type = Types.BIT;
else if (type_name.equals("date")) sql_type = Types.DATE;
else if (type_name.equals("time")) sql_type = Types.TIME;
else if (type_name.equals("abstime")) sql_type = Types.TIMESTAMP;
else sql_type = Types.OTHER;
if (type_name.equals("int2"))
sql_type = Types.SMALLINT;
else if (type_name.equals("int4"))
sql_type = Types.INTEGER;
else if (type_name.equals("int8"))
sql_type = Types.BIGINT;
else if (type_name.equals("cash"))
sql_type = Types.DECIMAL;
else if (type_name.equals("money"))
sql_type = Types.DECIMAL;
else if (type_name.equals("float4"))
sql_type = Types.REAL;
else if (type_name.equals("float8"))
sql_type = Types.DOUBLE;
else if (type_name.equals("bpchar"))
sql_type = Types.CHAR;
else if (type_name.equals("varchar"))
sql_type = Types.VARCHAR;
else if (type_name.equals("bool"))
sql_type = Types.BIT;
else if (type_name.equals("date"))
sql_type = Types.DATE;
else if (type_name.equals("time"))
sql_type = Types.TIME;
else if (type_name.equals("abstime"))
sql_type = Types.TIMESTAMP;
else
sql_type = Types.OTHER;
}
return sql_type;
}
......
......@@ -23,9 +23,123 @@ public class PG_Object
* @param type a string describing the type of the object
* @param value a string representation of the value of the object
*/
public PG_Object(String type, String value)
public PG_Object(String type, String value) throws SQLException
{
this.type = type;
this.value = value;
}
/**
* This returns true if the object is a 'box'
*/
public boolean isBox()
{
return type.equals("box");
}
/**
* This returns a PGbox object, or null if it's not
* @return PGbox
*/
public PGbox getBox() throws SQLException
{
if(isBox())
return new PGbox(value);
return null;
}
/**
* This returns true if the object is a 'point'
*/
public boolean isCircle()
{
return type.equals("circle");
}
/**
* This returns a PGcircle object, or null if it's not
* @return PGcircle
*/
public PGcircle getCircle() throws SQLException
{
if(isCircle())
return new PGcircle(value);
return null;
}
/**
* This returns true if the object is a 'lseg' (line segment)
*/
public boolean isLseg()
{
return type.equals("lseg");
}
/**
* This returns a PGlsegobject, or null if it's not
* @return PGlseg
*/
public PGlseg getLseg() throws SQLException
{
if(isLseg())
return new PGlseg(value);
return null;
}
/**
* This returns true if the object is a 'path'
*/
public boolean isPath()
{
return type.equals("path");
}
/**
* This returns a PGpath object, or null if it's not
* @return PGpath
*/
public PGpath getPath() throws SQLException
{
if(isPath())
return new PGpath(value);
return null;
}
/**
* This returns true if the object is a 'point'
*/
public boolean isPoint()
{
return type.equals("point");
}
/**
* This returns a PGpoint object, or null if it's not
* @return PGpoint object
*/
public PGpoint getPoint() throws SQLException
{
if(isPoint())
return new PGpoint(value);
return null;
}
/**
* This returns true if the object is a 'polygon'
*/
public boolean isPolygon()
{
return type.equals("polygon");
}
/**
* This returns a PGpolygon object, or null if it's not
* @return PGpolygon
*/
public PGpolygon getPolygon() throws SQLException
{
if(isPolygon())
return new PGpolygon(value);
return null;
}
}
......@@ -9,9 +9,6 @@ import java.sql.*;
import postgresql.*;
/**
* @version 1.0 15-APR-1997
* @author <A HREF="mailto:adrian@hottub.org">Adrian Hall</A>
*
* A ResultSet provides access to a table of data generated by executing a
* Statement. The table rows are retrieved in sequence. Within a row its
* column values can be accessed in any order.
......@@ -843,3 +840,4 @@ public class ResultSet implements java.sql.ResultSet
return fields.length;
}
}
......@@ -427,3 +427,4 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
return fields[columnIndex - 1];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment