Commit 298682d9 authored by Bruce Momjian's avatar Bruce Momjian

As the email posted to the announce and interfaces list, attached is a tar

file containing the latest version of the JDBC driver, allowing it to be
compiled and used under JDK 1.2 and later.

NB: None (well almost none) of the new methods actually do anything. This
release only handles getting it to compile and run. Now this is done, I'll
start working on implementing the new stuff.

Now this tar file replaces everything under src/interfaces/jdbc. I had to
do it this way, rather than diffs, because most of the classes under the
postgresql subdirectory have moved to a new directory under that one, to
enable the support of the two JDBC standards.

Here's a list of files in the tar file. Any file not listed here (in the
postgresql directory) will have to be deleted, otherwise it could cause
the driver to fail:

Peter Mount
parent 4a6285ee
Tue Dec 29 15:45:00 GMT 1998
- Refreshed the README (which was way out of date)
Tue Dec 29 15:45:00 GMT 1998
- Finished adding the additional methods into the JDBC2 driver.
- Had to add some explicit package references for the JDK1.2 Javac to
cope with the driver
Tue Dec 29 12:40:00 GMT 1998
- Fixed package imports and some references to java.sql.ResultSet in
various files. Compiled and tested the JDBC1 driver.
Mon Dec 28 19:01:37 GMT 1998
- created a new package postgresql.jdbc2 which will contain the JDBC 2
specific classes. A similar new package (postgresql.jdbc1) has been
created to hold the JDBC 1 specific classes.
- modified Makefile to allow compilation of the JDBC 1 & 2 drivers,
with the possibility of building a dual-spec driver.
- changed the version number in postgresql.Driver to 6.5
- modified postgresql.Driver class to initiate the correct driver when
used under a 1.1 or 1.2+ JVM.
- postgresql.Connection and postgresql.jdbc2.Connection now extends the
new class postgresql.ConnectionStub, which allows us to dynamically
open the JDBC1 or JDBC2 drivers.
- enabled compilation of the driver under Win32 when using the Make
from the CygWin package (Cygnus B20.1 was used).
- To make future development easier (now we have 2 specifications to
work with) the following classes have moved from the postgresql to
the postgresql.jdbc1 package:
CallableStatement Connection
DatabaseMetaData PreparedStatement
ResultSet ResultSetMetaData
Statement
Some of these classes have common code that is not dependent on
either JDBC specification. These common code are still in the
postgresql package.
Ie: postgresql.jdbc1.Connection extends postgresql.Connection
and postgresql.jdbc2.Connection extends postgresql.Connection
Web Oct 7 22:00:00 BST 1998 Web Oct 7 22:00:00 BST 1998
- removed syncronised from Connection.ExecSQL(). See next entry. - removed syncronised from Connection.ExecSQL(). See next entry.
- added new syncronised locking in the Connection.ExecSQL() and - added new syncronised locking in the Connection.ExecSQL() and
...@@ -82,4 +121,4 @@ Sun Aug 30 11:33:06 BST 1998 ...@@ -82,4 +121,4 @@ Sun Aug 30 11:33:06 BST 1998
and getSchemaName(). and getSchemaName().
- Created new class postgresql.util.PGmoney to map the money type - Created new class postgresql.util.PGmoney to map the money type
- Created new class postgresql.geometric.PGline to map the line type - Created new class postgresql.geometric.PGline to map the line type
\ No newline at end of file
This short document is provided to help programmers through the internals of
the PostgreSQL JDBC driver.
Makefile
--------
All compilation must be done by using Make. This is because there are two
versions of the driver, one for JDBC1 (for JDK 1.1.x) and the other for JDBC2
(for JDK 1.2 or later). The makefile determines which version to compile by
using a helper class makeVersion. This class is only used by make, and is not
stored in the Jar file.
Note: It is not sufficient to simply call javac on postgresql/Driver.java as
some classes are dynamically loaded, so javac will not compile them.
postgresql.jar
--------------
This jar file is produced by make, and contains the driver for your JDK
platform.
Note: It is possible to compile the driver under say JDK1.1.7, then under
JDK 1.2. Because make doesn't remove the old classes before compiling,
jar will simply package both sets together. When the driver is loaded,
the postgresql.Driver class will sort out which set of classes to use.
Importing packages
------------------
In user code, you may have to import one or more packages, if and only if you
are using the non jdbc extensions (like FastPath, or LargeObject).
DO NOT import the postgresql, postgresql.jdbc1 or postgresql.jdbc2 packages!
Internally, some classes will import the packages when there is a link between
them and the other packages. However, the above rule still applies. It's there
because Javac becomes confused between the different places that similar class
names are present.
However, there are places where they need to refer to classes in the postgresql
package. In this case, import the individual classes, and not the entire
package.
ie: import postgresql.Field
NOT import postgresql.*
Package Layout
--------------
The driver is split into several packages:
postgresql core classes, common to both JDBC 1 & 2
postgresql.jdbc1 classes used only in implementing JDBC 1
postgresql.jdbc2 classes used only in implementing JDBC 2
postgresql.fastpath FastPath to backend functions
postgresql.geometric 2D Geometric types mapped to Java Objects
postgresql.largeobject Low level Large Object access
postgresql.util Utility classes
Package postgresql
------------------
This package holds the core classes.
Driver registers the driver when it's loaded, and determines which
Connection class (in jdbc1 or jdbc2 packages) to use when
connecting to a database.
Field Used internally to represent a Field
PG_Stream Used internally to manage the network stream.
These classes contains common code that is not dependent to the
two JDBC specifications.
Connection Common code used in Connections, mainly Network Protocol stuff.
ResultSet Common code used in ResultSet's
Package postgresql.fastpath
---------------------------
Fastpath Handles executing a function on the PostgreSQL Backend
FastpathArg Defines an argument for a function call
Package postgresql.geometric
----------------------------
PGbox Maps to postgresql type box
PGcircle Maps to postgresql type circle
PGline Maps to postgresql type line
PGlseg Maps to postgresql type lseg
PGpath Maps to postgresql type path
PGpoint Maps to postgresql type point
PGpolygon Maps to postgresql type polygon
Package postgresql.jdbc1
------------------------
The classes in this package handle the JDBC 1 Specification, for JDK 1.1.x
All interfaces in the java.sql package are present here.
Package postgresql.jdbc2
------------------------
The classes in this package handle the JDBC 2 Specification, for JDK 1.2
All interfaces in the java.sql, and javax.sql packages are present here.
Package postgresql.largeobject
------------------------------
LargeObject Represents an open LargeObject
LargeObjectManager Handles the opening and deleting of LargeObjects
Package postgresql.util
-----------------------
PGmoney Maps to postgresql type money
PGobject Used to represent postgresql types that have no Java equivalent
PGtokenizer Helper class for the geometric types
Serialize Used to serialise Java objects into tabes, rather than Blobs
UnixCrypt Used to handle crypt authentication
...@@ -4,12 +4,10 @@ ...@@ -4,12 +4,10 @@
# Makefile for Java JDBC interface # Makefile for Java JDBC interface
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.10 1998/10/08 00:38:18 momjian Exp $ # $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.11 1999/01/17 04:51:49 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# These are commented out, but would be included in the postgresql source
FIND = find FIND = find
JAR = jar JAR = jar
JAVA = java JAVA = java
...@@ -24,7 +22,10 @@ RM = rm -f ...@@ -24,7 +22,10 @@ RM = rm -f
.SUFFIXES: .class .java .SUFFIXES: .class .java
.PHONY: all clean doc examples .PHONY: all clean doc examples
all: postgresql.jar # In 6.5, the all rule builds the makeVersion class which then calls make using
# the jdbc1 or jdbc2 rules
all: makeVersion.class
make $$($(JAVA) makeVersion)
@echo ------------------------------------------------------------ @echo ------------------------------------------------------------
@echo The JDBC driver has now been built. To make it available to @echo The JDBC driver has now been built. To make it available to
@echo other applications, copy the postgresql.jar file to a public @echo other applications, copy the postgresql.jar file to a public
...@@ -37,7 +38,9 @@ all: postgresql.jar ...@@ -37,7 +38,9 @@ all: postgresql.jar
@echo "under unix for HotJava), and add a line containing" @echo "under unix for HotJava), and add a line containing"
@echo jdbc.drivers=postgresql.Driver @echo jdbc.drivers=postgresql.Driver
@echo @echo
@echo More details are in the README file. @echo More details are in the README file and in the main postgresql
@echo documentation.
@echo
@echo ------------------------------------------------------------ @echo ------------------------------------------------------------
@echo To build the examples, type: @echo To build the examples, type:
@echo " make examples" @echo " make examples"
...@@ -56,39 +59,83 @@ doc: ...@@ -56,39 +59,83 @@ doc:
# These classes form the driver. These, and only these are placed into # These classes form the driver. These, and only these are placed into
# the jar file. # the jar file.
OBJS= postgresql/CallableStatement.class \ OBJ_COMMON= postgresql/Connection.class \
postgresql/Connection.class \ postgresql/Driver.class \
postgresql/DatabaseMetaData.class \ postgresql/Field.class \
postgresql/Driver.class \ postgresql/PG_Stream.class \
postgresql/Field.class \ postgresql/ResultSet.class \
postgresql/PG_Stream.class \ postgresql/fastpath/Fastpath.class \
postgresql/PreparedStatement.class \ postgresql/fastpath/FastpathArg.class \
postgresql/ResultSet.class \ postgresql/geometric/PGbox.class \
postgresql/ResultSetMetaData.class \ postgresql/geometric/PGcircle.class \
postgresql/Statement.class \ postgresql/geometric/PGline.class \
postgresql/fastpath/Fastpath.class \ postgresql/geometric/PGlseg.class \
postgresql/fastpath/FastpathArg.class \ postgresql/geometric/PGpath.class \
postgresql/geometric/PGbox.class \ postgresql/geometric/PGpoint.class \
postgresql/geometric/PGcircle.class \ postgresql/geometric/PGpolygon.class \
postgresql/geometric/PGline.class \ postgresql/largeobject/LargeObject.class \
postgresql/geometric/PGlseg.class \ postgresql/largeobject/LargeObjectManager.class \
postgresql/geometric/PGpath.class \ postgresql/util/PGmoney.class \
postgresql/geometric/PGpoint.class \ postgresql/util/PGobject.class \
postgresql/geometric/PGpolygon.class \ postgresql/util/PGtokenizer.class \
postgresql/largeobject/LargeObject.class \ postgresql/util/Serialize.class \
postgresql/largeobject/LargeObjectManager.class \ postgresql/util/UnixCrypt.class
postgresql/util/PGmoney.class \
postgresql/util/PGobject.class \ # These files are unique to the JDBC 1 (JDK 1.1) driver
postgresql/util/PGtokenizer.class \ OBJ_JDBC1= postgresql/jdbc1/CallableStatement.class \
postgresql/util/Serialize.class \ postgresql/jdbc1/Connection.class \
postgresql/util/UnixCrypt.class postgresql/jdbc1/DatabaseMetaData.class \
postgresql/jdbc1/PreparedStatement.class \
# If you have problems with the first line, try the second one. postgresql/jdbc1/ResultSet.class \
# This is needed when compiling under Solaris, as the solaris sh doesn't postgresql/jdbc1/ResultSetMetaData.class \
# recognise $( ) postgresql/jdbc1/Statement.class
postgresql.jar: $(OBJS)
# These files are unique to the JDBC 2 (JDK 2 nee 1.2) driver
OBJ_JDBC2= postgresql/jdbc2/ResultSet.class \
postgresql/jdbc2/PreparedStatement.class \
postgresql/jdbc2/CallableStatement.class \
postgresql/jdbc2/Connection.class \
postgresql/jdbc2/DatabaseMetaData.class \
postgresql/jdbc2/ResultSetMetaData.class \
postgresql/jdbc2/Statement.class
# This rule should never occur, but will be called when makeVersion fails to
# understand the java.version property correctly.
jdbc0:
@echo
@echo FATAL ERROR!
@echo
@echo makeVersion has not been able to determine what version of
@echo the JDK you are using, and hence what version of the driver
@echo to compile.
@echo
@echo There are two versions available, one that conforms to the
@echo JDBC 1 specification, and one to the JDBC 2 specification.
@echo
@echo To build the driver for JDBC 1 (usually for JDK 1.1 thru 1.1.7)
@echo then type: make jdbc1
@echo
@echo To build the driver for JDBC 2 (usually for JDK 1.2 and later)
@echo then type: make jdbc2
@echo
@echo If you still have problems, then please email the interfaces
@echo or bugs lists, or better still to me direct (peter@retep.org.uk)
@echo
# This rule builds the JDBC1 compliant driver
jdbc1: $(OBJ_COMMON) $(OBJ_JDBC1) postgresql.jar
# This rule builds the JDBC2 compliant driver
jdbc2: $(OBJ_COMMON) $(OBJ_JDBC2) postgresql.jar
# If you have problems with this rule, replace the $( ) with ` ` as some
# shells (mainly sh under Solaris) doesn't recognise $( )
#
# Note: This works by storing all compiled classes under the postgresql
# directory. We use this later for compiling the dual-mode driver.
#
postgresql.jar: $(OBJ) $(OBJ_COMMON)
$(JAR) -c0f $@ $$($(FIND) postgresql -name "*.class" -print) $(JAR) -c0f $@ $$($(FIND) postgresql -name "*.class" -print)
# $(JAR) -c0f $@ `$(FIND) postgresql -name "*.class" -print`
# This rule removes any temporary and compiled files from the source tree. # This rule removes any temporary and compiled files from the source tree.
clean: clean:
......
...@@ -15,8 +15,11 @@ list: ...@@ -15,8 +15,11 @@ list:
http://www.postgresql.org http://www.postgresql.org
By the time V6.3 is released, full documentation will be on the web, and in When PostgreSQL V6.4 was released, full documentation for the driver was
the distribution. included in the main documentation tree (under the doc directory).
This file was finally amended on December 29 1998 to account for the major
changes made to the driver since V6.4 was released.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
...@@ -28,14 +31,35 @@ This will compile the driver, and build a .jar file (Java ARchive). ...@@ -28,14 +31,35 @@ This will compile the driver, and build a .jar file (Java ARchive).
REMEMBER: once you have compiled the driver, it will work on ALL platforms REMEMBER: once you have compiled the driver, it will work on ALL platforms
that support the JDK 1.1 api or later. that support the JDK 1.1 api or later.
The V6.5 driver introduced support for the JDBC2 specification (which is used
with JDK 1.2 api and later). This caused us some problems because classes
written for JDBC1 and JDBC2 are not compatible, so a large chunk of the
driver had to be re-written to accomodate this.
Running make will build a .jar file (postgresql.jar) which contains the driver.
That jar file will contain the driver for _your_ version of the JDK. That is,
if you run make using JDK 1.1.7, then you will get the JDBC1 driver. If you
run using 1.2 then you will get the JDBC2 driver.
Tip: If you want the driver to run on both JDBC1 or JDBC2, first compile under
JDK 1.1.x, then recompile under JDK 1.2.
In testing, I've done this using 1.1.6 (running under linux), and running make
on my Win95 based Laptop (CygWin B20.1 was used to get a GNUMake - and a
decent shell {bash}).
When the .jar file is built, it includes all the classes under postgresql, and
the driver automatically selects the correct classes.
That means you don't have to compile it on every platform. Believe me, I That means you don't have to compile it on every platform. Believe me, I
still hear from people who ask me "I've compiled it ok under Solaris, but it still hear from people who ask me "I've compiled it ok under Solaris, but it
won't compile under Linux" - there's no difference. won't compile under Linux" - there's no difference.
PS: When you run make, don't worry if you see just one or two calls to javac. PS: When you run make, don't worry if you see more than one or two calls to
If, while compiling a class, javac needs another class that's not compiled, javac. This is normal, because the driver dynamically loads classes, and
it will compile it automatically. This reduces the numer of calls to javac the Makefile ensures everything gets compiled.
that make has to do.
I advise you don't try running javac outside of make. You may miss something.
Possible problems Possible problems
...@@ -47,6 +71,9 @@ postgresql/Driver.java:87: interface java.sql.Connection is an interface. It can ...@@ -47,6 +71,9 @@ postgresql/Driver.java:87: interface java.sql.Connection is an interface. It can
This is caused by not having the current directory in your CLASSPATH. Under This is caused by not having the current directory in your CLASSPATH. Under
Linux/Solaris, unset the CLASSPATH environment variable, and rerun make. Linux/Solaris, unset the CLASSPATH environment variable, and rerun make.
If you are still having problems, I keep a copy of the driver (for different
versions of the backend) on my web site http://www.retep.org.uk/postgres/
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
INSTALLING THE DRIVER INSTALLING THE DRIVER
...@@ -120,23 +147,11 @@ them to the URL. eg: ...@@ -120,23 +147,11 @@ them to the URL. eg:
jdbc:postgresql:database?user=me jdbc:postgresql:database?user=me
jdbc:postgresql:database?user=me&password=mypass jdbc:postgresql:database?user=me&password=mypass
By default, the driver doesn't use password authentication. You can enable Previous versions you had to use an auth argument to tell the driver what
this by adding the argument auth. ie: authentication scheme to use when connecting to the database.
jdbc:postgresql:database?user=me&password=mypass&auth=password
or if passing the user & password directly via DriverManager.getConnection(): However, this is no longer supported because the database tells the driver
what scheme it's expecting.
jdbc:postgresql:database?auth=password
PS: Password authentication is enabled if the value of auth starts with 'p'.
It is case insensitive.
As of postgresql 6.3, Ident (RFC 1413) authentication is also supported.
Simply use auth=ident in the url.
Also, as of 6.3, a system property of postgresql.auth is supported. This
defines the default authentication to use. The auth property overides this.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
...@@ -148,15 +163,6 @@ POSTGRESQL SPECIFICS ...@@ -148,15 +163,6 @@ POSTGRESQL SPECIFICS
Date datatype: Date datatype:
The driver now supports US and European date styles (although it is currently
limited to postgres format).
Basically the US like to format their dates as mm-dd-yyyy, while in Europe,
we like to use dd-mm-yyyy. Postgres supports this by the DateStyle variable.
From psql, you can issue "set datestyle='european';" to set european style,
and "set datestyle='us';" to set the US format. You can see what the current
value for this with "show datestyle;".
The driver now issues the "show datestyle;" query when it first connects, so The driver now issues the "show datestyle;" query when it first connects, so
any call to ResultSet.getDate() how returns the correct date. any call to ResultSet.getDate() how returns the correct date.
...@@ -171,13 +177,16 @@ ie: ...@@ -171,13 +177,16 @@ ie:
s.executeUpdate("show datestyle"); s.executeUpdate("show datestyle");
.. ..
s.close(); s.close();
Please note: This may change later, so that the driver uses the same format
internally (similar to how the ODBC driver works).
------------------ ------------------
JDBC supports database specific data types using the getObject() call. The JDBC supports database specific data types using the getObject() call. The
following types have their own Java equivalents supplied by the driver: following types have their own Java equivalents supplied by the driver:
box, circle, lseg, path, point, polygon box, circle, line, lseg, path, point, polygon
When using the getObject() method on a resultset, it returns a PG_Object, When using the getObject() method on a resultset, it returns a PG_Object,
which holds the postgres type, and its value. This object also supports which holds the postgres type, and its value. This object also supports
...@@ -194,10 +203,9 @@ syntax for writing these to the database. ...@@ -194,10 +203,9 @@ syntax for writing these to the database.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Peter T Mount, January 11 1998 Peter T Mount, December 29 1998
home email: pmount@maidast.demon.co.uk http://www.demon.co.uk/finder home email: pmount@retep.org.uk http://www.retep.org.uk
work email: peter@maidstone.gov.uk http://www.maidstone.gov.uk work email: petermount@it.maidstone.gov.uk or peter@taer.maidstone.gov.uk
Adrian Hall
email: adrian@hottub.org
PS: Please use the home email whenever possible. If you must contact me at work
then please cc my home one at the same time.
/**
* This class is used by the makefile to determine which version of the
* JDK is currently in use, and if it's using JDK1.1.x then it returns JDBC1
* and if later, it returns JDBC2
*
* $Id: makeVersion.java,v 1.1 1999/01/17 04:51:49 momjian Exp $
*/
public class makeVersion
{
public static void main(String[] args) {
String key = "java.version";
String version = System.getProperty(key);
//System.out.println(key+" = \""+version+"\"");
// Tip: use print not println here as println breaks the make that
// comes with CygWin-B20.1
if(version.startsWith("1.0")) {
// This will trigger the unknown rule in the makefile
System.out.print("jdbc0");
} else if(version.startsWith("1.1")) {
// This will trigger the building of the JDBC 1 driver
System.out.print("jdbc1");
} else {
// This will trigger the building of the JDBC 2 driver
System.out.print("jdbc2");
}
}
}
...@@ -27,8 +27,11 @@ public class Driver implements java.sql.Driver ...@@ -27,8 +27,11 @@ public class Driver implements java.sql.Driver
// These should be in sync with the backend that the driver was // These should be in sync with the backend that the driver was
// distributed with // distributed with
static final int MAJORVERSION = 6; static final int MAJORVERSION = 6;
static final int MINORVERSION = 4; static final int MINORVERSION = 5;
// Cache the version of the JDK in use
static String connectClass;
static static
{ {
try { try {
...@@ -49,6 +52,13 @@ public class Driver implements java.sql.Driver ...@@ -49,6 +52,13 @@ public class Driver implements java.sql.Driver
*/ */
public Driver() throws SQLException public Driver() throws SQLException
{ {
// Set the connectClass variable so that future calls will handle the correct
// base class
if(System.getProperty("java.version").startsWith("1.1")) {
connectClass = "postgresql.jdbc1.Connection";
} else {
connectClass = "postgresql.jdbc2.Connection";
}
} }
/** /**
...@@ -84,7 +94,19 @@ public class Driver implements java.sql.Driver ...@@ -84,7 +94,19 @@ public class Driver implements java.sql.Driver
if((props = parseURL(url,info))==null) if((props = parseURL(url,info))==null)
return null; return null;
return new Connection (host(), port(), props, database(), url, this); DriverManager.println("Using "+connectClass);
try {
postgresql.Connection con = (postgresql.Connection)(Class.forName(connectClass).newInstance());
con.openConnection (host(), port(), props, database(), url, this);
return (java.sql.Connection)con;
} catch(ClassNotFoundException ex) {
throw new SQLException("The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding.\nException thrown was "+ex.toString());
} catch(Exception ex2) {
throw new SQLException("Something unusual has occured to cause the driver to fail. Please report this exception: "+ex2.toString());
}
// The old call - remove before posting
//return new Connection (host(), port(), props, database(), url, this);
} }
/** /**
...@@ -315,5 +337,16 @@ public class Driver implements java.sql.Driver ...@@ -315,5 +337,16 @@ public class Driver implements java.sql.Driver
{ {
return props.getProperty(name); return props.getProperty(name);
} }
/**
* This method was added in v6.5, and simply throws an SQLException
* for an unimplemented method. I decided to do it this way while
* implementing the JDBC2 extensions to JDBC, as it should help keep the
* overall driver size down.
*/
public static SQLException notImplemented()
{
return new SQLException("This method is not yet implemented.");
}
} }
...@@ -11,13 +11,14 @@ import postgresql.*; ...@@ -11,13 +11,14 @@ import postgresql.*;
*/ */
public class Field public class Field
{ {
int length; // Internal Length of this field public int length; // Internal Length of this field
int oid; // OID of the type public int oid; // OID of the type
Connection conn; // Connection Instantation public String name; // Name of this field
String name; // Name of this field
int sql_type = -1; // The entry in java.sql.Types for this field protected Connection conn; // Connection Instantation
String type_name = null;// The sql type name
public int sql_type = -1; // The entry in java.sql.Types for this field
public String type_name = null;// The sql type name
/** /**
* Construct a field based on the information fed to it. * Construct a field based on the information fed to it.
......
...@@ -7,6 +7,9 @@ import java.util.*; ...@@ -7,6 +7,9 @@ import java.util.*;
import java.sql.*; import java.sql.*;
import postgresql.util.*; import postgresql.util.*;
// Important: There are a lot of debug code commented out. Please do not
// delete these.
/** /**
* This class implements the Fastpath api. * This class implements the Fastpath api.
* *
...@@ -54,7 +57,7 @@ public class Fastpath ...@@ -54,7 +57,7 @@ public class Fastpath
{ {
this.conn=conn; this.conn=conn;
this.stream=stream; this.stream=stream;
DriverManager.println("Fastpath initialised"); //DriverManager.println("Fastpath initialised");
} }
/** /**
...@@ -109,7 +112,7 @@ public class Fastpath ...@@ -109,7 +112,7 @@ public class Fastpath
Object result = null; // our result Object result = null; // our result
while(true) { while(true) {
int in = stream.ReceiveChar(); int in = stream.ReceiveChar();
DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'"); //DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");
switch(in) switch(in)
{ {
case 'V': case 'V':
...@@ -120,7 +123,7 @@ public class Fastpath ...@@ -120,7 +123,7 @@ public class Fastpath
// //
case 'G': case 'G':
int sz = stream.ReceiveIntegerR(4); int sz = stream.ReceiveIntegerR(4);
DriverManager.println("G: size="+sz); //debug //DriverManager.println("G: size="+sz); //debug
// Return an Integer if // Return an Integer if
if(resulttype) if(resulttype)
...@@ -149,7 +152,7 @@ public class Fastpath ...@@ -149,7 +152,7 @@ public class Fastpath
// Here we simply return res, which would contain the result // Here we simply return res, which would contain the result
// processed earlier. If no result, this already contains null // processed earlier. If no result, this already contains null
case '0': case '0':
DriverManager.println("returning "+result); //DriverManager.println("returning "+result);
return result; return result;
default: default:
...@@ -181,7 +184,7 @@ public class Fastpath ...@@ -181,7 +184,7 @@ public class Fastpath
*/ */
public Object fastpath(String name,boolean resulttype,FastpathArg[] args) throws SQLException public Object fastpath(String name,boolean resulttype,FastpathArg[] args) throws SQLException
{ {
DriverManager.println("Fastpath: calling "+name); //DriverManager.println("Fastpath: calling "+name);
return fastpath(getID(name),resulttype,args); return fastpath(getID(name),resulttype,args);
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -112,14 +112,40 @@ public class LargeObject ...@@ -112,14 +112,40 @@ public class LargeObject
* @return byte[] array containing data read * @return byte[] array containing data read
* @exception SQLException if a database-access error occurs. * @exception SQLException if a database-access error occurs.
*/ */
public byte[] read(int len) throws SQLException public byte[] read(int len) throws SQLException
{ {
FastpathArg args[] = new FastpathArg[2]; // This is the original method, where the entire block (len bytes)
args[0] = new FastpathArg(fd); // is retrieved in one go.
args[1] = new FastpathArg(len); FastpathArg args[] = new FastpathArg[2];
return fp.getData("loread",args); args[0] = new FastpathArg(fd);
} args[1] = new FastpathArg(len);
return fp.getData("loread",args);
// This version allows us to break this down into 4k blocks
//if(len<=4048) {
//// handle as before, return the whole block in one go
//FastpathArg args[] = new FastpathArg[2];
//args[0] = new FastpathArg(fd);
//args[1] = new FastpathArg(len);
//return fp.getData("loread",args);
//} else {
//// return in 4k blocks
//byte[] buf=new byte[len];
//int off=0;
//while(len>0) {
//int bs=4048;
//len-=bs;
//if(len<0) {
//bs+=len;
//len=0;
//}
//read(buf,off,bs);
//off+=bs;
//}
//return buf;
//}
}
/** /**
* Reads some data from the object into an existing array * Reads some data from the object into an existing array
* *
......
...@@ -102,7 +102,7 @@ public class LargeObjectManager ...@@ -102,7 +102,7 @@ public class LargeObjectManager
// //
// This is an example of Fastpath.addFunctions(); // This is an example of Fastpath.addFunctions();
// //
ResultSet res = (postgresql.ResultSet)conn.createStatement().executeQuery("select proname, oid from pg_proc" + java.sql.ResultSet res = (java.sql.ResultSet)conn.createStatement().executeQuery("select proname, oid from pg_proc" +
" where proname = 'lo_open'" + " where proname = 'lo_open'" +
" or proname = 'lo_close'" + " or proname = 'lo_close'" +
" or proname = 'lo_creat'" + " or proname = 'lo_creat'" +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment