+/*-------------------------------------------------------------------------
+ *
+ * Driver.java(.in)
+ * The Postgresql JDBC Driver implementation
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.27 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql;
import java.io.*;
* and register it with the DriverManager. This means that a user can load
* and register a driver by doing Class.forName("foo.bah.Driver")
*
- * @see org.postgresql.Connection
+ * @see org.postgresql.PGConnection
* @see java.sql.Driver
*/
public class Driver implements java.sql.Driver
}
- public static void makeSSL(PG_Stream p_stream) throws IOException {
+ public static void makeSSL(org.postgresql.core.PGStream p_stream) throws IOException {
@SSL@ if (logDebug)
@SSL@ debug("converting regular socket connection to ssl");
@SSL@ javax.net.ssl.SSLSocketFactory factory = (javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory.getDefault();
//The build number should be incremented for every new build
- private static int m_buildNumber = 202;
+ private static int m_buildNumber = 203;
}
+/*-------------------------------------------------------------------------
+ *
+ * PGConnection.java
+ * The public interface definition for a Postgresql Connection
+ * This interface defines PostgreSQL extentions to the java.sql.Connection
+ * interface. Any java.sql.Connection object returned by the driver will
+ * also implement this interface
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.4 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql;
import java.sql.*;
import org.postgresql.fastpath.Fastpath;
import org.postgresql.largeobject.LargeObjectManager;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.3 2002/09/06 21:23:05 momjian Exp $
- * This interface defines PostgreSQL extentions to the java.sql.Connection interface.
- * Any java.sql.Connection object returned by the driver will also implement this
- * interface
- */
public interface PGConnection
{
- /*
- * Get the character encoding to use for this connection.
- */
- public Encoding getEncoding() throws SQLException;
-
- /*
- * This method returns the java.sql.Types type for a postgres datatype name
- */
- public int getSQLType(String pgTypeName) throws SQLException;
-
- /*
- * This returns the java.sql.Types type for a postgres datatype OID
- */
- public int getSQLType(int oid) throws SQLException;
-
- /*
- * This returns the postgres datatype name from the
- * postgres datatype OID
- */
- public String getPGType(int oid) throws SQLException;
-
- /*
- * This returns the postgres datatype OID from the
- * postgres datatype name
+ /**
+ * This method returns any notifications that have been received
+ * since the last call to this method.
+ * Returns null if there have been no notifications.
+ * @since 7.3
*/
- public int getPGType(String typeName) throws SQLException;
+ public PGNotification[] getNotifications();
- /*
+ /**
* This returns the LargeObject API for the current connection.
+ * @since 7.3
*/
public LargeObjectManager getLargeObjectAPI() throws SQLException;
- /*
+ /**
* This returns the Fastpath API for the current connection.
+ * @since 7.3
*/
public Fastpath getFastpathAPI() throws SQLException;
- /*
- * This method is used internally to return an object based around
- * org.postgresql's more unique data types.
- *
- * <p>It uses an internal Hashtable to get the handling class. If the
- * type is not supported, then an instance of org.postgresql.util.PGobject
- * is returned.
- *
- * You can use the getValue() or setValue() methods to handle the returned
- * object. Custom objects can have their own methods.
- *
- * @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;
+ /** @deprecated */
+ public Encoding getEncoding() throws SQLException;
- /*
- * This method returns any notifications that have been received
- * since the last call to this method.
- * Returns null if there have been no notifications.
- */
- public PGNotification[] getNotifications();
+ /** @deprecated */
+ public int getSQLType(String pgTypeName) throws SQLException;
+
+ /** @deprecated */
+ public int getSQLType(int oid) throws SQLException;
+
+ /** @deprecated */
+ public String getPGType(int oid) throws SQLException;
+
+ /** @deprecated */
+ public int getPGType(String typeName) throws SQLException;
+ /** @deprecated */
+ public Object getObject(String type, String value) throws SQLException;
}
+/*-------------------------------------------------------------------------
+ *
+ * PGNotification.java
+ * This interface defines public PostgreSQL extention for Notifications
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGNotification.java,v 1.3 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGNotification.java,v 1.2 2002/09/06 21:23:05 momjian Exp $
- * This interface defines PostgreSQL extention for Notifications
- */
public interface PGNotification
{
- /*
+ /**
* Returns name of this notification
+ * @since 7.3
*/
public String getName();
- /*
+ /**
* Returns the process id of the backend process making this notification
+ * @since 7.3
*/
public int getPID();
+/*-------------------------------------------------------------------------
+ *
+ * PGStatement.java
+ * This interface defines PostgreSQL extentions to the java.sql.Statement
+ * interface. Any java.sql.Statement object returned by the driver will
+ * also implement this interface
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.7 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql;
import java.sql.*;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.6 2002/09/08 00:15:28 barry Exp $
- * This interface defines PostgreSQL extentions to the java.sql.Statement interface.
- * Any java.sql.Statement object returned by the driver will also implement this
- * interface
- */
public interface PGStatement
{
- /*
+ /**
* Returns the Last inserted/updated oid.
* @return OID of last insert
- * @since 7.3
+ * @since 7.3
*/
public long getLastOID() throws SQLException;
+ /**
+ * Turn on the use of prepared statements in the server (server side
+ * prepared statements are unrelated to jdbc PreparedStatements)
+ * @since 7.3
+ */
public void setUseServerPrepare(boolean flag) throws SQLException;
+ /**
+ * Is this statement using server side prepared statements
+ * @since 7.3
+ */
public boolean isUseServerPrepare();
}
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * BaseConnection.java
+ * The internal interface definition for a jdbc connection
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseConnection.java,v 1.1 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+package org.postgresql.core;
+
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.sql.SQLException;
+import org.postgresql.PGConnection;
+import org.postgresql.PGNotification;
+
+public interface BaseConnection extends PGConnection
+{
+
+ public void addNotification(PGNotification p_notification);
+ public void addWarning(String msg);
+ public void cancelQuery() throws SQLException;
+ public Statement createStatement() throws SQLException;
+ public BaseResultSet execSQL(String s) throws SQLException;
+ public String getCursorName() throws SQLException;
+ public Encoding getEncoding() throws SQLException;
+ public DatabaseMetaData getMetaData() throws SQLException;
+ public Object getObject(String type, String value) throws SQLException;
+ public PGStream getPGStream();
+ public String getPGType(int oid) throws SQLException;
+ public int getPGType(String pgTypeName) throws SQLException;
+ public int getSQLType(int oid) throws SQLException;
+ public int getSQLType(String pgTypeName) throws SQLException;
+ public boolean haveMinimumCompatibleVersion(String ver) throws SQLException;
+ public boolean haveMinimumServerVersion(String ver) throws SQLException;
+ public void setCursorName(String cursor) throws SQLException;
+
+}
+
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * BaseResultSet.java
+ * The internal interface definition for a jdbc result set
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseResultSet.java,v 1.1 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+package org.postgresql.core;
+
+
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.Vector;
+
+public interface BaseResultSet
+{
+ public BaseStatement getPGStatement();
+
+ public void append(BaseResultSet r);
+ public void close() throws SQLException;
+ public int getColumnCount();
+ public String getCursorName() throws SQLException;
+ public String getFixedString(int col) throws SQLException;
+ public long getLastOID();
+ public ResultSetMetaData getMetaData() throws SQLException;
+ public ResultSet getNext();
+ public Object getObject(int columnIndex) throws SQLException;
+ public int getResultCount();
+ public String getStatusString();
+ public String getString(int columnIndex) throws SQLException;
+ public StringBuffer getStringBuffer();
+ public int getTupleCount();
+ public boolean next() throws SQLException;
+ public boolean reallyResultSet();
+ public void reInit (Field[] fields, Vector tuples, String status,
+ int updateCount, long insertOID, boolean binaryCursor);
+ public void setStatement(BaseStatement statement);
+
+}
--- /dev/null
+/*-------------------------------------------------------------------------
+ *
+ * BaseStatement.java
+ * The internal interface definition for a jdbc statement
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.1 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+package org.postgresql.core;
+
+
+import java.sql.*;
+import java.util.Vector;
+
+public interface BaseStatement extends org.postgresql.PGStatement
+{
+ public BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
+
+ public BaseConnection getPGConnection();
+
+ /*
+ * The maxRows limit is set to limit the number of rows that
+ * any ResultSet can contain. If the limit is exceeded, the
+ * excess rows are silently dropped.
+ */
+ public int getFetchSize() throws SQLException;
+ public int getMaxRows() throws SQLException;
+ public int getResultSetConcurrency() throws SQLException;
+ public String getStatementName();
+
+}
+/*-------------------------------------------------------------------------
+ *
+ * Encoding.java
+ * Converts to and from the character encoding used by the backend.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Encoding.java,v 1.10 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.core;
-import java.io.*;
-import java.util.*;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
-import org.postgresql.util.*;
-
-/*
- * Converts to and from the character encoding used by the backend.
- *
- * $Id: Encoding.java,v 1.9 2003/02/09 23:14:55 barry Exp $
- */
+import java.util.Hashtable;
+import org.postgresql.util.PSQLException;
public class Encoding
{
-package org.postgresql;
+/*-------------------------------------------------------------------------
+ *
+ * Field.java
+ * Field is a class used to describe fields in a PostgreSQL ResultSet
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Field.java,v 1.1 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+package org.postgresql.core;
import java.lang.*;
import java.sql.*;
import java.util.*;
-import org.postgresql.*;
-import org.postgresql.util.*;
+import org.postgresql.core.BaseConnection;
+import org.postgresql.util.PSQLException;
/*
- * org.postgresql.Field is a class used to describe fields in a PostgreSQL
- * ResultSet
*/
public class Field
{
private int mod; // type modifier of this field
private String name; // Name of this field
- private org.postgresql.PGConnection conn; // Connection Instantation
+ private BaseConnection conn; // Connection Instantation
/*
* @param oid the OID of the field
* @param len the length of the field
*/
- public Field(org.postgresql.PGConnection conn, String name, int oid, int length, int mod)
+ public Field(BaseConnection conn, String name, int oid, int length, int mod)
{
this.conn = conn;
this.name = name;
* @param oid the OID of the field
* @param len the length of the field
*/
- public Field(org.postgresql.PGConnection conn, String name, int oid, int length)
+ public Field(BaseConnection conn, String name, int oid, int length)
{
this(conn, name, oid, length, 0);
}
+/*-------------------------------------------------------------------------
+ *
+ * Notification.java
+ * This is the implementation of the PGNotification interface
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Notification.java,v 1.3 2003/03/07 18:39:41 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.core;
+import org.postgresql.PGNotification;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Notification.java,v 1.2 2002/09/06 21:23:05 momjian Exp $
- * This is the implementation of the PGNotification interface
- */
-public class Notification implements org.postgresql.PGNotification
+public class Notification implements PGNotification
{
public Notification(String p_name, int p_pid)
{
-package org.postgresql;
-
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.*;
-import org.postgresql.core.*;
-import org.postgresql.util.*;
-
-/*
- * $Id: PG_Stream.java,v 1.18 2003/02/27 05:45:44 barry Exp $
+/*-------------------------------------------------------------------------
+ *
+ * PGStream.java
+ * This class is used by Connection for communicating with the
+ * backend.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
*
- * This class is used by Connection & PGlobj for communicating with the
- * backend.
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/PGStream.java,v 1.1 2003/03/07 18:39:41 barry Exp $
*
- * @see java.sql.Connection
+ *-------------------------------------------------------------------------
*/
-// This class handles all the Streamed I/O for a org.postgresql connection
-public class PG_Stream
+package org.postgresql.core;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.Socket;
+import java.sql.*;
+import org.postgresql.util.PSQLException;
+
+
+public class PGStream
{
public String host;
public int port;
* @param port the port number that the postmaster is sitting on
* @exception IOException if an IOException occurs below it.
*/
- public PG_Stream(String p_host, int p_port) throws IOException
+ public PGStream(String p_host, int p_port) throws IOException
{
host = p_host;
port = p_port;
-
+/*-------------------------------------------------------------------------
+ *
+ * QueryExecutor.java
+ * Executes a query on the backend.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.20 2003/03/07 18:39:42 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.core;
import java.util.Vector;
import java.io.IOException;
import java.sql.*;
-import org.postgresql.*;
import org.postgresql.util.PSQLException;
import org.postgresql.jdbc1.AbstractJdbc1Connection;
import org.postgresql.jdbc1.AbstractJdbc1ResultSet;
import org.postgresql.jdbc1.AbstractJdbc1Statement;
-/*
- * Executes a query on the backend.
- *
- * <p>The lifetime of a QueryExecutor object is from sending the query
- * until the response has been received from the backend.
- *
- * $Id: QueryExecutor.java,v 1.19 2003/02/04 11:01:52 davec Exp $
- */
-
public class QueryExecutor
{
//This version of execute does not take an existing result set, but
//creates a new one for the results of the query
- public static ResultSet execute (String[] p_sqlFrags,
+ public static BaseResultSet execute(String[] p_sqlFrags,
Object[] p_binds,
- java.sql.Statement statement)
+ BaseStatement statement)
throws SQLException
{
QueryExecutor qe = new QueryExecutor();
else
qe.maxRows = 0;
- qe.connection = (AbstractJdbc1Connection)((AbstractJdbc1Statement)statement).getPGConnection();
- qe.pg_stream = qe.connection.getPGStream();
+ qe.connection = statement.getPGConnection();
+ qe.pgStream = qe.connection.getPGStream();
return qe.execute();
}
//This version of execute reuses an existing result set for the query
//results, this is used when a result set is backed by a cursor and
//more results are fetched
- public static void execute (String[] p_sqlFrags,
+ public static void execute(String[] p_sqlFrags,
Object[] p_binds,
- java.sql.ResultSet rs)
+ BaseResultSet rs)
throws SQLException
{
QueryExecutor qe = new QueryExecutor();
qe.m_sqlFrags = p_sqlFrags;
qe.m_binds = p_binds;
qe.rs = rs;
- qe.statement = (java.sql.Statement)((AbstractJdbc1ResultSet)qe.rs).getPGStatement();
+ qe.statement = qe.rs.getPGStatement();
if (qe.statement != null)
qe.maxRows = qe.statement.getMaxRows();
else
qe.maxRows = 0;
- qe.connection = (AbstractJdbc1Connection)((AbstractJdbc1Statement)qe.statement).getPGConnection();
- qe.pg_stream = qe.connection.getPGStream();
+ qe.connection = qe.statement.getPGConnection();
+ qe.pgStream = qe.connection.getPGStream();
qe.execute();
}
private String[] m_sqlFrags;
private Object[] m_binds;
- private java.sql.Statement statement;
- private java.sql.ResultSet rs;
+ private BaseStatement statement;
+ private BaseResultSet rs;
- private AbstractJdbc1Connection connection;
- private PG_Stream pg_stream;
+ private BaseConnection connection;
+ private PGStream pgStream;
private Field[] fields = null;
private Vector tuples = new Vector();
* Execute a query on the backend.
*
*/
- private java.sql.ResultSet execute() throws SQLException
+ private BaseResultSet execute() throws SQLException
{
StringBuffer errorMessage = null;
- if (pg_stream == null)
+ if (pgStream == null)
{
throw new PSQLException("postgresql.con.closed");
}
- synchronized (pg_stream)
+ synchronized (pgStream)
{
sendQuery();
boolean l_endQuery = false;
while (!l_endQuery)
{
- c = pg_stream.ReceiveChar();
+ c = pgStream.ReceiveChar();
switch (c)
{
case 'A': // Asynchronous Notify
- int pid = pg_stream.ReceiveInteger(4);
- String msg = pg_stream.ReceiveString(connection.getEncoding());
+ int pid = pgStream.ReceiveInteger(4);
+ String msg = pgStream.ReceiveString(connection.getEncoding());
connection.addNotification(new org.postgresql.core.Notification(msg, pid));
break;
case 'B': // Binary Data Transfer
if ( errorMessage == null )
errorMessage = new StringBuffer();
- errorMessage.append(pg_stream.ReceiveString(connection.getEncoding()));
+ errorMessage.append(pgStream.ReceiveString(connection.getEncoding()));
// keep processing
break;
case 'I': // Empty Query
- int t = pg_stream.ReceiveChar();
+ int t = pgStream.ReceiveChar();
break;
case 'N': // Error Notification
- connection.addWarning(pg_stream.ReceiveString(connection.getEncoding()));
+ connection.addWarning(pgStream.ReceiveString(connection.getEncoding()));
break;
case 'P': // Portal Name
- String pname = pg_stream.ReceiveString(connection.getEncoding());
+ String pname = pgStream.ReceiveString(connection.getEncoding());
break;
case 'T': // MetaData Field Description
receiveFields();
//create a new one
if (rs != null)
{
- ((org.postgresql.jdbc1.AbstractJdbc1ResultSet)rs).reInit(fields, tuples, status, update_count, insert_oid, binaryCursor);
+ rs.reInit(fields, tuples, status, update_count, insert_oid, binaryCursor);
}
else
{
- rs = ((AbstractJdbc1Statement)statement).createResultSet(fields, tuples, status, update_count, insert_oid, binaryCursor);
+ rs = statement.createResultSet(fields, tuples, status, update_count, insert_oid, binaryCursor);
}
return rs;
}
}
try
{
- pg_stream.SendChar('Q');
+ pgStream.SendChar('Q');
for (int i = 0 ; i < m_binds.length ; ++i)
{
- pg_stream.Send(connection.getEncoding().encode(m_sqlFrags[i]));
- pg_stream.Send(connection.getEncoding().encode(m_binds[i].toString()));
+ pgStream.Send(connection.getEncoding().encode(m_sqlFrags[i]));
+ pgStream.Send(connection.getEncoding().encode(m_binds[i].toString()));
}
- pg_stream.Send(connection.getEncoding().encode(m_sqlFrags[m_binds.length]));
- pg_stream.SendChar(0);
- pg_stream.flush();
+ pgStream.Send(connection.getEncoding().encode(m_sqlFrags[m_binds.length]));
+ pgStream.SendChar(0);
+ pgStream.flush();
}
catch (IOException e)
{
if (fields == null)
throw new PSQLException("postgresql.con.tuple");
- Object tuple = pg_stream.ReceiveTuple(fields.length, isBinary);
+ Object tuple = pgStream.ReceiveTuple(fields.length, isBinary);
if (isBinary)
binaryCursor = true;
if (maxRows == 0 || tuples.size() < maxRows)
private void receiveCommandStatus() throws SQLException
{
- status = pg_stream.ReceiveString(connection.getEncoding());
+ status = pgStream.ReceiveString(connection.getEncoding());
try
{
if (fields != null)
throw new PSQLException("postgresql.con.multres");
- int size = pg_stream.ReceiveIntegerR(2);
+ int size = pgStream.ReceiveIntegerR(2);
fields = new Field[size];
for (int i = 0; i < fields.length; i++)
{
- String typeName = pg_stream.ReceiveString(connection.getEncoding());
- int typeOid = pg_stream.ReceiveIntegerR(4);
- int typeLength = pg_stream.ReceiveIntegerR(2);
- int typeModifier = pg_stream.ReceiveIntegerR(4);
+ String typeName = pgStream.ReceiveString(connection.getEncoding());
+ int typeOid = pgStream.ReceiveIntegerR(4);
+ int typeLength = pgStream.ReceiveIntegerR(2);
+ int typeModifier = pgStream.ReceiveIntegerR(4);
fields[i] = new Field(connection, typeName, typeOid, typeLength, typeModifier);
}
}
package org.postgresql.core;
-import org.postgresql.PG_Stream;
import java.io.IOException;
/**
* Sent to the backend to initialize a newly created connection.
*
- * $Id: StartupPacket.java,v 1.2 2002/09/06 21:23:05 momjian Exp $
+ * $Id: StartupPacket.java,v 1.3 2003/03/07 18:39:42 barry Exp $
*/
public class StartupPacket
this.database = database;
}
- public void writeTo(PG_Stream stream) throws IOException
+ public void writeTo(PGStream stream) throws IOException
{
stream.SendInteger(4 + 4 + SM_DATABASE + SM_USER + SM_OPTIONS + SM_UNUSED + SM_TTY, 4);
stream.SendInteger(protocolMajor, 2);
+/*-------------------------------------------------------------------------
+ *
+ * Fastpath.java
+ * This class implements the Fastpath api.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Attic/Fastpath.java,v 1.12 2003/03/07 18:39:42 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.fastpath;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import java.util.Hashtable;
import org.postgresql.Driver;
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-// Important: There are a lot of debug code commented out. Please do not
-// delete these.
+import org.postgresql.core.BaseConnection;
+import org.postgresql.core.PGStream;
+import org.postgresql.util.PSQLException;
/*
* This class implements the Fastpath api.
*
- * <p>This is a means of executing functions imbeded in the org.postgresql backend
- * from within a java application.
+ * <p>This is a means of executing functions imbeded in the org.postgresql
+ * backend from within a java application.
*
* <p>It is based around the file src/interfaces/libpq/fe-exec.c
*
- * @see org.postgresql.FastpathFastpathArg
- * @see org.postgresql.LargeObject
*/
public class Fastpath
{
// to a connection).
protected Hashtable func = new Hashtable();
- protected org.postgresql.PGConnection conn; // our connection
- protected org.postgresql.PG_Stream stream; // the network stream
+ protected BaseConnection conn; // our connection
+ protected PGStream stream; // the network stream
/*
* Initialises the fastpath system
*
- * <p><b>Important Notice</b>
- * <br>This is called from org.postgresql.Connection, and should not be called
- * from client code.
- *
- * @param conn org.postgresql.Connection to attach to
+ * @param conn BaseConnection to attach to
* @param stream The network stream to the backend
*/
- public Fastpath(org.postgresql.PGConnection conn, org.postgresql.PG_Stream stream)
+ public Fastpath(BaseConnection conn, PGStream stream)
{
this.conn = conn;
this.stream = stream;
//------------------------------
// Notice from backend
case 'N':
- ((org.postgresql.jdbc1.AbstractJdbc1Connection)conn).addWarning(stream.ReceiveString(conn.getEncoding()));
+ conn.addWarning(stream.ReceiveString(conn.getEncoding()));
break;
case 'V':
* This is the prefered method to call, as function id's can/may change
* between versions of the backend.
*
- * For an example of how this works, refer to org.postgresql.LargeObject
+ * For an example of how this works, refer to org.postgresql.largeobject.LargeObject
*
* @param name Function name
* @param resulttype True if the result is an integer, false for other
* @return null if no data, Integer if an integer result, or byte[] otherwise
* @exception SQLException if name is unknown or if a database-access error
* occurs.
- * @see org.postgresql.LargeObject
+ * @see org.postgresql.largeobject.LargeObject
*/
public Object fastpath(String name, boolean resulttype, FastpathArg[] args) throws SQLException
{
* the function's required are entered into this table, keeping connection
* times as fast as possible.
*
- * <p>The org.postgresql.LargeObject class performs a query upon it's startup,
+ * <p>The org.postgresql.largeobject.LargeObject class performs a query upon it's startup,
* and passes the returned ResultSet to the addFunctions() method here.
*
* <p>Once this has been done, the LargeObject api refers to the functions by
*
* @param rs ResultSet
* @exception SQLException if a database-access error occurs.
- * @see org.postgresql.LargeObjectManager
+ * @see org.postgresql.largeobject.LargeObjectManager
*/
public void addFunctions(ResultSet rs) throws SQLException
{
-package org.postgresql.fastpath;
-
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.util.*;
-
-/*
- * Each fastpath call requires an array of arguments, the number and type
- * dependent on the function being called.
+/*-------------------------------------------------------------------------
+ *
+ * FastpathArg.java
+ * Each fastpath call requires an array of arguments, the number and type
+ * dependent on the function being called.
*
- * <p>This class implements methods needed to provide this capability.
+ * Copyright (c) 2003, PostgreSQL Global Development Group
*
- * <p>For an example on how to use this, refer to the org.postgresql.largeobject
- * package
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/fastpath/Attic/FastpathArg.java,v 1.4 2003/03/07 18:39:42 barry Exp $
*
- * @see org.postgresql.fastpath.Fastpath
- * @see org.postgresql.largeobject.LargeObjectManager
- * @see org.postgresql.largeobject.LargeObject
+ *-------------------------------------------------------------------------
*/
+package org.postgresql.fastpath;
+
+import java.io.IOException;
+
public class FastpathArg
{
/*
* @param s output stream
* @exception IOException if something failed on the network stream
*/
- protected void send(org.postgresql.PG_Stream s) throws IOException
+ protected void send(org.postgresql.core.PGStream s) throws IOException
{
if (type)
{
+/*-------------------------------------------------------------------------
+ *
+ * PGbox.java
+ * This represents the box datatype within org.postgresql.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGbox.java,v 1.4 2003/03/07 18:39:42 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.geometric;
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
+import java.sql.SQLException;
+import java.io.Serializable;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PGtokenizer;
+import org.postgresql.util.PSQLException;
-/*
- * This represents the box datatype within org.postgresql.
- */
public class PGbox extends PGobject implements Serializable, Cloneable
{
/*
+/*-------------------------------------------------------------------------
+ *
+ * PGcircle.java
+ * This represents org.postgresql's circle datatype, consisting of a point
+ * and a radius
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGcircle.java,v 1.4 2003/03/07 18:39:42 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.geometric;
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
+import java.io.Serializable;
+import java.sql.SQLException;
+import java.util.Hashtable;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PGtokenizer;
+import org.postgresql.util.PSQLException;
-/*
- * This represents org.postgresql's circle datatype, consisting of a point and
- * a radius
- */
public class PGcircle extends PGobject implements Serializable, Cloneable
{
/*
+/*-------------------------------------------------------------------------
+ *
+ * PGline.java
+ * This implements a line consisting of two points.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGline.java,v 1.4 2003/03/07 18:39:42 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.geometric;
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
+import java.io.Serializable;
+import java.sql.SQLException;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PGtokenizer;
+import org.postgresql.util.PSQLException;
/*
- * This implements a line consisting of two points.
- *
* Currently line is not yet implemented in the backend, but this class
* ensures that when it's done were ready for it.
*/
+/*-------------------------------------------------------------------------
+ *
+ * PGlseg.java
+ * This implements a lseg (line segment) consisting of two points
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGlseg.java,v 1.4 2003/03/07 18:39:42 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.geometric;
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
+import java.io.Serializable;
+import java.sql.SQLException;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PGtokenizer;
+import org.postgresql.util.PSQLException;
-/*
- * This implements a lseg (line segment) consisting of two points
- */
public class PGlseg extends PGobject implements Serializable, Cloneable
{
/*
+/*-------------------------------------------------------------------------
+ *
+ * PGpath.java
+ * This implements a path (a multiple segmented line, which may be closed)
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpath.java,v 1.5 2003/03/07 18:39:42 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.geometric;
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
+import java.io.Serializable;
+import java.sql.SQLException;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PGtokenizer;
+import org.postgresql.util.PSQLException;
-/*
- * This implements a path (a multiple segmented line, which may be closed)
- */
public class PGpath extends PGobject implements Serializable, Cloneable
{
/*
+/*-------------------------------------------------------------------------
+ *
+ * PGline.java
+ * It maps to the point datatype in org.postgresql.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpoint.java,v 1.4 2003/03/07 18:39:43 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.geometric;
import java.awt.Point;
-import java.io.*;
-import java.sql.*;
+import java.io.Serializable;
+import java.sql.SQLException;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PGtokenizer;
+import org.postgresql.util.PSQLException;
import org.postgresql.util.*;
/*
* This implements a version of java.awt.Point, except it uses double
* to represent the coordinates.
- *
- * <p>It maps to the point datatype in org.postgresql.
*/
public class PGpoint extends PGobject implements Serializable, Cloneable
{
+/*-------------------------------------------------------------------------
+ *
+ * PGline.java
+ * This implements the polygon datatype within PostgreSQL.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/geometric/Attic/PGpolygon.java,v 1.4 2003/03/07 18:39:43 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.geometric;
-import java.io.*;
-import java.sql.*;
-import org.postgresql.util.*;
+import java.io.Serializable;
+import java.sql.SQLException;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PGtokenizer;
+import org.postgresql.util.PSQLException;
-/*
- * This implements the polygon datatype within PostgreSQL.
- */
public class PGpolygon extends PGobject implements Serializable, Cloneable
{
/*
+/*-------------------------------------------------------------------------
+ *
+ * AbstractJdbc1Connection.java
+ * This class defines methods of the jdbc1 specification. This class is
+ * extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds
+ * the jdbc2 methods. The real Connection class (for jdbc1) is
+ * org.postgresql.jdbc1.Jdbc1Connection
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.17 2003/03/07 18:39:43 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.jdbc1;
import java.util.*;
import org.postgresql.Driver;
import org.postgresql.PGNotification;
-import org.postgresql.PG_Stream;
-import org.postgresql.core.*;
+import org.postgresql.core.BaseConnection;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Encoding;
+import org.postgresql.core.PGStream;
+import org.postgresql.core.QueryExecutor;
+import org.postgresql.core.StartupPacket;
import org.postgresql.fastpath.Fastpath;
import org.postgresql.largeobject.LargeObjectManager;
-import org.postgresql.util.*;
-
+import org.postgresql.util.MD5Digest;
+import org.postgresql.util.PGobject;
+import org.postgresql.util.PSQLException;
+import org.postgresql.util.UnixCrypt;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.16 2003/02/27 05:45:44 barry Exp $
- * This class defines methods of the jdbc1 specification. This class is
- * extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
- * methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
- */
-public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnection
+public abstract class AbstractJdbc1Connection implements BaseConnection
{
// This is the network stream associated with this connection
- private PG_Stream pg_stream;
+ private PGStream pgStream;
- public PG_Stream getPGStream() {
- return pg_stream;
+ public PGStream getPGStream() {
+ return pgStream;
}
protected String PG_HOST;
public boolean autoCommit = true;
public boolean readOnly = false;
- public org.postgresql.Driver this_driver;
+ public Driver this_driver;
private String this_url;
private String cursor = null; // The positioned update cursor name
/*
* Cache of the current isolation level
*/
- private int isolationLevel = java.sql.Connection.TRANSACTION_READ_COMMITTED;
+ private int isolationLevel = Connection.TRANSACTION_READ_COMMITTED;
- public abstract java.sql.Statement createStatement() throws SQLException;
+ public abstract Statement createStatement() throws SQLException;
+ public abstract DatabaseMetaData getMetaData() throws SQLException;
/*
* This method actually opens the connection. It is called by Driver.
* @param d the Driver instantation of the connection
* @exception SQLException if a database access error occurs
*/
- public void openConnection(String host, int port, Properties info, String database, String url, org.postgresql.Driver d) throws SQLException
+ public void openConnection(String host, int port, Properties info, String database, String url, Driver d) throws SQLException
{
firstWarning = null;
if (info.getProperty("user") == null)
throw new PSQLException("postgresql.con.user");
- this_driver = (org.postgresql.Driver)d;
+ this_driver = (Driver)d;
this_url = url;
PG_DATABASE = database;
try
{
l_logLevel = Integer.parseInt(l_logLevelProp);
- if (l_logLevel > org.postgresql.Driver.DEBUG || l_logLevel < org.postgresql.Driver.INFO)
+ if (l_logLevel > Driver.DEBUG || l_logLevel < Driver.INFO)
{
l_logLevel = 0;
}
}
if (l_logLevel > 0)
{
- org.postgresql.Driver.setLogLevel(l_logLevel);
+ Driver.setLogLevel(l_logLevel);
enableDriverManagerLogging();
}
//Print out the driver version number
- if (org.postgresql.Driver.logInfo)
- org.postgresql.Driver.info(org.postgresql.Driver.getVersion());
- if (org.postgresql.Driver.logDebug) {
- org.postgresql.Driver.debug(" ssl = " + useSSL);
- org.postgresql.Driver.debug(" compatible = " + compatible);
- org.postgresql.Driver.debug(" loglevel = " + l_logLevel);
+ if (Driver.logInfo)
+ Driver.info(Driver.getVersion());
+ if (Driver.logDebug) {
+ Driver.debug(" ssl = " + useSSL);
+ Driver.debug(" compatible = " + compatible);
+ Driver.debug(" loglevel = " + l_logLevel);
}
// Now make the initial connection
try
{
- pg_stream = new PG_Stream(host, port);
+ pgStream = new PGStream(host, port);
}
catch (ConnectException cex)
{
try
{
if (useSSL) {
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("Asking server if it supports ssl");
- pg_stream.SendInteger(8,4);
- pg_stream.SendInteger(80877103,4);
+ if (Driver.logDebug)
+ Driver.debug("Asking server if it supports ssl");
+ pgStream.SendInteger(8,4);
+ pgStream.SendInteger(80877103,4);
// now flush the ssl packets to the backend
- pg_stream.flush();
+ pgStream.flush();
// Now get the response from the backend, either an error message
// or an authentication request
- int beresp = pg_stream.ReceiveChar();
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("Server response was (S=Yes,N=No): "+(char)beresp);
+ int beresp = pgStream.ReceiveChar();
+ if (Driver.logDebug)
+ Driver.debug("Server response was (S=Yes,N=No): "+(char)beresp);
switch (beresp)
{
case 'E':
// The most common one to be thrown here is:
// "User authentication failed"
//
- throw new PSQLException("postgresql.con.misc", pg_stream.ReceiveString(encoding));
+ throw new PSQLException("postgresql.con.misc", pgStream.ReceiveString(encoding));
case 'N':
// Server does not support ssl
case 'S':
// Server supports ssl
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("server does support ssl");
- org.postgresql.Driver.makeSSL(pg_stream);
+ if (Driver.logDebug)
+ Driver.debug("server does support ssl");
+ Driver.makeSSL(pgStream);
break;
default:
new StartupPacket(PG_PROTOCOL_LATEST_MAJOR,
PG_PROTOCOL_LATEST_MINOR,
PG_USER,
- database).writeTo(pg_stream);
+ database).writeTo(pgStream);
// now flush the startup packets to the backend
- pg_stream.flush();
+ pgStream.flush();
// Now get the response from the backend, either an error message
// or an authentication request
int areq = -1; // must have a value here
do
{
- int beresp = pg_stream.ReceiveChar();
+ int beresp = pgStream.ReceiveChar();
String salt = null;
byte [] md5Salt = new byte[4];
switch (beresp)
// The most common one to be thrown here is:
// "User authentication failed"
//
- throw new PSQLException("postgresql.con.misc", pg_stream.ReceiveString(encoding));
+ throw new PSQLException("postgresql.con.misc", pgStream.ReceiveString(encoding));
case 'R':
// Get the type of request
- areq = pg_stream.ReceiveIntegerR(4);
+ areq = pgStream.ReceiveIntegerR(4);
// Get the crypt password salt if there is one
if (areq == AUTH_REQ_CRYPT)
{
byte[] rst = new byte[2];
- rst[0] = (byte)pg_stream.ReceiveChar();
- rst[1] = (byte)pg_stream.ReceiveChar();
+ rst[0] = (byte)pgStream.ReceiveChar();
+ rst[1] = (byte)pgStream.ReceiveChar();
salt = new String(rst, 0, 2);
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("Crypt salt=" + salt);
+ if (Driver.logDebug)
+ Driver.debug("Crypt salt=" + salt);
}
// Or get the md5 password salt if there is one
if (areq == AUTH_REQ_MD5)
{
- md5Salt[0] = (byte)pg_stream.ReceiveChar();
- md5Salt[1] = (byte)pg_stream.ReceiveChar();
- md5Salt[2] = (byte)pg_stream.ReceiveChar();
- md5Salt[3] = (byte)pg_stream.ReceiveChar();
+ md5Salt[0] = (byte)pgStream.ReceiveChar();
+ md5Salt[1] = (byte)pgStream.ReceiveChar();
+ md5Salt[2] = (byte)pgStream.ReceiveChar();
+ md5Salt[3] = (byte)pgStream.ReceiveChar();
salt = new String(md5Salt, 0, 4);
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("MD5 salt=" + salt);
+ if (Driver.logDebug)
+ Driver.debug("MD5 salt=" + salt);
}
// now send the auth packet
break;
case AUTH_REQ_KRB4:
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("postgresql: KRB4");
+ if (Driver.logDebug)
+ Driver.debug("postgresql: KRB4");
throw new PSQLException("postgresql.con.kerb4");
case AUTH_REQ_KRB5:
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("postgresql: KRB5");
+ if (Driver.logDebug)
+ Driver.debug("postgresql: KRB5");
throw new PSQLException("postgresql.con.kerb5");
case AUTH_REQ_PASSWORD:
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("postgresql: PASSWORD");
- pg_stream.SendInteger(5 + password.length(), 4);
- pg_stream.Send(password.getBytes());
- pg_stream.SendInteger(0, 1);
- pg_stream.flush();
+ if (Driver.logDebug)
+ Driver.debug("postgresql: PASSWORD");
+ pgStream.SendInteger(5 + password.length(), 4);
+ pgStream.Send(password.getBytes());
+ pgStream.SendInteger(0, 1);
+ pgStream.flush();
break;
case AUTH_REQ_CRYPT:
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("postgresql: CRYPT");
+ if (Driver.logDebug)
+ Driver.debug("postgresql: CRYPT");
String crypted = UnixCrypt.crypt(salt, password);
- pg_stream.SendInteger(5 + crypted.length(), 4);
- pg_stream.Send(crypted.getBytes());
- pg_stream.SendInteger(0, 1);
- pg_stream.flush();
+ pgStream.SendInteger(5 + crypted.length(), 4);
+ pgStream.Send(crypted.getBytes());
+ pgStream.SendInteger(0, 1);
+ pgStream.flush();
break;
case AUTH_REQ_MD5:
- if (org.postgresql.Driver.logDebug)
- org.postgresql.Driver.debug("postgresql: MD5");
+ if (Driver.logDebug)
+ Driver.debug("postgresql: MD5");
byte[] digest = MD5Digest.encode(PG_USER, password, md5Salt);
- pg_stream.SendInteger(5 + digest.length, 4);
- pg_stream.Send(digest);
- pg_stream.SendInteger(0, 1);
- pg_stream.flush();
+ pgStream.SendInteger(5 + digest.length, 4);
+ pgStream.Send(digest);
+ pgStream.SendInteger(0, 1);
+ pgStream.flush();
break;
default:
int beresp;
do
{
- beresp = pg_stream.ReceiveChar();
+ beresp = pgStream.ReceiveChar();
switch (beresp)
{
case 'K':
- pid = pg_stream.ReceiveIntegerR(4);
- ckey = pg_stream.ReceiveIntegerR(4);
+ pid = pgStream.ReceiveIntegerR(4);
+ ckey = pgStream.ReceiveIntegerR(4);
break;
case 'E':
- throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
+ throw new PSQLException("postgresql.con.backend", pgStream.ReceiveString(encoding));
case 'N':
- addWarning(pg_stream.ReceiveString(encoding));
+ addWarning(pgStream.ReceiveString(encoding));
break;
default:
throw new PSQLException("postgresql.con.setup");
// Expect ReadyForQuery packet
do
{
- beresp = pg_stream.ReceiveChar();
+ beresp = pgStream.ReceiveChar();
switch (beresp)
{
case 'Z':
break;
case 'N':
- addWarning(pg_stream.ReceiveString(encoding));
+ addWarning(pgStream.ReceiveString(encoding));
break;
case 'E':
- throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
+ throw new PSQLException("postgresql.con.backend", pgStream.ReceiveString(encoding));
default:
throw new PSQLException("postgresql.con.setup");
}
// more than one round trip to the backend during connection startup.
- java.sql.ResultSet resultSet
+ BaseResultSet resultSet
= execSQL("set datestyle to 'ISO'; select version(), " + encodingQuery + ";");
if (! resultSet.next())
//support is now always included
if (haveMinimumServerVersion("7.3"))
{
- java.sql.ResultSet acRset =
+ BaseResultSet acRset =
execSQL("set client_encoding = 'UNICODE'; show autocommit");
//set encoding to be unicode
* Return the instance of org.postgresql.Driver
* that created this connection
*/
- public org.postgresql.Driver getDriver()
+ public Driver getDriver()
{
return this_driver;
}
/** Simple query execution.
*/
- public java.sql.ResultSet execSQL (String s) throws SQLException
+ public BaseResultSet execSQL (String s) throws SQLException
{
final Object[] nullarr = new Object[0];
- java.sql.Statement stat = createStatement();
+ BaseStatement stat = (BaseStatement) createStatement();
return QueryExecutor.execute(new String[] { s },
nullarr,
stat);
public Fastpath getFastpathAPI() throws SQLException
{
if (fastpath == null)
- fastpath = new Fastpath(this, pg_stream);
+ fastpath = new Fastpath(this, pgStream);
return fastpath;
}
public LargeObjectManager getLargeObjectAPI() throws SQLException
{
if (largeobject == null)
- largeobject = new LargeObjectManager((java.sql.Connection)this);
+ largeobject = new LargeObjectManager(this);
return largeobject;
}
* You can use the getValue() or setValue() methods to handle the returned
* object. Custom objects can have their own methods.
*
- * In 6.4, this is extended to use the org.postgresql.util.Serialize class to
- * allow the Serialization of Java Objects into the database without using
- * Blobs. Refer to that class for details on how this new feature works.
- *
* @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
{
{
Object o = objectTypes.get(type);
- // If o is null, then the type is unknown, so check to see if type
- // is an actual table name. If it does, see if a Class is known that
- // can handle it
- if (o == null)
- {
- Serialize ser = new Serialize((java.sql.Connection)this, type);
- objectTypes.put(type, ser);
- return ser.fetch(Integer.parseInt(value));
- }
-
+ // If o is null, then the type is unknown.
// If o is not null, and it is a String, then its a class name that
// extends PGobject.
//
// This is used to implement the org.postgresql unique types (like lseg,
// point, etc).
- if (o instanceof String)
+ if (o != null && o instanceof String)
{
// 6.3 style extending PG_Object
PGobject obj = null;
obj.setValue(value);
return (Object)obj;
}
- else
- {
- // If it's an object, it should be an instance of our Serialize class
- // If so, then call it's fetch method.
- if (o instanceof Serialize)
- return ((Serialize)o).fetch(Integer.parseInt(value));
- }
}
catch (SQLException sx)
{
return null;
}
- /*
- * This stores an object into the database. This method was
- * deprecated in 7.2 bacause an OID can be larger than the java signed
- * int returned by this method.
- * @deprecated Replaced by storeObject() in 7.2
- */
- public int putObject(Object o) throws SQLException
- {
- return (int) storeObject(o);
- }
-
- /*
- * This stores an object into the database.
- * @param o Object to store
- * @return OID of the new rectord
- * @exception SQLException if value is not correct for this type
- * @see org.postgresql.util.Serialize
- * @since 7.2
- */
- public long storeObject(Object o) throws SQLException
- {
- try
- {
- String type = o.getClass().getName();
- Object x = objectTypes.get(type);
-
- // If x is null, then the type is unknown, so check to see if type
- // is an actual table name. If it does, see if a Class is known that
- // can handle it
- if (x == null)
- {
- Serialize ser = new Serialize((java.sql.Connection)this, type);
- objectTypes.put(type, ser);
- return ser.storeObject(o);
- }
-
- // If it's an object, it should be an instance of our Serialize class
- // If so, then call it's fetch method.
- if (x instanceof Serialize)
- return ((Serialize)x).storeObject(o);
-
- // Thow an exception because the type is unknown
- throw new PSQLException("postgresql.con.strobj");
-
- }
- catch (SQLException sx)
- {
- // rethrow the exception. Done because we capture any others next
- sx.fillInStackTrace();
- throw sx;
- }
- catch (Exception ex)
- {
- throw new PSQLException("postgresql.con.strobjex", ex);
- }
- }
-
/*
* This allows client code to add a handler for one of org.postgresql's
* more unique data types.
*/
public void close() throws SQLException
{
- if (pg_stream != null)
+ if (pgStream != null)
{
try
{
- pg_stream.SendChar('X');
- pg_stream.flush();
- pg_stream.close();
+ pgStream.SendChar('X');
+ pgStream.flush();
+ pgStream.close();
}
catch (IOException e)
{}
finally
{
- pg_stream = null;
+ pgStream = null;
}
}
}
String sql = "show transaction isolation level";
String level = null;
if (haveMinimumServerVersion("7.3")) {
- ResultSet rs = execSQL(sql);
+ BaseResultSet rs = execSQL(sql);
if (rs.next()) {
level = rs.getString(1);
}
}
if (level != null) {
if (level.indexOf("READ COMMITTED") != -1)
- return java.sql.Connection.TRANSACTION_READ_COMMITTED;
+ return Connection.TRANSACTION_READ_COMMITTED;
else if (level.indexOf("READ UNCOMMITTED") != -1)
- return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
+ return Connection.TRANSACTION_READ_UNCOMMITTED;
else if (level.indexOf("REPEATABLE READ") != -1)
- return java.sql.Connection.TRANSACTION_REPEATABLE_READ;
+ return Connection.TRANSACTION_REPEATABLE_READ;
else if (level.indexOf("SERIALIZABLE") != -1)
- return java.sql.Connection.TRANSACTION_SERIALIZABLE;
+ return Connection.TRANSACTION_SERIALIZABLE;
}
- return java.sql.Connection.TRANSACTION_READ_COMMITTED;
+ return Connection.TRANSACTION_READ_COMMITTED;
}
/*
isolationLevelSQL = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ";
switch (isolationLevel)
{
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
+ case Connection.TRANSACTION_READ_COMMITTED:
isolationLevelSQL += "READ COMMITTED";
break;
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
+ case Connection.TRANSACTION_SERIALIZABLE:
isolationLevelSQL += "SERIALIZABLE";
break;
default:
switch (isolationLevel)
{
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
+ case Connection.TRANSACTION_READ_COMMITTED:
sb.append(" READ COMMITTED");
break;
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
+ case Connection.TRANSACTION_SERIALIZABLE:
sb.append(" SERIALIZABLE");
break;
} else {
sql = "SELECT typname FROM pg_type WHERE oid = " +oid;
}
- ResultSet result = execSQL(sql);
- if (((AbstractJdbc1ResultSet)result).getColumnCount() != 1 || ((AbstractJdbc1ResultSet)result).getTupleCount() != 1) {
+ BaseResultSet result = execSQL(sql);
+ if (result.getColumnCount() != 1 || result.getTupleCount() != 1) {
throw new PSQLException("postgresql.unexpected");
}
result.next();
} else {
sql = "SELECT oid FROM pg_type WHERE typname='" + typeName + "'";
}
- ResultSet result = execSQL(sql);
- if (((AbstractJdbc1ResultSet)result).getColumnCount() != 1 || ((AbstractJdbc1ResultSet)result).getTupleCount() != 1)
+ BaseResultSet result = execSQL(sql);
+ if (result.getColumnCount() != 1 || result.getTupleCount() != 1)
throw new PSQLException("postgresql.unexpected");
result.next();
oid = Integer.parseInt(result.getString(1));
*/
public boolean isClosed() throws SQLException
{
- return (pg_stream == null);
+ return (pgStream == null);
}
/*
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP
};
+ public void cancelQuery() throws SQLException
+ {
+ org.postgresql.core.PGStream cancelStream = null;
+ try
+ {
+ cancelStream = new org.postgresql.core.PGStream(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
+ }
+ }
+
+
//Methods to support postgres notifications
public void addNotification(org.postgresql.PGNotification p_notification)
{
import java.sql.*;
import java.util.*;
-import org.postgresql.Field;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Field;
import org.postgresql.util.PSQLException;
import org.postgresql.Driver;
}
rs.close();
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
/*
v.addElement(tuple);
}
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
/*
}
rs.close();
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
/*
}
rs.close();
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
/*
}
rs.close();
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
private static void sortStringArray(String s[]) {
v.addElement(tuple);
}
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
/*
/* Perhaps we should check that the given
* catalog.schema.table actually exists. -KJ
*/
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
/*
tuples.addElement(tuple);
}
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, tuples, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, tuples, "OK", 1, 0, false);
}
/*
}
rs.close();
- return ((AbstractJdbc1Statement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
}
/*
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Vector;
-import org.postgresql.Field;
+import org.postgresql.Driver;
+import org.postgresql.core.BaseConnection;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Field;
import org.postgresql.core.Encoding;
+import org.postgresql.core.QueryExecutor;
import org.postgresql.largeobject.*;
import org.postgresql.util.PGbytea;
+import org.postgresql.util.PGtokenizer;
import org.postgresql.util.PSQLException;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.9 2003/02/04 09:20:08 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.10 2003/03/07 18:39:44 barry Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2ResultSet which adds the jdbc2
* methods. The real ResultSet class (for jdbc1) is org.postgresql.jdbc1.Jdbc1ResultSet
*/
-public abstract class AbstractJdbc1ResultSet
+public abstract class AbstractJdbc1ResultSet implements BaseResultSet
{
protected Vector rows; // The results
- protected Statement statement;
-
- public org.postgresql.PGStatement getPGStatement() {
- return (org.postgresql.PGStatement) statement;
- }
-
+ protected BaseStatement statement;
protected Field fields[]; // The field descriptions
protected String status; // Status of the result
protected boolean binaryCursor = false; // is the data binary or Strings
protected long insertOID; // The oid of an inserted row
protected int current_row; // Our pointer to where we are at
protected byte[][] this_row; // the current row result
- protected org.postgresql.PGConnection connection; // the connection which we returned from
+ protected BaseConnection connection; // the connection which we returned from
protected SQLWarning warnings = null; // The warning chain
protected boolean wasNullFlag = false; // the flag for wasNull()
// We can chain multiple resultSets together - this points to
// next resultSet in the chain.
- protected ResultSet next = null;
+ protected BaseResultSet next = null;
- protected StringBuffer sbuf = null;
+ private StringBuffer sbuf = null;
public byte[][] rowBuffer = null;
+ public abstract ResultSetMetaData getMetaData() throws SQLException;
- public AbstractJdbc1ResultSet(Statement statement,
+ public AbstractJdbc1ResultSet(BaseStatement statement,
Field[] fields,
Vector tuples,
String status,
long insertOID,
boolean binaryCursor)
{
- this.connection = ((org.postgresql.jdbc1.AbstractJdbc1Statement)statement).getPGConnection();
+ this.connection = statement.getPGConnection();
this.statement = statement;
this.fields = fields;
this.rows = tuples;
this.binaryCursor = binaryCursor;
}
+ public BaseStatement getPGStatement() {
+ return statement;
+ }
+
+ public StringBuffer getStringBuffer() {
+ return sbuf;
+ }
+
+ //This is implemented in jdbc2
+ public void setStatement(BaseStatement statement) {
+ }
//method to reinitialize a result set with more data
public void reInit (Field[] fields, Vector tuples, String status,
if (++current_row >= rows.size())
{
- int fetchSize = ((AbstractJdbc1Statement)statement).fetchSize;
+ int fetchSize = statement.getFetchSize();
// Must be false if we weren't batching.
if (fetchSize == 0)
return false;
String[] sql = new String[1];
String[] binds = new String[0];
// Is this the correct query???
- String cursorName = ((AbstractJdbc1Statement)statement).m_statementName;
+ String cursorName = statement.getStatementName();
sql[0] = "FETCH FORWARD " + fetchSize + " FROM " + cursorName;
- org.postgresql.core.QueryExecutor.execute(sql,
+ QueryExecutor.execute(sql,
binds,
- (java.sql.ResultSet)this);
+ this);
// Test the new rows array.
if (rows.size() == 0)
//If the data is already binary then just return it
return this_row[columnIndex - 1];
}
- else if (((AbstractJdbc1Connection)connection).haveMinimumCompatibleVersion("7.2"))
+ else if (connection.haveMinimumCompatibleVersion("7.2"))
{
//Version 7.2 supports the bytea datatype for byte arrays
if (fields[columnIndex - 1].getPGType().equals("bytea"))
public Time getTime(int columnIndex) throws SQLException
{
- return toTime( getString(columnIndex), (java.sql.ResultSet)this, fields[columnIndex - 1].getPGType() );
+ return toTime( getString(columnIndex), this, fields[columnIndex - 1].getPGType() );
}
public Timestamp getTimestamp(int columnIndex) throws SQLException
{
- return toTimestamp( getString(columnIndex), (java.sql.ResultSet)this, fields[columnIndex - 1].getPGType() );
+ return toTimestamp( getString(columnIndex), this, fields[columnIndex - 1].getPGType() );
}
public InputStream getAsciiStream(int columnIndex) throws SQLException
if (wasNullFlag)
return null;
- if (((AbstractJdbc1Connection)connection).haveMinimumCompatibleVersion("7.2"))
+ if (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
if (wasNullFlag)
return null;
- if (((AbstractJdbc1Connection)connection).haveMinimumCompatibleVersion("7.2"))
+ if (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
if (wasNullFlag)
return null;
- if (((AbstractJdbc1Connection)connection).haveMinimumCompatibleVersion("7.2"))
+ if (connection.haveMinimumCompatibleVersion("7.2"))
{
//Version 7.2 supports BinaryStream for all PG bytea type
//As the spec/javadoc for this method indicate this is to be used for
public String getCursorName() throws SQLException
{
- return ((AbstractJdbc1Connection)connection).getCursorName();
+ return (connection.getCursorName());
}
/*
*
* @return the next ResultSet, or null if there are none
*/
- public java.sql.ResultSet getNext()
+ public ResultSet getNext()
{
- return (java.sql.ResultSet)next;
+ return (ResultSet)next;
}
/*
* This following method allows us to add a ResultSet object
* to the end of the current chain.
*/
- public void append(AbstractJdbc1ResultSet r)
+ public void append(BaseResultSet r)
{
if (next == null)
- next = (java.sql.ResultSet)r;
+ next = r;
else
- ((AbstractJdbc1ResultSet)next).append(r);
+ next.append(r);
}
/*
// Handle Money
if (s.charAt(0) == '(')
{
- s = "-" + org.postgresql.util.PGtokenizer.removePara(s).substring(1);
+ s = "-" + PGtokenizer.removePara(s).substring(1);
}
if (s.charAt(0) == '$')
{
}
}
- public static Time toTime(String s, java.sql.ResultSet resultSet, String pgDataType) throws SQLException
+ public static Time toTime(String s, BaseResultSet resultSet, String pgDataType) throws SQLException
{
if (s == null)
return null; // SQL NULL
*
* @throws SQLException if there is a problem parsing s.
**/
- public static Timestamp toTimestamp(String s, java.sql.ResultSet resultSet, String pgDataType)
+ public static Timestamp toTimestamp(String s, BaseResultSet resultSet, String pgDataType)
throws SQLException
{
- AbstractJdbc1ResultSet rs = (AbstractJdbc1ResultSet)resultSet;
+ BaseResultSet rs = resultSet;
if (s == null)
return null;
// SimpleDateFormat objects
synchronized (rs)
{
+ StringBuffer l_sbuf = rs.getStringBuffer();
SimpleDateFormat df = null;
- if ( org.postgresql.Driver.logDebug )
- org.postgresql.Driver.debug("the data from the DB is " + s);
+ if ( Driver.logDebug )
+ Driver.debug("the data from the DB is " + s);
// If first time, create the buffer, otherwise clear it.
- if (rs.sbuf == null)
- rs.sbuf = new StringBuffer(32);
+ if (l_sbuf == null)
+ l_sbuf = new StringBuffer(32);
else
{
- rs.sbuf.setLength(0);
+ l_sbuf.setLength(0);
}
// Copy s into sbuf for parsing.
- rs.sbuf.append(s);
+ l_sbuf.append(s);
int slen = s.length();
// For a Timestamp, the fractional seconds are stored in the
// cut the copy to second value "2001-12-07 16:29:22"
int i = 19;
- rs.sbuf.setLength(i);
+ l_sbuf.setLength(i);
char c = s.charAt(i++);
if (c == '.')
{
// prepend the GMT part and then add the remaining bit of
// the string.
- rs.sbuf.append(" GMT");
- rs.sbuf.append(c);
- rs.sbuf.append(s.substring(i, slen));
+ l_sbuf.append(" GMT");
+ l_sbuf.append(c);
+ l_sbuf.append(s.substring(i, slen));
// Lastly, if the tz part doesn't specify the :MM part then
// we add ":00" for java.
if (slen - i < 5)
- rs.sbuf.append(":00");
+ l_sbuf.append(":00");
// we'll use this dateformat string to parse the result.
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
//If timestamptz then we use GMT, else local timezone
if (pgDataType.equals("timestamptz"))
{
- rs.sbuf.append(" GMT");
+ l_sbuf.append(" GMT");
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
}
else
//If timestamptz then we use GMT, else local timezone
if (pgDataType.equals("timestamptz"))
{
- rs.sbuf.append(" GMT");
+ l_sbuf.append(" GMT");
df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
}
else
try
{
// All that's left is to parse the string and return the ts.
- if ( org.postgresql.Driver.logDebug )
- org.postgresql.Driver.debug("the data after parsing is "
- + rs.sbuf.toString() + " with " + nanos + " nanos");
+ if ( Driver.logDebug )
+ Driver.debug("the data after parsing is "
+ + l_sbuf.toString() + " with " + nanos + " nanos");
Timestamp result =
- new Timestamp(df.parse(rs.sbuf.toString()).getTime());
+ new Timestamp(df.parse(l_sbuf.toString()).getTime());
result.setNanos(nanos);
return result;
}
import java.lang.*;
import java.util.*;
-import org.postgresql.*;
+import org.postgresql.core.Field;
import org.postgresql.util.*;
import java.sql.SQLException;
import java.sql.Types;
import java.math.BigDecimal;
import java.sql.*;
import java.util.Vector;
+import org.postgresql.core.BaseConnection;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Field;
+import org.postgresql.core.QueryExecutor;
import org.postgresql.largeobject.*;
import org.postgresql.util.*;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.17 2003/02/09 23:14:55 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.18 2003/03/07 18:39:44 barry Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
*/
-public abstract class AbstractJdbc1Statement implements org.postgresql.PGStatement
+public abstract class AbstractJdbc1Statement implements BaseStatement
{
// The connection who created us
- protected AbstractJdbc1Connection connection;
-
- public org.postgresql.PGConnection getPGConnection() {
- return connection;
- }
+ protected BaseConnection connection;
/** The warnings chain. */
protected SQLWarning warnings = null;
protected boolean replaceProcessingEnabled = true;
/** The current results */
- protected java.sql.ResultSet result = null;
+ protected BaseResultSet result = null;
// Static variables for parsing SQL when replaceProcessing is true.
private static final short IN_SQLCODE = 0;
protected Object callResult;
- public abstract java.sql.ResultSet createResultSet(org.postgresql.Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
+ public abstract BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
- public AbstractJdbc1Statement (AbstractJdbc1Connection connection)
+ public AbstractJdbc1Statement (BaseConnection connection)
{
this.connection = connection;
}
- public AbstractJdbc1Statement (AbstractJdbc1Connection connection, String p_sql) throws SQLException
+ public AbstractJdbc1Statement (BaseConnection connection, String p_sql) throws SQLException
{
this.connection = connection;
parseSqlStmt(p_sql); // this allows Callable stmt to override
}
+ public BaseConnection getPGConnection() {
+ return connection;
+ }
+
+ public String getStatementName() {
+ return m_statementName;
+ }
+
+ public int getFetchSize() throws SQLException {
+ return fetchSize;
+ }
+
protected void parseSqlStmt (String p_sql) throws SQLException
{
String l_sql = p_sql;
{
try
{
- ((AbstractJdbc1Connection)connection).execSQL("DEALLOCATE " + m_statementName);
+ connection.execSQL("DEALLOCATE " + m_statementName);
}
catch (Exception e)
{
else
this.execute();
- while (result != null && !((AbstractJdbc1ResultSet)result).reallyResultSet())
- result = ((AbstractJdbc1ResultSet)result).getNext();
+ while (result != null && !result.reallyResultSet())
+ result = (BaseResultSet) result.getNext();
if (result == null)
throw new PSQLException("postgresql.stat.noresult");
- return result;
+ return (ResultSet) result;
}
/*
//If we have already created a server prepared statement, we need
//to deallocate the existing one
if (m_statementName != null) {
- ((AbstractJdbc1Connection)connection).execSQL("DEALLOCATE " + m_statementName);
+ connection.execSQL("DEALLOCATE " + m_statementName);
m_statementName = null;
m_origSqlFragments = null;
m_executeSqlFragments = null;
public int executeUpdate() throws SQLException
{
this.execute();
- if (((AbstractJdbc1ResultSet)result).reallyResultSet())
+ if (result.reallyResultSet())
throw new PSQLException("postgresql.stat.result");
return this.getUpdateCount();
}
//If we have already created a server prepared statement, we need
//to deallocate the existing one
if (m_statementName != null) {
- ((AbstractJdbc1Connection)connection).execSQL("DEALLOCATE " + m_statementName);
+ connection.execSQL("DEALLOCATE " + m_statementName);
m_statementName = null;
m_origSqlFragments = null;
m_executeSqlFragments = null;
}
// New in 7.1, pass Statement so that ExecSQL can customise to it
- result = org.postgresql.core.QueryExecutor.execute(m_sqlFragments,
+ result = QueryExecutor.execute(m_sqlFragments,
m_binds,
- (java.sql.Statement)this);
+ this);
//If we are executing a callable statement function set the return data
if (isFunction)
{
- if (!((AbstractJdbc1ResultSet)result).reallyResultSet())
+ if (!result.reallyResultSet())
throw new PSQLException("postgresql.call.noreturnval");
if (!result.next ())
throw new PSQLException ("postgresql.call.noreturnval");
}
else
{
- return (result != null && ((AbstractJdbc1ResultSet)result).reallyResultSet());
+ return (result != null && result.reallyResultSet());
}
}
m_sqlFragments[m_sqlFragments.length - 1] += (";" + endCurs);
}
- result = org.postgresql.core.QueryExecutor.execute(m_sqlFragments,
+ result = QueryExecutor.execute(m_sqlFragments,
m_binds,
- (java.sql.Statement)this);
+ this);
//If we are executing a callable statement function set the return data
if (isFunction)
{
- if (!((AbstractJdbc1ResultSet)result).reallyResultSet())
+ if (!result.reallyResultSet())
throw new PSQLException("postgresql.call.noreturnval");
if (!result.next ())
throw new PSQLException ("postgresql.call.noreturnval");
}
else
{
- return (result != null && ((AbstractJdbc1ResultSet)result).reallyResultSet());
+ return (result != null && result.reallyResultSet());
}
}
*/
public void setCursorName(String name) throws SQLException
{
- ((AbstractJdbc1Connection)connection).setCursorName(name);
+ connection.setCursorName(name);
}
return -1;
if (isFunction)
return 1;
- if (((AbstractJdbc1ResultSet)result).reallyResultSet())
+ if (result.reallyResultSet())
return -1;
- return ((AbstractJdbc1ResultSet)result).getResultCount();
+ return result.getResultCount();
}
/*
*/
public boolean getMoreResults() throws SQLException
{
- result = ((AbstractJdbc1ResultSet)result).getNext();
- return (result != null && ((AbstractJdbc1ResultSet)result).reallyResultSet());
+ result = (BaseResultSet) result.getNext();
+ return (result != null && result.reallyResultSet());
}
{
if (result == null)
return null;
- return ((AbstractJdbc1ResultSet)result).getStatusString();
+ return result.getStatusString();
}
/*
*/
public java.sql.ResultSet getResultSet() throws SQLException
{
- if (result != null && ((AbstractJdbc1ResultSet) result).reallyResultSet())
- return result;
+ if (result != null && result.reallyResultSet())
+ return (ResultSet) result;
return null;
}
// If using server prepared statements deallocate them
if (m_useServerPrepare && m_statementName != null) {
- ((AbstractJdbc1Connection)connection).execSQL("DEALLOCATE " + m_statementName);
+ connection.execSQL("DEALLOCATE " + m_statementName);
}
// Disasociate it from us (For Garbage Collection)
/*
*
* The following methods are postgres extensions and are defined
- * in the interface org.postgresql.Statement
+ * in the interface BaseStatement
*
*/
{
if (result == null)
return 0;
- return (int)((AbstractJdbc1ResultSet)result).getLastOID();
+ return (int) result.getLastOID();
}
/*
{
if (result == null)
return 0;
- return ((AbstractJdbc1ResultSet)result).getLastOID();
+ return result.getLastOID();
}
/*
/*
* This stores an Object into a parameter.
- * <p>New for 6.4, if the object is not recognised, but it is
- * Serializable, then the object is serialised using the
- * org.postgresql.util.Serialize class.
*/
public void setObject(int parameterIndex, Object x) throws SQLException
{
else if (x instanceof PGobject)
setString(parameterIndex, ((PGobject)x).getValue(), PG_TEXT);
else
- // Try to store java object in database
- setSerialize(parameterIndex, connection.storeObject(x), x.getClass().getName() );
+ // Try to store as a string in database
+ setString(parameterIndex, x.toString(), PG_TEXT);
}
/*
return callResult;
}
+ //This method is implemeted in jdbc2
+ public int getResultSetConcurrency() throws SQLException
+ {
+ return 0;
+ }
+
/*
* Returns the SQL statement with the current template values
* substituted.
m_bindTypes[paramIndex - 1] = type;
}
- /*
- * Set a parameter to a tablerow-type oid reference.
- *
- * @param parameterIndex the first parameter is 1...
- * @param x the oid of the object from org.postgresql.util.Serialize.store
- * @param classname the classname of the java object x
- * @exception SQLException if a database access error occurs
- */
- private void setSerialize(int parameterIndex, long x, String classname) throws SQLException
- {
- // converts . to _, toLowerCase, and ensures length < max name length
- String tablename = Serialize.toPostgreSQL((java.sql.Connection)connection, classname );
- DriverManager.println("setSerialize: setting " + x + "::" + tablename );
-
- // OID reference to tablerow-type must be cast like: <oid>::<tablename>
- // Note that postgres support for tablerow data types is incomplete/broken.
- // This cannot be just a plain OID because then there would be ambiguity
- // between when you want the oid itself and when you want the object
- // an oid references.
- bind(parameterIndex, Long.toString(x) + "::" + tablename, PG_TEXT );
- }
-
/**
* this method will turn a string of the form
* {? = call <some_function> (?, [?,..]) }
//If turning server prepared statements off deallocate statement
//and reset statement name
if (m_useServerPrepare != flag && !flag)
- ((AbstractJdbc1Connection)connection).execSQL("DEALLOCATE " + m_statementName);
+ connection.execSQL("DEALLOCATE " + m_statementName);
m_statementName = null;
m_useServerPrepare = flag;
} else {
import java.sql.*;
+import java.util.Vector;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
public class Jdbc1CallableStatement extends AbstractJdbc1Statement implements java.sql.CallableStatement
{
super(connection, sql);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.util.Vector;
import java.sql.*;
-import org.postgresql.Field;
+import org.postgresql.core.Field;
import org.postgresql.util.PSQLException;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.6 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.7 2003/03/07 18:39:44 barry Exp $
* This class implements the java.sql.Connection interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1Connection
import java.sql.*;
import java.util.*;
-import org.postgresql.Field;
+import org.postgresql.core.Field;
import org.postgresql.util.PSQLException;
public class Jdbc1DatabaseMetaData extends AbstractJdbc1DatabaseMetaData implements java.sql.DatabaseMetaData
import java.sql.*;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
public class Jdbc1PreparedStatement extends AbstractJdbc1Statement implements PreparedStatement
{
super(connection, sql);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.sql.*;
import java.util.Vector;
-import org.postgresql.Field;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.5 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.6 2003/03/07 18:39:44 barry Exp $
* This class implements the java.sql.ResultSet interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1ResultSet
public class Jdbc1ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet implements java.sql.ResultSet
{
- public Jdbc1ResultSet(Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public Jdbc1ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super(statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
package org.postgresql.jdbc1;
+import java.util.Vector;
+import org.postgresql.core.Field;
+
public class Jdbc1ResultSetMetaData extends AbstractJdbc1ResultSetMetaData implements java.sql.ResultSetMetaData
{
- public Jdbc1ResultSetMetaData(java.util.Vector rows, org.postgresql.Field[] fields)
+ public Jdbc1ResultSetMetaData(Vector rows, Field[] fields)
{
super(rows, fields);
}
import java.sql.*;
+import java.util.Vector;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.4 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.5 2003/03/07 18:39:44 barry Exp $
* This class implements the java.sql.Statement interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1Statement
super(c);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.text.*;
import java.util.*;
import java.sql.*;
-import org.postgresql.Field;
import org.postgresql.PGConnection;
import org.postgresql.largeobject.*;
import java.text.*;
import java.util.*;
import java.sql.*;
-import org.postgresql.Field;
import org.postgresql.PGConnection;
import org.postgresql.largeobject.*;
import java.sql.*;
import org.postgresql.util.PSQLException;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.3 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.4 2003/03/07 18:39:44 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
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
import java.util.*;
import org.postgresql.Driver;
-import org.postgresql.Field;
+import org.postgresql.core.Field;
import org.postgresql.util.PSQLException;
public abstract class AbstractJdbc2DatabaseMetaData extends org.postgresql.jdbc1.AbstractJdbc1DatabaseMetaData
import java.text.SimpleDateFormat;
import java.util.*;
import org.postgresql.Driver;
-import org.postgresql.Field;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.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.14 2003/02/27 05:56:27 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.15 2003/03/07 18:39:45 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
private PreparedStatement selectStatement = null;
- public AbstractJdbc2ResultSet(Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public AbstractJdbc2ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super (statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
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 );
+ return (java.sql.Array) new org.postgresql.jdbc2.Array( connection, i, fields[i - 1], this );
}
// This one needs some thought, as not all ResultSets come from a statement
public Statement getStatement() throws SQLException
{
- return statement;
+ return (Statement) statement;
}
}
- public void setStatement(Statement statement)
+ public void setStatement(BaseStatement statement)
{
this.statement = statement;
}
import java.lang.*;
import java.sql.*;
import java.util.*;
-import org.postgresql.*;
+import org.postgresql.core.Field;
import org.postgresql.util.*;
public abstract class AbstractJdbc2ResultSetMetaData extends org.postgresql.jdbc1.AbstractJdbc1ResultSetMetaData
import java.math.*;
import java.sql.*;
import java.util.Vector;
+import org.postgresql.Driver;
import org.postgresql.largeobject.*;
import org.postgresql.util.PSQLException;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.11 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.12 2003/03/07 18:39:45 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 AbstractJdbc2Statement (AbstractJdbc2Connection c)
{
super(c);
- resultsettype = java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE;
- concurrency = java.sql.ResultSet.CONCUR_READ_ONLY;
+ resultsettype = ResultSet.TYPE_SCROLL_INSENSITIVE;
+ concurrency = ResultSet.CONCUR_READ_ONLY;
}
public AbstractJdbc2Statement(AbstractJdbc2Connection connection, String sql) throws SQLException
boolean l_return = super.execute();
//Now do the jdbc2 specific stuff
//required for ResultSet.getStatement() to work and updateable resultsets
- ((AbstractJdbc2ResultSet)result).setStatement((Statement)this);
+ result.setStatement(this);
return l_return;
}
public void cancel() throws SQLException
{
- ((AbstractJdbc2Connection)connection).cancelQuery();
+ connection.cancelQuery();
}
- public java.sql.Connection getConnection() throws SQLException
+ public Connection getConnection() throws SQLException
{
- return (java.sql.Connection)connection;
+ return (Connection) connection;
}
public int getFetchDirection() throws SQLException
throw new PSQLException("postgresql.psqlnotimp");
}
- public int getFetchSize() throws SQLException
- {
- return super.fetchSize;
- }
-
public int getResultSetConcurrency() throws SQLException
{
return concurrency;
{
// I don't think this should happen, since it's a hint it should just
// fail quietly.
- // throw org.postgresql.Driver.notImplemented();
+ // throw Driver.notImplemented();
}
public void setFetchSize(int rows) throws SQLException
batch.addElement(l_statement);
}
- public java.sql.ResultSetMetaData getMetaData() throws SQLException
+ public ResultSetMetaData getMetaData() throws SQLException
{
- java.sql.ResultSet rs = getResultSet();
+ ResultSet rs = getResultSet();
if (rs != null)
return rs.getMetaData();
public void setRef(int i, Ref x) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public void setDate(int i, java.sql.Date d, java.util.Calendar cal) throws SQLException
public java.sql.Array getArray(int i) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public java.math.BigDecimal getBigDecimal(int parameterIndex) throws SQLException
public Blob getBlob(int i) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public Clob getClob(int i) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public Object getObject(int i, java.util.Map map) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public Ref getRef(int i) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public java.sql.Date getDate(int i, java.util.Calendar cal) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public Time getTime(int i, java.util.Calendar cal) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
public Timestamp getTimestamp(int i, java.util.Calendar cal) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
// no custom types allowed yet..
public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException
{
- throw org.postgresql.Driver.notImplemented();
+ throw Driver.notImplemented();
}
import java.sql.*;
import java.util.*;
import java.math.BigDecimal;
-import org.postgresql.Field;
+import org.postgresql.core.BaseConnection;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Field;
import org.postgresql.util.*;
/*
public class Array implements java.sql.Array
{
- private org.postgresql.PGConnection conn = null;
- private org.postgresql.Field field = null;
- private ResultSet rs;
+ private BaseConnection conn = null;
+ private Field field = null;
+ private BaseResultSet rs;
private int idx = 0;
private String rawString = null;
* @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.PGConnection conn, int idx, Field field, ResultSet rs )
+ public Array(BaseConnection conn, int idx, Field field, BaseResultSet rs )
throws SQLException
{
this.conn = conn;
this.field = field;
this.rs = rs;
this.idx = idx;
- this.rawString = ((AbstractJdbc2ResultSet)rs).getFixedString(idx);
+ this.rawString = rs.getFixedString(idx);
}
public Object getArray() throws SQLException
default:
throw org.postgresql.Driver.notImplemented();
}
- java.sql.Statement stat = ((AbstractJdbc2Connection)conn).createStatement();
- return ((AbstractJdbc2Statement)stat).createResultSet(fields, rows, "OK", 1, 0, false);
+ BaseStatement stat = (BaseStatement) conn.createStatement();
+ return (ResultSet) stat.createResultSet(fields, rows, "OK", 1, 0, false);
}
public String toString()
import java.sql.*;
+import java.util.Vector;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
public class Jdbc2CallableStatement extends org.postgresql.jdbc2.AbstractJdbc2Statement implements java.sql.CallableStatement
{
super(connection, sql);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.sql.*;
import java.util.Vector;
import java.util.Hashtable;
-import org.postgresql.Field;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Connection.java,v 1.6 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Connection.java,v 1.7 2003/03/07 18:39:45 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
import java.sql.*;
+import java.util.Vector;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
public class Jdbc2PreparedStatement extends org.postgresql.jdbc2.AbstractJdbc2Statement implements java.sql.PreparedStatement
{
super(connection, sql);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.sql.*;
import java.util.Vector;
-import org.postgresql.Field;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.7 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.8 2003/03/07 18:39:45 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(Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public Jdbc2ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super(statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
- public java.sql.ResultSetMetaData getMetaData() throws SQLException
+ public ResultSetMetaData getMetaData() throws SQLException
{
return new Jdbc2ResultSetMetaData(rows, fields);
}
package org.postgresql.jdbc2;
+import java.util.Vector;
+import org.postgresql.core.Field;
+
public class Jdbc2ResultSetMetaData extends AbstractJdbc2ResultSetMetaData implements java.sql.ResultSetMetaData
{
- public Jdbc2ResultSetMetaData(java.util.Vector rows, org.postgresql.Field[] fields)
+ public Jdbc2ResultSetMetaData(Vector rows, Field[] fields)
{
super(rows, fields);
}
import java.sql.*;
+import java.util.Vector;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.4 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.5 2003/03/07 18:39:45 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
super(c);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.sql.*;
import java.util.Vector;
+import org.postgresql.core.BaseStatement;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.3 2003/02/04 09:20:10 barry Exp $
+
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.4 2003/03/07 18:39:45 barry Exp $
* This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2ResultSet which provides the jdbc2
* methods. The real Statement class (for jdbc3) is org.postgresql.jdbc3.Jdbc3ResultSet
public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
{
- public AbstractJdbc3ResultSet(Statement statement, org.postgresql.Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public AbstractJdbc3ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super (statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.sql.*;
+import java.util.Vector;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
public class Jdbc3CallableStatement extends org.postgresql.jdbc3.AbstractJdbc3Statement implements java.sql.CallableStatement
{
super(connection, sql);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc3ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.sql.*;
import java.util.Vector;
import java.util.Hashtable;
-import org.postgresql.Field;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Connection.java,v 1.3 2003/02/04 09:20:10 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Connection.java,v 1.4 2003/03/07 18:39:45 barry Exp $
* This class implements the java.sql.Connection interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Connection or one of it's parents
import java.sql.*;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
public class Jdbc3PreparedStatement extends org.postgresql.jdbc3.AbstractJdbc3Statement implements java.sql.PreparedStatement
{
super(connection, sql);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc3ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
import java.sql.*;
import java.util.Vector;
-import org.postgresql.Field;
+import org.postgresql.core.Field;
+import org.postgresql.core.BaseStatement;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.4 2003/02/04 09:20:11 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.5 2003/03/07 18:39:45 barry Exp $
* This class implements the java.sql.ResultSet interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents
public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet implements java.sql.ResultSet
{
- public Jdbc3ResultSet(Statement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public Jdbc3ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
{
super(statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
package org.postgresql.jdbc3;
+import org.postgresql.core.Field;
+
public class Jdbc3ResultSetMetaData extends org.postgresql.jdbc2.AbstractJdbc2ResultSetMetaData implements java.sql.ResultSetMetaData
{
- public Jdbc3ResultSetMetaData(java.util.Vector rows, org.postgresql.Field[] fields)
+ public Jdbc3ResultSetMetaData(java.util.Vector rows, Field[] fields)
{
super(rows, fields);
}
import java.sql.*;
+import java.util.Vector;
+import org.postgresql.core.BaseResultSet;
+import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.3 2003/02/04 09:20:11 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.4 2003/03/07 18:39:45 barry Exp $
* This class implements the java.sql.Statement interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Statement or one of it's parents
super(c);
}
- public java.sql.ResultSet createResultSet (org.postgresql.Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
{
return new Jdbc3ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
}
+/*-------------------------------------------------------------------------
+ *
+ * BlobInputStream.java
+ * This is an implementation of an InputStream from a large object.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/largeobject/Attic/BlobInputStream.java,v 1.5 2003/03/07 18:39:45 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.largeobject;
import java.io.InputStream;
import java.io.IOException;
import java.sql.SQLException;
-/*
- * This is an initial implementation of an InputStream from a large object.
- * For now, the bare minimum is implemented. Later (after 7.1) we will overide
- * the other read methods to optimise them.
- */
public class BlobInputStream extends InputStream
{
/*
+/*-------------------------------------------------------------------------
+ *
+ * BlobOutputStream.java
+ * This implements a basic output stream that writes to a LargeObject
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/largeobject/Attic/BlobOutputStream.java,v 1.6 2003/03/07 18:39:45 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.largeobject;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.SQLException;
-/*
- * This implements a basic output stream that writes to a LargeObject
- */
public class BlobOutputStream extends OutputStream
{
/*
+/*-------------------------------------------------------------------------
+ *
+ * LargeObject.java
+ * This class implements the large object interface to org.postgresql.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/largeobject/Attic/LargeObject.java,v 1.10 2003/03/07 18:39:45 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.largeobject;
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-
-import org.postgresql.fastpath.*;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.sql.SQLException;
+import org.postgresql.fastpath.Fastpath;
+import org.postgresql.fastpath.FastpathArg;
/*
- * This class implements the large object interface to org.postgresql.
- *
- * <p>It provides the basic methods required to run the interface, plus
+ * This class provides the basic methods required to run the interface, plus
* a pair of methods that provide InputStream and OutputStream classes
* for this object.
*
* to a Large Object, or how to create one.
*
* @see org.postgresql.largeobject.LargeObjectManager
- * @see org.postgresql.ResultSet#getAsciiStream
- * @see org.postgresql.ResultSet#getBinaryStream
- * @see org.postgresql.ResultSet#getUnicodeStream
- * @see org.postgresql.PreparedStatement#setAsciiStream
- * @see org.postgresql.PreparedStatement#setBinaryStream
- * @see org.postgresql.PreparedStatement#setUnicodeStream
* @see java.sql.ResultSet#getAsciiStream
* @see java.sql.ResultSet#getBinaryStream
* @see java.sql.ResultSet#getUnicodeStream
+/*-------------------------------------------------------------------------
+ *
+ * LargeObjectManager.java
+ * This class implements the large object interface to org.postgresql.
+ *
+ * It provides methods that allow client code to create, open and delete
+ * large objects from the database. When opening an object, an instance of
+ * org.postgresql.largeobject.LargeObject is returned, and its methods
+ * then allow access to the object.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/largeobject/Attic/LargeObjectManager.java,v 1.10 2003/03/07 18:39:45 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.largeobject;
-import org.postgresql.Driver;
-import java.io.*;
-import java.lang.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-import org.postgresql.fastpath.*;
-import org.postgresql.util.*;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import org.postgresql.Driver;
+import org.postgresql.core.BaseConnection;
+import org.postgresql.fastpath.Fastpath;
+import org.postgresql.fastpath.FastpathArg;
+import org.postgresql.util.PSQLException;
/*
* This class implements the large object interface to org.postgresql.
*
* ... code that opens a connection ...
*
- * lobj = ((org.postgresql.Connection)myconn).getLargeObjectAPI();
+ * lobj = ((org.postgresql.PGConnection)myconn).getLargeObjectAPI();
* </pre>
*
* <p>Normally, client code would use the getAsciiStream, getBinaryStream,
* <p>Refer to org.postgresql.largeobject.LargeObject on how to manipulate the
* contents of a Large Object.
*
- * @see org.postgresql.largeobject.LargeObject
- * @see org.postgresql.ResultSet#getAsciiStream
- * @see org.postgresql.ResultSet#getBinaryStream
- * @see org.postgresql.ResultSet#getUnicodeStream
- * @see org.postgresql.PreparedStatement#setAsciiStream
- * @see org.postgresql.PreparedStatement#setBinaryStream
- * @see org.postgresql.PreparedStatement#setUnicodeStream
* @see java.sql.ResultSet#getAsciiStream
* @see java.sql.ResultSet#getBinaryStream
* @see java.sql.ResultSet#getUnicodeStream
* org.postgresql.Connection class keeps track of the various extension API's
* and it's advised you use those to gain access, and not going direct.
*/
- public LargeObjectManager(Connection conn) throws SQLException
+ public LargeObjectManager(BaseConnection conn) throws SQLException
{
// We need Fastpath to do anything
- this.fp = ((org.postgresql.PGConnection)conn).getFastpathAPI();
+ this.fp = conn.getFastpathAPI();
// Now get the function oid's for the api
//
// Fastpath/LargeObject
suite.addTestSuite(BlobTest.class);
- suite.addTestSuite(SerializeTest.class);
suite.addTestSuite(UpdateableResultTest.class );
suite.addTestSuite(CallableStmtTest.class );
+++ /dev/null
-package org.postgresql.test.jdbc2;
-
-import java.io.Serializable;
-
-public class SerializeObject implements Serializable {
-
- public int intcol;
- public double doublecol;
- public String stringcol;
-
-}
+++ /dev/null
-package org.postgresql.test.jdbc2;
-
-import org.postgresql.test.TestUtil;
-import junit.framework.TestCase;
-import java.sql.*;
-import org.postgresql.util.Serialize;
-
-public class SerializeTest extends TestCase {
-
- private Connection conn;
- private SerializeObject serobj;
- private Serialize ser;
-
- public SerializeTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- conn = TestUtil.openDB();
- serobj = new SerializeObject();
- serobj.intcol = 1;
- serobj.doublecol = 3.4;
- serobj.stringcol = "Hello";
- TestUtil.dropTable(conn,Serialize.toPostgreSQL(conn,serobj.getClass().getName()));
- Serialize.create(conn, serobj);
- Serialize.create(conn, serobj);
- ser = new Serialize(conn,serobj);
- }
-
- protected void tearDown() throws Exception {
- TestUtil.dropTable(conn,Serialize.toPostgreSQL(conn,serobj.getClass().getName()));
- }
-
- public void testCreateSerialize() {
- try {
- long oid = ser.storeObject(serobj);
- SerializeObject serobj2 = (SerializeObject)ser.fetch(oid);
- assertNotNull(serobj2);
- assertEquals(serobj.intcol,serobj2.intcol);
- assertTrue(Math.abs(serobj.doublecol-serobj2.doublecol) < 0.0001);
- assertTrue(serobj.stringcol.equals(serobj2.stringcol));
- } catch (SQLException sqle) {
- fail(sqle.getMessage());
- }
- }
-
-}
* tests.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public abstract class BaseDataSourceTest extends TestCase
{
try
{
con = getDataSourceConnection();
- ((PGConnection)con).getEncoding().name();
+ ((PGConnection)con).getNotifications();
con.close();
}
catch (Exception e)
+/*-------------------------------------------------------------------------
+ *
+ * MD5Digest.java
+ * MD5-based utility function to obfuscate passwords before network
+ * transmission
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/MD5Digest.java,v 1.5 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
/*
- * MD5-based utility function to obfuscate passwords before network transmission
- *
* @author Jeremy Wohl
- * $Id: MD5Digest.java,v 1.4 2002/08/16 19:35:46 davec Exp $
*/
import java.security.*;
+/*-------------------------------------------------------------------------
+ *
+ * MessageTranslator.java
+ * A singleton class to translate JDBC driver messages in SQLException's.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/MessageTranslator.java,v 1.4 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
-import java.util.*;
-import java.text.*;
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
-/*
- * A singleton class to translate JDBC driver messages in SQLException's.
- */
public class MessageTranslator
{
+/*-------------------------------------------------------------------------
+ *
+ * PGbytea.java
+ * Converts to and from the postgresql bytea datatype used by the backend.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PGbytea.java,v 1.7 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
import java.sql.*;
-/*
- * Converts to and from the postgresql bytea datatype used by the backend.
- *
- * $Id: PGbytea.java,v 1.6 2002/09/06 21:23:06 momjian Exp $
- */
-
public class PGbytea
{
+/*-------------------------------------------------------------------------
+ *
+ * PGmoney.java
+ * This implements a class that handles the PostgreSQL money and cash types
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PGmoney.java,v 1.5 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
-import java.io.*;
-import java.sql.*;
-/*
- * This implements a class that handles the PostgreSQL money and cash types
- */
+import java.io.Serializable;
+import java.sql.SQLException;
+
public class PGmoney extends PGobject implements Serializable, Cloneable
{
/*
val = value;
}
- /*
- * This is called mainly from the other geometric types, when a
- * point is imbeded within their definition.
- *
- * @param value Definition of this point in PostgreSQL's syntax
- */
public PGmoney(String value) throws SQLException
{
this();
setType("money");
}
- /*
- * @param s Definition of this point in PostgreSQL's syntax
- * @exception SQLException on conversion failure
- */
public void setValue(String s) throws SQLException
{
try
}
}
- /*
- * @param obj Object to compare with
- * @return true if the two boxes are identical
- */
public boolean equals(Object obj)
{
if (obj instanceof PGmoney)
return new PGmoney(val);
}
- /*
- * @return the PGpoint in the syntax expected by org.postgresql
- */
public String getValue()
{
if (val < 0)
+/*-------------------------------------------------------------------------
+ *
+ * PGobject.java
+ * PGobject is a class used to describe unknown types
+ * An unknown type is any type that is unknown by JDBC Standards
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PGobject.java,v 1.4 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
-import java.io.*;
-import java.lang.*;
-import java.sql.*;
-import java.util.*;
+import java.io.Serializable;
+import java.sql.SQLException;
-/*
- * org.postgresql.PG_Object is a class used to describe unknown types
- * An unknown type is any type that is unknown by JDBC Standards
- *
- * <p>As of PostgreSQL 6.3, this allows user code to add their own
- * handlers via a call to org.postgresql.Connection. These handlers
- * must extend this class.
- */
public class PGobject implements Serializable, Cloneable
{
protected String type;
+/*-------------------------------------------------------------------------
+ *
+ * PGtokenizer.java
+ * This class is used to tokenize the text output of org.postgres.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PGtokenizer.java,v 1.6 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
import java.sql.*;
import java.util.*;
/*
- * This class is used to tokenize the text output of org.postgres.
- *
- * <p>It's mainly used by the geometric classes, but is useful in parsing any
+ * It's mainly used by the geometric classes, but is useful in parsing any
* output from custom data types output from org.postgresql.
*
* @see org.postgresql.geometric.PGbox
+/*-------------------------------------------------------------------------
+ *
+ * PSQLException.java
+ * This class extends SQLException, and provides our internationalisation
+ * handling
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/PSQLException.java,v 1.9 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
-import java.io.*;
-import java.sql.*;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.sql.SQLException;
-/*
- * This class extends SQLException, and provides our internationalisation handling
- */
public class PSQLException extends SQLException
{
private String message;
+++ /dev/null
-package org.postgresql.util;
-
-import org.postgresql.Driver;
-import java.io.*;
-import java.lang.*;
-import java.lang.reflect.*;
-import java.net.*;
-import java.util.*;
-import java.sql.*;
-
-/*
- * This class uses PostgreSQL's object oriented features to store Java Objects.<p>
- *
- * It does this by mapping a Java Class name to a table in the database. Each
- * entry in this new table then represents a Serialized instance of this
- * class. As each entry has an OID (Object IDentifier), this OID can be
- * included in another table.<p>
- *
- * Serialize depends on a feature of Postgres that allows
- * a table to be used as a data type. However, Postgres support of
- * this feature is incomplete. The basic ability to create and use
- * a table as a field type in another table exists:<br>
- * CREATE TABLE myclass( var1 TEXT, var2 INTEGER );<br>
- * CREATE TABLE othertable( field1 TEXT, field2 myclass );<br>
- * INSERT INTO myclass VALUES ('Hello', 1);<br>
- * INSERT INTO othertable VALUES ('World', xxxx::myclass);<br>
- * where xxxx is the OID of a row in myclass<br>
- * This lets othertable reference a myclass instance but
- * the support to actually make any use of the myclass data type
- * is not there. For instance, you cannot compare the myclass field
- * with ANY other data type, not even with other myclass values.
- * Casting to and from the myclass type will also not work.
- * From the limited testing done, only the literal xxxx::myclass
- * syntax appears to work.<p>
- *
- * Queries like:<br>
- * SELECT othertable.field2.var1 FROM othertable;<br>
- * will not work but were suggested in the original Postgres
- * design documents.<p>
- * Because support is incomplete for table data types, tables
- * such as othertable that hold java instances should also
- * hold an oid field for the same java instance:<br>
- * CREATE othertable( field1 TEXT, field2 myclass, myclassOID oid);<br>
- * This oid-type field would be set with setInt() immediately after
- * setting the myclass-type field with setObject(). The order of these
- * set calls matters since the oid is not available until after
- * setting the object when inserting a new object. With the oid,
- * queries and comparisons etc. can be done to locate a myclass.
- * Read below about how to include an int oid field in your java class
- * that is updated by setObject() when it is inserted.<p>
- *
- * The myclass table represents a java class. This table is created
- * by Serialize.create(). Serialize.create() must be called before
- * the first use of the myclass java class in PreparedStatement.setObject()
- * calls. This is a one-time initialization step.<p>
- *
- * There are a number of limitations placed on the java class to be
- * used by Serialize:
- * <ul>
- * <li>The class name must be less than 64 chars long and must be all lowercase.
- * This is due to limitations in Postgres about the size of table names.
- * The name must be all lowercase since table names in Postgres are
- * case insensitive and the relname is stored in lowercase. Unless some
- * additional table were to be maintained about the names of java classes,
- * there is no way to know how to go from a Postgres table name back to
- * a java class name with knowledge of case of the letters in the name.
- * <li>The class name must not contain the underscore '_' character since
- * any dots in a java class name are converted to an underscore in
- * its table name and vice versa going back.
- * <li>The class should only contain java primitive types and String.
- * Support for recursively "serializing" a class is not tested but
- * some code for this does exist and you may wish to take a look at it.
- * <li>Only the public fields of the class will be stored in and fetched from
- * the database. Protected and private fields are ignored.
- * <li>Must have a no-arg constructor so that Class.newInstance() may
- * instantiate the class in fetch().
- * <li>Should implement the Serializable interface. This interface
- * may be used more in future releases or in providing an alternative
- * method of storing the java classes in the database. The Serializable
- * interface allows a class instance to be written out as a binary
- * stream of data and is a standard java feature.
- * <li>The class should contain a field defined as:<br>
- * int oid = 0;<br>
- * This field is actually optional and its use by jdbc2.PreparedStatement.setObject()
- * is as follows:<br>
- * If oid does not exist in the class, the class instance is stored in a new table row
- * everytime setObject() is called on it. If oid field exists and is 0, then the class
- * instance is stored into a new row in the table and that row's oid is set in the class by setObject().
- * If oid field exists and is > 0, then the existing table row for the class instance is
- * updated. The oid field should be thought of as read-only unless you want to set it to 0
- * so that a new instance is created in the database rather than doing an update.<p>
- * </ul>
- *
- * Suggested usage:
- * <ol>
- * <li>Create your javaclass and include an int oid = 0; field.
- * <li>Run Serialize.create( conn, javaclass ) to create the table for javaclass (once).
- * <li>Create mytable in the database with fields like: jclassoid INTEGER, jclass JAVACLASS<br>
- * <li>Use a jdbc2.PreparedStatement to insert, update, or select from mytable.
- * Use setObject(2, jclass), followed by setInt(1, jclass.oid) to setup an insert.
- * <li>Use jclass.oid and jclassoid to do queries since the jclass field cannot be used
- * for anything but fetching the javaclass instance with getObject("jclass").
- * </ol>
- * Finally, Serialize is a work in progress and being a utility class, it is not supported.
- * You are "on your own" if you use it. If you use it and make any enhancements,
- * please consider joining the email lists pgsql-jdbc@postgresql.org and pgsql-patches@postgresql.org
- * and contributing your additions.
- */
-public class Serialize
-{
- // This is the connection that the instance refers to
- protected Connection conn;
-
- // This is the table name
- protected String tableName;
-
- // This is the class name
- protected String className;
-
- // This is the Class for this serialzed object
- protected Class ourClass;
-
- /*
- * This creates an instance that can be used to serialize or deserialize
- * a Java object from a PostgreSQL table.
- */
- public Serialize(Connection conn, String type) throws SQLException
- {
- try
- {
- this.conn = conn;
- if (Driver.logDebug)
- Driver.debug("Serialize: initializing instance for type: " + type);
- tableName = toPostgreSQL(conn,type);
- className = type;
- ourClass = Class.forName(className);
- }
- catch (ClassNotFoundException cnfe)
- {
- if (Driver.logDebug)
- Driver.debug("Serialize: " + className + " java class not found");
- throw new PSQLException("postgresql.serial.noclass", type);
- }
-
- // Second check, the type must be a table
- boolean status = false;
- String sql;
- if (conn.getMetaData().supportsSchemasInTableDefinitions()) {
- sql = "SELECT 1 FROM pg_catalog.pg_type t, pg_catalog.pg_class c WHERE t.typrelid=c.oid AND c.relkind='r' AND t.typname='" + tableName + "' AND pg_table_is_visible(c.oid) ";
- } else {
- sql = "SELECT 1 FROM pg_type t, pg_class c WHERE t.typrelid=c.oid AND c.relkind='r' AND t.typname='"+tableName+"'";
- }
-
- ResultSet rs = conn.createStatement().executeQuery(sql);
- if (rs != null)
- {
- if (rs.next())
- {
- status = true;
- if (Driver.logDebug)
- Driver.debug("Serialize: " + tableName + " table found");
- }
- rs.close();
- }
- // This should never occur, as org.postgresql has it's own internal checks
- if (!status)
- {
- if (Driver.logDebug)
- Driver.debug("Serialize: " + tableName + " table not found");
- throw new PSQLException("postgresql.serial.table", type);
- }
- // Finally cache the fields within the table
- }
-
- /*
- * Constructor when Object is passed in
- */
- public Serialize(Connection c, Object o) throws SQLException
- {
- this(c, o.getClass().getName());
- }
-
- /*
- * Constructor when Class is passed in
- */
- public Serialize(Connection c, Class cls) throws SQLException
- {
- this(c, cls.getName());
- }
-
- /*
- * This fetches an object from a table, given it's OID
- * @param oid The oid of the object
- * @return Object relating to oid
- * @exception SQLException on error
- */
- public Object fetch(long oid) throws SQLException
- {
- try
- {
- if (Driver.logDebug)
- Driver.debug("Serialize.fetch: " + "attempting to instantiate object of type: " + ourClass.getName() );
- Object obj = ourClass.newInstance();
- if (Driver.logDebug)
- Driver.debug("Serialize.fetch: " + "instantiated object of type: " + ourClass.getName() );
-
- // NB: we use java.lang.reflect here to prevent confusion with
- // the org.postgresql.Field
-
- // used getFields to get only public fields. We have no way to set values
- // for other declarations. Maybe look for setFieldName() methods?
- java.lang.reflect.Field f[] = ourClass.getFields();
- boolean hasOID = false;
- int oidFIELD = -1;
-
- StringBuffer sb = new StringBuffer("select");
- char sep = ' ';
- // build a select for the fields. Look for the oid field to use in the where
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- if (n.equals("oid"))
- {
- hasOID = true;
- oidFIELD = i;
- }
- sb.append(sep);
- sb.append(n);
- sep = ',';
- }
- sb.append(" from ");
- sb.append(tableName);
- sb.append(" where oid=");
- sb.append(oid);
-
- if (Driver.logDebug)
- Driver.debug("Serialize.fetch: " + sb.toString());
- ResultSet rs = conn.createStatement().executeQuery(sb.toString());
-
- if (rs != null)
- {
- if (rs.next())
- {
- for (int i = 0;i < f.length;i++)
- {
- if ( !Modifier.isFinal(f[i].getModifiers()) )
- {
- if ( f[i].getType().getName().equals("short") )
- f[i].setShort(obj, rs.getShort(i + 1));
- else if ( f[i].getType().getName().equals("char") )
- f[i].setChar(obj, rs.getString(i + 1).toCharArray()[0]);
- else if ( f[i].getType().getName().equals("byte"))
- f[i].setByte(obj, rs.getByte(i + 1));
- else if ( f[i].getType().getName().equals("boolean") )
- {
- // booleans come out of pgsql as a t or an f
- if ( rs.getString(i + 1).equals("t") )
- f[i].setBoolean(obj, true);
- else
- f[i].setBoolean(obj, false);
- }
- else
- f[i].set(obj, rs.getObject(i + 1));
- }
- }
- }
- rs.close();
- }
- else
- throw new PSQLException("postgresql.unexpected");
-
- return obj;
-
- }
- catch (IllegalAccessException iae)
- {
- throw new SQLException(iae.toString());
- }
- catch (InstantiationException ie)
- {
- throw new SQLException(ie.toString());
- }
- }
-
- /*
- * This stores an object into a table, returning it's OID.<p>
- * This method was deprecated in 7.2 because the value of an OID
- * can be larger than a java signed int.
- * @deprecated Replaced by storeObject() in 7.2
- */
- public int store(Object o) throws SQLException
- {
- return (int) storeObject(o);
- }
-
- /*
- * This stores an object into a table, returning it's OID.<p>
- *
- * If the object has an int called OID, and it is > 0, then
- * that value is used for the OID, and the table will be updated.
- * If the value of OID is 0, then a new row will be created, and the
- * value of OID will be set in the object. This enables an object's
- * value in the database to be updateable.
- *
- * If the object has no int called OID, then the object is stored. However
- * if the object is later retrieved, amended and stored again, it's new
- * state will be appended to the table, and will not overwrite the old
- * entries.
- *
- * @param o Object to store (must implement Serializable)
- * @return oid of stored object
- * @exception SQLException on error
- * @since 7.2
- */
- public long storeObject(Object o) throws SQLException
- {
- try
- {
- // NB: we use java.lang.reflect here to prevent confusion with
- // the org.postgresql.Field
-
- // don't save private fields since we would not be able to fetch them
- java.lang.reflect.Field f[] = ourClass.getFields();
-
- boolean hasOID = false;
- int oidFIELD = -1;
- boolean update = false;
-
- // Find out if we have an oid value
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- if (n.equals("oid"))
- {
- hasOID = true;
- oidFIELD = i;
- // Do update if oid != 0
- update = f[i].getInt(o) > 0;
- }
- }
-
- StringBuffer sb = new StringBuffer(update ? "update " + tableName + " set" : "insert into " + tableName + " ");
- char sep = update ? ' ' : '(';
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- // oid cannot be updated!
- if ( n.equals("oid") )
- continue;
- sb.append(sep);
- sep = ',';
- sb.append(n);
- if (update)
- {
- sb.append('=');
- // handle unset values
- if (f[i].get(o) == null)
- sb.append("null");
- else if (
- f[i].getType().getName().equals("java.lang.String")
- || f[i].getType().getName().equals("char") )
- {
- sb.append('\'');
- // don't allow single qoutes or newlines in the string
- sb.append(fixString(f[i].get(o).toString()));
- sb.append('\'');
- }
- else
- sb.append(f[i].get(o).toString());
- }
- }
-
- if (update)
- sb.append(" where oid = " + f[oidFIELD].getInt(o) );
-
- if (!update)
- {
- sb.append(") values ");
- sep = '(';
- for (int i = 0;i < f.length;i++)
- {
- String n = f[i].getName();
- // oid cannot be set!
- if ( n.equals("oid") )
- continue;
- sb.append(sep);
- sep = ',';
- // handle unset values
- if (f[i].get(o) == null)
- sb.append("null");
- else if (
- f[i].getType().getName().equals("java.lang.String")
- || f[i].getType().getName().equals("char"))
- {
- sb.append('\'');
- // don't allow single quotes or newlines in the string
- sb.append(fixString(f[i].get(o).toString()));
- sb.append('\'');
- }
- else
- sb.append(f[i].get(o).toString());
- }
- sb.append(')');
- }
-
- if (Driver.logDebug)
- Driver.debug("Serialize.store: " + sb.toString() );
- ResultSet rs = ((org.postgresql.jdbc1.AbstractJdbc1Connection)conn).execSQL(sb.toString());
-
- // fetch the OID for returning
- if (update)
- {
- // object has oid already, so return it
- if (rs != null)
- rs.close();
- return f[oidFIELD].getInt(o);
- }
- else
- {
- // new record inserted has new oid; rs should be not null
- long newOID = ((org.postgresql.jdbc1.AbstractJdbc1ResultSet)rs).getLastOID();
- rs.close();
- // update the java object's oid field if it has the oid field
- if (hasOID)
- f[oidFIELD].setLong(o, newOID);
- // new object stored, return newly inserted oid
- return newOID;
- }
-
- }
- catch (IllegalAccessException iae)
- {
- throw new SQLException(iae.toString());
- }
- }
-
- /*
- * Escape literal single quote and backslashes embedded in strings/chars.
- * Otherwise, postgres will bomb on the single quote and remove the
- * the backslashes.
- */
- private String fixString(String s)
- {
- int idx = -1;
-
- // handle null
- if (s == null)
- return "";
-
- // if the string has single quotes in it escape them as ''
- if ((idx = s.indexOf("'")) > -1)
- {
- StringBuffer buf = new StringBuffer();
- StringTokenizer tok = new StringTokenizer(s, "'");
- // handle quote as 1St charater
- if (idx > 0)
- buf.append(tok.nextToken());
-
- while (tok.hasMoreTokens())
- buf.append("''").append(tok.nextToken());
-
- s = buf.toString();
- }
-
- // if the string has backslashes in it escape them them as \\
- if ((idx = s.indexOf("\\")) > -1)
- {
- StringBuffer buf = new StringBuffer();
- StringTokenizer tok = new StringTokenizer(s, "\\");
- if (idx > 0)
- buf.append(tok.nextToken());
-
- while (tok.hasMoreTokens())
- buf.append("\\\\").append(tok.nextToken());
-
- s = buf.toString();
- }
-
- return s;
- }
-
- /*
- * This method is not used by the driver, but it creates a table, given
- * a Serializable Java Object. It should be used before serializing any
- * objects.
- * @param c Connection to database
- * @param o Object to base table on
- * @exception SQLException on error
- */
- public static void create(Connection con, Object o) throws SQLException
- {
- create(con, o.getClass());
- }
-
- /*
- * This method is not used by the driver, but it creates a table, given
- * a Serializable Java Object. It should be used before serializing any
- * objects.
- * @param c Connection to database
- * @param o Class to base table on
- * @exception SQLException on error
- */
- public static void create(Connection conn, Class c) throws SQLException
- {
- if (c.isInterface())
- throw new PSQLException("postgresql.serial.interface");
-
- // See if the table exists
- String tableName = toPostgreSQL(conn,c.getName());
-
- String sql;
- if (conn.getMetaData().supportsSchemasInTableDefinitions()) {
- sql = "SELECT 1 FROM pg_catalog.pg_class WHERE relkind='r' AND relname='" + tableName + "' AND pg_table_is_visible(oid) ";
- } else {
- sql = "SELECT 1 FROM pg_class WHERE relkind='r' AND relname='"+tableName+"'";
- }
-
- ResultSet rs = conn.createStatement().executeQuery(sql);
- if ( rs.next() )
- {
- if (Driver.logDebug)
- Driver.debug("Serialize.create: table " + tableName + " exists, skipping");
- rs.close();
- return ;
- }
-
- // else table not found, so create it
- if (Driver.logDebug)
- Driver.debug("Serialize.create: table " + tableName + " not found, creating" );
- // No entries returned, so the table doesn't exist
-
- StringBuffer sb = new StringBuffer("create table ");
- sb.append(tableName);
- char sep = '(';
-
- // java.lang.reflect.Field[] fields = c.getDeclaredFields();
- // Only store public fields, another limitation!
- java.lang.reflect.Field[] fields = c.getFields();
- for (int i = 0;i < fields.length;i++)
- {
- Class type = fields[i].getType();
- // oid is a special field
- if (!fields[i].getName().equals("oid"))
- {
- sb.append(sep);
- sb.append(fields[i].getName());
- sb.append(' ');
- sep = ',';
-
- if (type.isArray())
- {
- // array handling
- }
- else
- {
- // convert the java type to org.postgresql, recursing if a class
- // is found
- String n = type.getName();
- int j = 0;
- for (;j < tp.length && !tp[j][0].equals(n);j++)
- ;
- if (j < tp.length)
- sb.append(tp[j][1]);
- else
- {
- create(conn, type);
- sb.append(toPostgreSQL(conn,n));
- }
- }
- }
- }
- sb.append(")");
-
- // Now create the table
- if (Driver.logDebug)
- Driver.debug("Serialize.create: " + sb );
- conn.createStatement().executeUpdate(sb.toString());
- }
-
- // This is used to translate between Java primitives and PostgreSQL types.
- private static final String tp[][] = {
- // {"boolean", "int1"},
- {"boolean", "bool"},
- {"double", "float8"},
- {"float", "float4"},
- {"int", "int4"},
- // {"long", "int4"},
- {"long", "int8"},
- {"short", "int2"},
- {"java.lang.String", "text"},
- {"java.lang.Integer", "int4"},
- {"java.lang.Float", "float4"},
- {"java.lang.Double", "float8"},
- {"java.lang.Short", "int2"},
- {"char", "char"},
- {"byte", "int2"}
- };
-
- /**
- * This converts a Java Class name to a org.postgresql table, by replacing . with
- * _<p>
- *
- * Because of this, a Class name may not have _ in the name.<p>
- * Another limitation, is that the entire class name (including packages)
- * cannot be longer than the maximum table name length.
- *
- * @param con The database connection
- * @param name Class name
- * @return PostgreSQL table name
- * @exception SQLException on error
- * @since 7.3
- */
- public static String toPostgreSQL(Connection con, String name) throws SQLException
- {
- DatabaseMetaData dbmd = con.getMetaData();
- int maxNameLength = dbmd.getMaxTableNameLength();
- return toPostgreSQL(maxNameLength,name);
- }
-
- /**
- * Convert a Java Class Name to an org.postgresql table name, by replacing .
- * with _ <p>
- *
- * @deprecated Replaced by toPostgresql(connection, name) in 7.3
- */
- public static String toPostgreSQL(String name) throws SQLException {
- return toPostgreSQL(31,name);
- }
-
- private static String toPostgreSQL(int maxNameLength, String name) throws SQLException {
-
- name = name.toLowerCase();
-
- if (name.indexOf("_") > -1)
- throw new PSQLException("postgresql.serial.underscore");
-
- // Postgres table names can only be so many characters long.
- // If the full class name with package is too long
- // then just use the class name. If the class name is
- // too long throw an exception.
- //
- if ( name.length() > maxNameLength )
- {
- name = name.substring(name.lastIndexOf(".") + 1);
- if ( name.length() > maxNameLength )
- throw new PSQLException("postgresql.serial.namelength", name, new Integer(name.length()));
- }
- return name.replace('.', '_');
- }
-
-
- /*
- * This converts a org.postgresql table to a Java Class name, by replacing _ with
- * .<p>
- *
- * @param name PostgreSQL table name
- * @return Class name
- * @exception SQLException on error
- */
- public static String toClassName(String name) throws SQLException
- {
- name = name.toLowerCase();
- return name.replace('_', '.');
- }
-
-}
+/*-------------------------------------------------------------------------
+ *
+ * UnixCrypt.java
+ * Contains static methods to encrypt and compare
+ * passwords with Unix encrypted passwords.
+ *
+ * Copyright (c) 2003, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/Attic/UnixCrypt.java,v 1.4 2003/03/07 18:39:46 barry Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
package org.postgresql.util;
/*
- * This class provides us with the ability to encrypt passwords when sent
- * over the network stream
- *
- * <P>Contains static methods to encrypt and compare
- * passwords with Unix encrypted passwords.</P>
- *
* <P>See <A HREF="http://www.zeh.com/local/jfd/crypt.html">
* John Dumas's Java Crypt page</A> for the original source.</P>
*