Thu Jan 18 12:24:00 GMT 2001 peter@retep.org.uk
- These methods in org.postgresql.jdbc2.ResultSet are now implemented: getBigDecimal(int) ie: without a scale (why did this get missed?) getBlob(int) getCharacterStream(int) getConcurrency() getDate(int,Calendar) getFetchDirection() getFetchSize() getTime(int,Calendar) getTimestamp(int,Calendar) getType() NB: Where int represents the column name, the associated version taking a String were already implemented by calling the int version. - These methods no longer throw the not implemented but the new noupdate error. This is in preparation for the Updateable ResultSet support which will overide these methods by extending the existing class to implement that functionality, but needed to show something other than notimplemented: cancelRowUpdates() deleteRow() - Added new error message into errors.properties "postgresql.noupdate" This is used by jdbc2.ResultSet when an update method is called and the ResultSet is not updateable. A new method notUpdateable() has been added to that class to throw this exception, keeping the binary size down. - Added new error message into errors.properties "postgresql.psqlnotimp" This is used instead of unimplemented when it's a feature in the backend that is preventing this method from being implemented. - Removed getKeysetSize() as its not part of the ResultSet API Thu Jan 18 09:46:00 GMT 2001 peter@retep.org.uk - Applied modified patch from Richard Bullington-McGuire <rbulling@microstate.com>. I had to modify it as some of the code patched now exists in different classes, and some of it actually patched obsolete code. Wed Jan 17 10:19:00 GMT 2001 peter@retep.org.uk - Updated Implementation to include both ANT & JBuilder - Updated README to reflect the changes since 7.0 - Created jdbc.jpr file which allows JBuilder to be used to edit the source. JBuilder _CAN_NOT_ be used to compile. You must use ANT for that. It's only to allow JBuilders syntax checking to improve the drivers source. Refer to Implementation for more details
This commit is contained in:
parent
89ac643964
commit
45b5d792af
94
build.xml
Normal file
94
build.xml
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
build file to allow ant (http://jakarta.apache.org/ant/) to be used
|
||||||
|
to build the PostgreSQL JDBC Driver and any associated java utilities under
|
||||||
|
/contrib.
|
||||||
|
|
||||||
|
This is placed here for three reasons:
|
||||||
|
|
||||||
|
1: You only need to run ANT once to get everything.
|
||||||
|
2: To let people know that there are more java sources under /contrib.
|
||||||
|
3: In the next release (after 7.1) it's intended to have configure to
|
||||||
|
detect the presence of both the JDK and ANT, and if both are found
|
||||||
|
to build the jdbc driver and utils with the rest of postgresql.
|
||||||
|
|
||||||
|
$Id: build.xml,v 1.1 2001/01/18 14:50:14 peter Exp $
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project name="postgresql" default="jar" basedir=".">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This is the normal entry point. It builds first the
|
||||||
|
jdbc driver, then the extra tools.
|
||||||
|
-->
|
||||||
|
<target name="jar">
|
||||||
|
<antcall target="call">
|
||||||
|
<param name="target" value="jar" />
|
||||||
|
</antcall>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This entry point clears the source tree. Call this when you want
|
||||||
|
to build a clean install.
|
||||||
|
-->
|
||||||
|
<target name="clean">
|
||||||
|
<antcall target="call">
|
||||||
|
<param name="target" value="clean" />
|
||||||
|
</antcall>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This entry point installs the .jar files into an install directory.
|
||||||
|
|
||||||
|
To use this, call ant as follows:
|
||||||
|
|
||||||
|
ant -Dinstall.directory=mydir install
|
||||||
|
|
||||||
|
Where mydir is the _Absolute_ path of the directory to create.
|
||||||
|
|
||||||
|
|
||||||
|
If the directory mydir does not exist it will be created.
|
||||||
|
|
||||||
|
If the directory is not absolute then the install will fail by
|
||||||
|
creating subdirectories in the build path. Be careful.
|
||||||
|
|
||||||
|
|
||||||
|
This is intended for "make install" to call it.
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
Windows: ant -Dc:\jars install
|
||||||
|
Unix: ant -Dinstall.directory=/usr/local/lib/jars install
|
||||||
|
Cygwin: ant -Dinstall.directory=$(cygpath -w /usr/local/lib/jars) install
|
||||||
|
|
||||||
|
-->
|
||||||
|
<target name="install" if="install.directory">
|
||||||
|
<mkdir dir="${install.directory}" />
|
||||||
|
<antcall target="call">
|
||||||
|
<param name="target" value="install" />
|
||||||
|
</antcall>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This actually calls the other two build.xml files.
|
||||||
|
To use it, use the <antcall> tag, and pass the destination target
|
||||||
|
within a <param> tag using name="target".
|
||||||
|
|
||||||
|
ie:
|
||||||
|
|
||||||
|
<antcall target="call">
|
||||||
|
<param name="target" value="mytarget" />
|
||||||
|
</antcall>
|
||||||
|
|
||||||
|
Here, the target mytarget will be called from all the sub build.xml
|
||||||
|
files.
|
||||||
|
|
||||||
|
Note: The target must be present in _ALL_ build.xml files otherwise
|
||||||
|
the build will fail.
|
||||||
|
-->
|
||||||
|
<target name="call">
|
||||||
|
<ant dir="src/interfaces/jdbc" target="${target}" />
|
||||||
|
<ant dir="contrib/retep" target="${target}" />
|
||||||
|
</target>
|
||||||
|
</project>
|
||||||
|
|
0
contrib/retep/CHANGELOG
Normal file
0
contrib/retep/CHANGELOG
Normal file
0
contrib/retep/Implementation
Normal file
0
contrib/retep/Implementation
Normal file
0
contrib/retep/README
Normal file
0
contrib/retep/README
Normal file
60
contrib/retep/build.xml
Normal file
60
contrib/retep/build.xml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<!--
|
||||||
|
|
||||||
|
build file to build the donated retep tools packages
|
||||||
|
|
||||||
|
$Id: build.xml,v 1.1 2001/01/18 14:50:14 peter Exp $
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project name="retep" default="jar" basedir=".">
|
||||||
|
|
||||||
|
<!-- set global properties for this build -->
|
||||||
|
<property name="src" value="." />
|
||||||
|
<property name="dest" value="build" />
|
||||||
|
<property name="package" value="uk/org/retep" />
|
||||||
|
<property name="jars" value="jars" />
|
||||||
|
|
||||||
|
<!-- Some checks used to build dependent on the environment -->
|
||||||
|
<target name="checks">
|
||||||
|
<available property="jdk1.2+" classname="java.lang.ThreadLocal" />
|
||||||
|
<available property="jdk1.3+" classname="java.lang.StrictMath" />
|
||||||
|
<available property="jdk1.2e+" classname="javax.sql.DataSource" />
|
||||||
|
<available property="xml" classname="org.xml.sax.Parser" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Prepares the build by creating a directory to place the class files -->
|
||||||
|
<target name="prepare">
|
||||||
|
<mkdir dir="${dest}" />
|
||||||
|
<mkdir dir="${jars}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- This target removes any class files from the build directory -->
|
||||||
|
<target name="clean">
|
||||||
|
<delete dir="${dest}" />
|
||||||
|
<delete dir="${jars}" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Builds the XML Tools -->
|
||||||
|
<target name="xml" depends="checks,prepare" if="xml">
|
||||||
|
<javac srcdir="${src}" destdir="${dest}">
|
||||||
|
<include name="${package}/xml/**" />
|
||||||
|
</javac>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Builds the various jar files -->
|
||||||
|
<target name="jar" depends="xml">
|
||||||
|
<jar jarfile="${jars}/retepTools.jar" basedir="${dest}">
|
||||||
|
<include name="${package}/xml/parser/**" if="xml" />
|
||||||
|
</jar>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="install" depends="jar" if="install.directory">
|
||||||
|
<copy todir="${install.directory}" overwrite="true" filtering="off">
|
||||||
|
<fileset dir="${jars}">
|
||||||
|
<include name="**/*.jar" />
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
44
contrib/retep/retep.jpx
Normal file
44
contrib/retep/retep.jpx
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--JBuilder XML Project-->
|
||||||
|
<project>
|
||||||
|
<property category="idl" name="ProcessIDL" value="false" />
|
||||||
|
<property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.ApplicationRunner" />
|
||||||
|
<property category="runtime.0" name="jsprunner.docbase" value="." />
|
||||||
|
<property category="runtime.0" name="jsprunner.jspfile" value="E%|/docs/java/xml/example6" />
|
||||||
|
<property category="sys" name="AuthorLabel" value="@author" />
|
||||||
|
<property category="sys" name="BackupPath" value="bak" />
|
||||||
|
<property category="sys" name="BeansInstantiate" value="false" />
|
||||||
|
<property category="sys" name="BraceStyle" value="1" />
|
||||||
|
<property category="sys" name="CheckStable" value="1" />
|
||||||
|
<property category="sys" name="Company" value="" />
|
||||||
|
<property category="sys" name="CompanyLabel" value="Company:" />
|
||||||
|
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
|
||||||
|
<property category="sys" name="CopyrightLabel" value="Copyright:" />
|
||||||
|
<property category="sys" name="DefaultPackage" value="org.postgresql.core" />
|
||||||
|
<property category="sys" name="Description" value="" />
|
||||||
|
<property category="sys" name="DescriptionLabel" value="Description:" />
|
||||||
|
<property category="sys" name="DocPath" value="doc" />
|
||||||
|
<property category="sys" name="EventMatch" value="false" />
|
||||||
|
<property category="sys" name="EventStyle" value="1" />
|
||||||
|
<property category="sys" name="ExcludeClassEnabled" value="0" />
|
||||||
|
<property category="sys" name="InstanceVisibility" value="0" />
|
||||||
|
<property category="sys" name="JDK" value="java 1.3.0-C" />
|
||||||
|
<property category="sys" name="LastTag" value="0" />
|
||||||
|
<property category="sys" name="Libraries" value="JAXP" />
|
||||||
|
<property category="sys" name="MakeStable" value="0" />
|
||||||
|
<property category="sys" name="OutPath" value="build" />
|
||||||
|
<property category="sys" name="SourcePath" value="." />
|
||||||
|
<property category="sys" name="Title" value="" />
|
||||||
|
<property category="sys" name="TitleLabel" value="Title:" />
|
||||||
|
<property category="sys" name="Version" value="1.0" />
|
||||||
|
<property category="sys" name="VersionLabel" value="@version" />
|
||||||
|
<property category="sys" name="WorkingDirectory" value="." />
|
||||||
|
<node type="Package" name="uk.org.retep.xml.jdbc" />
|
||||||
|
<node type="Package" name="uk.org.retep.xml.parser" />
|
||||||
|
<file path="build.xml" />
|
||||||
|
<file path="CHANGELOG" />
|
||||||
|
<file path="Implementation" />
|
||||||
|
<file path="README" />
|
||||||
|
</project>
|
||||||
|
|
202
contrib/retep/uk/org/retep/xml/parser/TagHandler.java
Normal file
202
contrib/retep/uk/org/retep/xml/parser/TagHandler.java
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
package uk.org.retep.xml.parser;
|
||||||
|
|
||||||
|
import java.io.CharArrayWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import org.xml.sax.AttributeList;
|
||||||
|
import org.xml.sax.HandlerBase;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.Parser;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.parsers.SAXParser;
|
||||||
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the base of the XML handler. You create an instance,
|
||||||
|
* register classes (who implement TagListener) that are interested in the tags
|
||||||
|
* and pass it to SAX.
|
||||||
|
*
|
||||||
|
* <p>Or you create an instance, register the TagListeners and use the getParser()
|
||||||
|
* method to create a Parser. Then start parsing by calling it's parse() method.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TagHandler extends HandlerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current active level
|
||||||
|
*/
|
||||||
|
private int level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cache used to handle nesting of tags
|
||||||
|
*/
|
||||||
|
private List contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cache used to handle nesting of tags
|
||||||
|
*/
|
||||||
|
private List tags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cache used to handle nesting of tags
|
||||||
|
*/
|
||||||
|
private List args;
|
||||||
|
|
||||||
|
// Current active content writer
|
||||||
|
private CharArrayWriter content;
|
||||||
|
|
||||||
|
// List of TagListener's who want to be fed data
|
||||||
|
private HashSet tagListeners;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public TagHandler() {
|
||||||
|
level=0;
|
||||||
|
contents = new ArrayList();
|
||||||
|
tags = new ArrayList();
|
||||||
|
args = new ArrayList();
|
||||||
|
tagListeners = new HashSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by SAX when a tag is begun. This simply creates a new level in the
|
||||||
|
* cache and stores the parameters and tag name in there.
|
||||||
|
*/
|
||||||
|
public void startElement(String p0, AttributeList p1) throws SAXException {
|
||||||
|
|
||||||
|
// Now move up and fetch a CharArrayWriter from the cache
|
||||||
|
// creating if this is the first time at this level
|
||||||
|
if(contents.size()<=level) {
|
||||||
|
contents.add(new CharArrayWriter());
|
||||||
|
tags.add(p0);
|
||||||
|
args.add(new HashMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
content=(CharArrayWriter) contents.get(level);
|
||||||
|
content.reset();
|
||||||
|
|
||||||
|
// Also cache the tag's text and argument list
|
||||||
|
tags.set(level,p0);
|
||||||
|
|
||||||
|
HashMap h = (HashMap) args.get(level);
|
||||||
|
h.clear();
|
||||||
|
for(int i=p1.getLength()-1;i>-1;i--) {
|
||||||
|
h.put(p1.getName(i),p1.getValue(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now notify any TagListeners
|
||||||
|
Iterator it = tagListeners.iterator();
|
||||||
|
while(it.hasNext())
|
||||||
|
( (TagListener) it.next() ).tagStart(level,p0,h);
|
||||||
|
|
||||||
|
// Now move up a level
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called by SAX at the end of a tag. This calls handleTag() and then
|
||||||
|
* raises the level, so that the previous parent tag may continue.
|
||||||
|
*/
|
||||||
|
public void endElement(String p0) throws SAXException {
|
||||||
|
// move up a level retrieving that level's current content
|
||||||
|
// Now this exception should never occur as the underlying parser should
|
||||||
|
// actually trap it.
|
||||||
|
if(level<1)
|
||||||
|
throw new SAXException("Already at top level?");
|
||||||
|
level--;
|
||||||
|
|
||||||
|
// Now notify any TagListeners
|
||||||
|
Iterator it = tagListeners.iterator();
|
||||||
|
while(it.hasNext())
|
||||||
|
( (TagListener) it.next() ).tagContent(content);
|
||||||
|
|
||||||
|
// allows large content to be released early
|
||||||
|
content.reset();
|
||||||
|
|
||||||
|
// Now reset content to the previous level
|
||||||
|
content=(CharArrayWriter) contents.get(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by SAX so that content between the start and end tags are captured.
|
||||||
|
*/
|
||||||
|
public void characters(char[] p0, int p1, int p2) throws SAXException {
|
||||||
|
content.write(p0,p1,p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a TagListener so that it is notified of tags as they are processed.
|
||||||
|
* @param handler TagListener to add
|
||||||
|
*/
|
||||||
|
public void addTagListener(TagListener h) {
|
||||||
|
tagListeners.add(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the TagListener so it no longer receives notifications of tags
|
||||||
|
*/
|
||||||
|
public void removeTagListener(TagListener h) {
|
||||||
|
tagListeners.remove(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns a org.xml.sax.Parser object that will parse the
|
||||||
|
* contents of a URI.
|
||||||
|
*
|
||||||
|
* <p>Normally you would call this method, then call the parse(uri) method of
|
||||||
|
* the returned object.
|
||||||
|
* @return org.xml.sax.Parser object
|
||||||
|
*/
|
||||||
|
public Parser getParser()
|
||||||
|
throws SAXException
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||||
|
|
||||||
|
String validation = System.getProperty ("javax.xml.parsers.validation", "false");
|
||||||
|
if (validation.equalsIgnoreCase("true"))
|
||||||
|
spf.setValidating (true);
|
||||||
|
|
||||||
|
SAXParser sp = spf.newSAXParser();
|
||||||
|
Parser parser = sp.getParser ();
|
||||||
|
|
||||||
|
parser.setDocumentHandler(this);
|
||||||
|
|
||||||
|
return(parser);
|
||||||
|
} catch(ParserConfigurationException pce) {
|
||||||
|
throw new SAXException(pce.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will parse the specified URI.
|
||||||
|
*
|
||||||
|
* <p>Internally this is the same as getParser().parse(uri);
|
||||||
|
* @param uri The URI to parse
|
||||||
|
*/
|
||||||
|
public void parse(String uri)
|
||||||
|
throws IOException, SAXException
|
||||||
|
{
|
||||||
|
getParser().parse(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will parse the specified InputSource.
|
||||||
|
*
|
||||||
|
* <p>Internally this is the same as getParser().parse(is);
|
||||||
|
* @param is The InputSource to parse
|
||||||
|
*/
|
||||||
|
public void parse(InputSource is)
|
||||||
|
throws IOException, SAXException
|
||||||
|
{
|
||||||
|
getParser().parse(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
contrib/retep/uk/org/retep/xml/parser/TagListener.java
Normal file
30
contrib/retep/uk/org/retep/xml/parser/TagListener.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package uk.org.retep.xml.parser;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.io.CharArrayWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines the methods a class needs to implement if it wants the
|
||||||
|
* xml parser to notify it of any xml tags.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface TagListener {
|
||||||
|
/**
|
||||||
|
* This is called when a tag has just been started.
|
||||||
|
* <p><b>NB:</b> args is volatile, so if you use it beyond the lifetime of
|
||||||
|
* this call, then you must make a copy of the HashMap (and not use simply
|
||||||
|
* store this HashMap).
|
||||||
|
* @param level The number of tags above this
|
||||||
|
* @param tag The tag name
|
||||||
|
* @param args A HashMap of any arguments
|
||||||
|
*/
|
||||||
|
public void tagStart(int level,String tag,HashMap args);
|
||||||
|
/**
|
||||||
|
* This method is called by ContHandler to process a tag once it has been
|
||||||
|
* fully processed.
|
||||||
|
* <p><b>NB:</b> content is volatile, so you must copy its contents if you use
|
||||||
|
* it beyond the lifetime of this call.
|
||||||
|
* @param content CharArrayWriter containing the content of the tag.
|
||||||
|
*/
|
||||||
|
public void tagContent(CharArrayWriter content);
|
||||||
|
}
|
@ -1,3 +1,49 @@
|
|||||||
|
Thu Jan 18 12:24:00 GMT 2001 peter@retep.org.uk
|
||||||
|
- These methods in org.postgresql.jdbc2.ResultSet are now implemented:
|
||||||
|
getBigDecimal(int) ie: without a scale (why did this get missed?)
|
||||||
|
getBlob(int)
|
||||||
|
getCharacterStream(int)
|
||||||
|
getConcurrency()
|
||||||
|
getDate(int,Calendar)
|
||||||
|
getFetchDirection()
|
||||||
|
getFetchSize()
|
||||||
|
getTime(int,Calendar)
|
||||||
|
getTimestamp(int,Calendar)
|
||||||
|
getType()
|
||||||
|
NB: Where int represents the column name, the associated version
|
||||||
|
taking a String were already implemented by calling the int
|
||||||
|
version.
|
||||||
|
- These methods no longer throw the not implemented but the new noupdate
|
||||||
|
error. This is in preparation for the Updateable ResultSet support
|
||||||
|
which will overide these methods by extending the existing class to
|
||||||
|
implement that functionality, but needed to show something other than
|
||||||
|
notimplemented:
|
||||||
|
cancelRowUpdates()
|
||||||
|
deleteRow()
|
||||||
|
- Added new error message into errors.properties "postgresql.noupdate"
|
||||||
|
This is used by jdbc2.ResultSet when an update method is called and
|
||||||
|
the ResultSet is not updateable. A new method notUpdateable() has been
|
||||||
|
added to that class to throw this exception, keeping the binary size
|
||||||
|
down.
|
||||||
|
- Added new error message into errors.properties "postgresql.psqlnotimp"
|
||||||
|
This is used instead of unimplemented when it's a feature in the
|
||||||
|
backend that is preventing this method from being implemented.
|
||||||
|
- Removed getKeysetSize() as its not part of the ResultSet API
|
||||||
|
|
||||||
|
Thu Jan 18 09:46:00 GMT 2001 peter@retep.org.uk
|
||||||
|
- Applied modified patch from Richard Bullington-McGuire
|
||||||
|
<rbulling@microstate.com>. I had to modify it as some of the code
|
||||||
|
patched now exists in different classes, and some of it actually
|
||||||
|
patched obsolete code.
|
||||||
|
|
||||||
|
Wed Jan 17 10:19:00 GMT 2001 peter@retep.org.uk
|
||||||
|
- Updated Implementation to include both ANT & JBuilder
|
||||||
|
- Updated README to reflect the changes since 7.0
|
||||||
|
- Created jdbc.jpr file which allows JBuilder to be used to edit the
|
||||||
|
source. JBuilder _CAN_NOT_ be used to compile. You must use ANT for
|
||||||
|
that. It's only to allow JBuilders syntax checking to improve the
|
||||||
|
drivers source. Refer to Implementation for more details
|
||||||
|
|
||||||
Wed Dec 20 16:19:00 GMT 2000 peter@retep.org.uk
|
Wed Dec 20 16:19:00 GMT 2000 peter@retep.org.uk
|
||||||
- Finished build.xml and updated Driver.java.in and buildDriver to
|
- Finished build.xml and updated Driver.java.in and buildDriver to
|
||||||
match how Makefile and ANT operate.
|
match how Makefile and ANT operate.
|
||||||
|
@ -1,28 +1,87 @@
|
|||||||
This short document is provided to help programmers through the internals of
|
This short document is provided to help programmers through the internals of
|
||||||
the PostgreSQL JDBC driver.
|
the PostgreSQL JDBC driver.
|
||||||
|
|
||||||
|
Last update: January 17 2001 peter@retep.org.uk
|
||||||
|
|
||||||
|
build.xml
|
||||||
|
---------
|
||||||
|
|
||||||
|
As of 7.1, we now use the ANT build tool to build the driver. ANT is part of
|
||||||
|
the Apache/Jakarta project, and provides far superior build capabilities. You
|
||||||
|
can find ANT from http://jakarta.apache.org/ant/index.html and being pure java
|
||||||
|
it will run on any java platform.
|
||||||
|
|
||||||
|
So far I've tested it under JDK1.2.x & JDK1.3 (both Linux & NT) but not yet with
|
||||||
|
JDK1.1.8. Because of the latter the Makefile still works for now, but should be
|
||||||
|
gone for 7.2.
|
||||||
|
|
||||||
|
Anyhow, to build, simply type ant and the .jar file will be created and put into
|
||||||
|
the jars directory.
|
||||||
|
|
||||||
|
Tip: If you run ant from the sources root directory (ie: where the configure
|
||||||
|
script is located) you will find another build.xml file. It is advised to run
|
||||||
|
ant from that directory as it will then compile some auxilary Java/JDBC
|
||||||
|
utilities that are located under the /contrib/retep directory.
|
||||||
|
|
||||||
Makefile
|
Makefile
|
||||||
--------
|
--------
|
||||||
|
|
||||||
All compilation must be done by using Make. This is because there are two
|
Prior to 7.1, all compilation must be done by using Make. This is because there
|
||||||
versions of the driver, one for JDBC1 (for JDK 1.1.x) and the other for JDBC2
|
are three versions of the driver, one for JDBC1 (for JDK 1.1.x) and the others
|
||||||
(for JDK 1.2 or later). The makefile determines which version to compile by
|
for JDBC2 (for JDK 1.2 or later, one standard and one enterprise).
|
||||||
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
|
As of 7.1, ANT is the build tool of choice. Just compare Makefile and build.xml
|
||||||
some classes are dynamically loaded, so javac will not compile them.
|
to see why! Make just isn't suited to Java.
|
||||||
|
|
||||||
|
Building with just the JDK
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
This is not advised, simply because you have to make sure you include the
|
||||||
|
correct classes, and the fact that org.postgresql.Driver is built on the fly.
|
||||||
|
Also, javac won't pick up all the classes because some (org.postgresql.geometric
|
||||||
|
for example) are loaded dynamically.
|
||||||
|
|
||||||
|
org/postgresql/Driver.java.in
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Because there are three versions of the driver, the org.postgresql.Driver class
|
||||||
|
is built dynamically. To build correctly ANT copies the Driver.java.in file to
|
||||||
|
Driver.java replacing certain values according to the required driver.
|
||||||
|
|
||||||
|
The replaced values are of the format %VALUE%, ie: %MAJORVERSION% is replaced
|
||||||
|
with 7 in the 7.1 version of the driver.
|
||||||
|
|
||||||
postgresql.jar
|
postgresql.jar
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
This jar file is produced by make, and contains the driver for your JDK
|
This jar file is produced by ANT, and contains the driver for your JDK platform.
|
||||||
platform.
|
|
||||||
|
|
||||||
Note: It is possible to compile the driver under say JDK1.1.7, then under
|
If you downloaded a precompiled binary from the web, you may find that the
|
||||||
JDK 1.2. Because make doesn't remove the old classes before compiling,
|
jar file will be named differently. These are identical to this file but are
|
||||||
jar will simply package both sets together. When the driver is loaded,
|
named according to the backend and jdk versions.
|
||||||
the postgresql.Driver class will sort out which set of classes to use.
|
|
||||||
|
The naming convention is of the form: jdbc-#.#-#.##.jar
|
||||||
|
|
||||||
|
ie: for 7.1
|
||||||
|
jdbc-7.1-1.1.jar JDBC Driver for JDK1.1.8
|
||||||
|
jdbc-7.1-1.2.jar JDBC Driver for JDK1.2 & JDK1.3
|
||||||
|
jdbc-7.1-1.2ent.jar JDBC Driver for JDK1.2 & JDK1.3 Enterprise Editions
|
||||||
|
|
||||||
|
If in the future there are any 1.3 specific classes then there will be two new
|
||||||
|
jar files.
|
||||||
|
|
||||||
|
Note: All the precompiled binaries are built under Linux.
|
||||||
|
|
||||||
|
jdbc.jpx
|
||||||
|
--------
|
||||||
|
|
||||||
|
This is a JBuilder4 project file. It's here to allow JBuilder to be used to
|
||||||
|
develop the driver. Mainly for it's Editor's features like syntax checking and
|
||||||
|
auto-completion etc.
|
||||||
|
|
||||||
|
IMPORTANT: You CAN NOT build the driver from within JBuilder. You must use ANT.
|
||||||
|
This is because of the three versions of the JDK. If you try to use
|
||||||
|
JBuilder, it will try to build everything, and it will just not work.
|
||||||
|
|
||||||
Importing packages
|
Importing packages
|
||||||
------------------
|
------------------
|
||||||
@ -50,16 +109,17 @@ Package Layout
|
|||||||
|
|
||||||
The driver is split into several packages:
|
The driver is split into several packages:
|
||||||
|
|
||||||
postgresql core classes, common to both JDBC 1 & 2
|
org.postgresql core classes that can be accessed by user code
|
||||||
postgresql.jdbc1 classes used only in implementing JDBC 1
|
org.postgresql.core core classes not normally used externally
|
||||||
postgresql.jdbc2 classes used only in implementing JDBC 2
|
org.postgresql.jdbc1 classes used only in implementing JDBC 1
|
||||||
postgresql.fastpath FastPath to backend functions
|
org.postgresql.jdbc2 classes used only in implementing JDBC 2
|
||||||
postgresql.geometric 2D Geometric types mapped to Java Objects
|
org.postgresql.fastpath FastPath to backend functions
|
||||||
postgresql.largeobject Low level Large Object access
|
org.postgresql.geometric 2D Geometric types mapped to Java Objects
|
||||||
postgresql.util Utility classes
|
org.postgresql.largeobject Low level Large Object access
|
||||||
|
org.postgresql.util Utility classes
|
||||||
|
|
||||||
|
|
||||||
Package postgresql
|
Package org.postgresql
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
This package holds the core classes.
|
This package holds the core classes.
|
||||||
@ -70,6 +130,9 @@ Driver registers the driver when it's loaded, and determines which
|
|||||||
|
|
||||||
Field Used internally to represent a Field
|
Field Used internally to represent a Field
|
||||||
PG_Stream Used internally to manage the network stream.
|
PG_Stream Used internally to manage the network stream.
|
||||||
|
PostgresqlDataSource
|
||||||
|
Exists in the Java2 Enterprise edition driver only and is the
|
||||||
|
enterprise equivalent to Driver
|
||||||
|
|
||||||
These classes contains common code that is not dependent to the
|
These classes contains common code that is not dependent to the
|
||||||
two JDBC specifications.
|
two JDBC specifications.
|
||||||
@ -77,13 +140,25 @@ PG_Stream Used internally to manage the network stream.
|
|||||||
Connection Common code used in Connections, mainly Network Protocol stuff.
|
Connection Common code used in Connections, mainly Network Protocol stuff.
|
||||||
ResultSet Common code used in ResultSet's
|
ResultSet Common code used in ResultSet's
|
||||||
|
|
||||||
Package postgresql.fastpath
|
Package org.postgresql.core
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
New in 7.1, this is where core classes (common to all versions) will exist. Any
|
||||||
|
new class that would have gone into org.postgresql must go in here instead.
|
||||||
|
|
||||||
|
BytePoolDim1 Handles a pool of byte[] arrays.
|
||||||
|
BytePoolDim2 Handles a pool of byte[][] arrays
|
||||||
|
MemoryPool Interface for managing MemoryPools. Not used (yet).
|
||||||
|
ObjectPool Interface for an Object Pool
|
||||||
|
SimpleObjectPool Class that implements ObjectPool and used by BytePoolDim#
|
||||||
|
|
||||||
|
Package org.postgresql.fastpath
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
Fastpath Handles executing a function on the PostgreSQL Backend
|
Fastpath Handles executing a function on the PostgreSQL Backend
|
||||||
FastpathArg Defines an argument for a function call
|
FastpathArg Defines an argument for a function call
|
||||||
|
|
||||||
Package postgresql.geometric
|
Package org.postgresql.geometric
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
PGbox Maps to postgresql type box
|
PGbox Maps to postgresql type box
|
||||||
@ -94,25 +169,25 @@ PGpath Maps to postgresql type path
|
|||||||
PGpoint Maps to postgresql type point
|
PGpoint Maps to postgresql type point
|
||||||
PGpolygon Maps to postgresql type polygon
|
PGpolygon Maps to postgresql type polygon
|
||||||
|
|
||||||
Package postgresql.jdbc1
|
Package org.postgresql.jdbc1
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
The classes in this package handle the JDBC 1 Specification, for JDK 1.1.x
|
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.
|
All interfaces in the java.sql package are present here.
|
||||||
|
|
||||||
Package postgresql.jdbc2
|
Package org.postgresql.jdbc2
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
The classes in this package handle the JDBC 2 Specification, for JDK 1.2
|
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.
|
All interfaces in the java.sql, and javax.sql packages are present here.
|
||||||
|
|
||||||
Package postgresql.largeobject
|
Package org.postgresql.largeobject
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
LargeObject Represents an open LargeObject
|
LargeObject Represents an open LargeObject
|
||||||
LargeObjectManager Handles the opening and deleting of LargeObjects
|
LargeObjectManager Handles the opening and deleting of LargeObjects
|
||||||
|
|
||||||
Package postgresql.util
|
Package org.postgresql.util
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
PGmoney Maps to postgresql type money
|
PGmoney Maps to postgresql type money
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# Makefile for Java JDBC interface
|
# Makefile for Java JDBC interface
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $Id: Makefile,v 1.25 2000/10/12 08:55:23 peter Exp $
|
# $Id: Makefile,v 1.26 2001/01/18 14:50:14 peter Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -39,10 +39,30 @@ PGBASE = org/postgresql
|
|||||||
# New for 7.1: The jar filename
|
# New for 7.1: The jar filename
|
||||||
JARFILE = postgresql.jar
|
JARFILE = postgresql.jar
|
||||||
|
|
||||||
|
all:
|
||||||
|
@echo ------------------------------------------------------------
|
||||||
|
@echo The use of Make to build the driver is now depreciated in
|
||||||
|
@echo version 7.1 and later. To build the driver you now need to
|
||||||
|
@echo use ANT. This is the build tool of the Jakarta project, and
|
||||||
|
@echo you can obtain this from http://jakarta.apache.org/ant/
|
||||||
|
@echo
|
||||||
|
@echo Once you have this installed, change directory to the root
|
||||||
|
@echo directory of the postgresql source and type ant.
|
||||||
|
@echo
|
||||||
|
@echo ie: if you are currently in the pgsql/src/interfaces/jdbc
|
||||||
|
@echo directory then cd into the pgsql one \(cd ../../.. should
|
||||||
|
@echo do\).
|
||||||
|
@echo
|
||||||
|
@echo The file Implementation contains more info on this, as does
|
||||||
|
@echo the homepage http://jdbc.postgresql.org/
|
||||||
|
@echo ------------------------------------------------------------
|
||||||
|
|
||||||
# Yet another attempt to check the version. In theory, any JVM that fails
|
# Yet another attempt to check the version. In theory, any JVM that fails
|
||||||
# this is breaking the versioning specifications released by Javasoft.
|
# this is breaking the versioning specifications released by Javasoft.
|
||||||
#
|
#
|
||||||
all: utils/CheckVersion.class
|
# In 7.1 this is renamed oldall so that the depreciated message is shown.
|
||||||
|
#
|
||||||
|
oldall: utils/CheckVersion.class
|
||||||
@$(MAKE) `$(JAVA) utils.CheckVersion`
|
@$(MAKE) `$(JAVA) utils.CheckVersion`
|
||||||
|
|
||||||
# For 6.5.3 and 7.0+, we need to select the correct JDBC API, so prompt
|
# For 6.5.3 and 7.0+, we need to select the correct JDBC API, so prompt
|
||||||
@ -72,7 +92,10 @@ huho:
|
|||||||
@echo
|
@echo
|
||||||
@echo ------------------------------------------------------------
|
@echo ------------------------------------------------------------
|
||||||
|
|
||||||
msg:
|
# In 7.1 replaced msg so that the depreciated message is shown.
|
||||||
|
msg: all
|
||||||
|
|
||||||
|
oldmsg:
|
||||||
@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
|
||||||
|
@ -1,34 +1,49 @@
|
|||||||
This is a simple readme describing how to compile and use the jdbc driver.
|
This is a simple readme describing how to compile and use the jdbc driver.
|
||||||
|
|
||||||
This file was amended on May 2 2000 to document the changes made in the 7.0
|
This file was amended on January 17 2001 to reflect the changes made in the 7.1
|
||||||
release.
|
release.
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
This isn't a guide on how to use JDBC - for that refer to Javasoft's web site:
|
This isn't a guide on how to use JDBC - for that refer to Javasoft's web site:
|
||||||
|
|
||||||
http://www.javasoft.com
|
http://www.javasoft.com/
|
||||||
|
|
||||||
For problems with this driver, then refer to the postgres-interfaces email
|
For problems with this driver, then refer to the postgres-interfaces email
|
||||||
list:
|
list:
|
||||||
|
|
||||||
http://www.postgresql.org
|
http://www.postgresql.org/
|
||||||
|
|
||||||
|
The Driver's home page is:
|
||||||
|
|
||||||
|
http://jdbc.postgresql.org/
|
||||||
|
or http://www.retep.org.uk/postgresql/
|
||||||
|
|
||||||
|
NB: They are both the same physical directory so both will always be in sync
|
||||||
|
(unless the laws of physics break down ;-) )
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
COMPILING
|
COMPILING
|
||||||
|
|
||||||
There are actually two versions of the driver. One for the JDBC1.2 specification, and one for the JDBC2 specification. To compile the driver, you need to select the correct one.
|
To compile you will need to have ANT installed. To obtain ant go to
|
||||||
|
http://jakarta.apache.org/ant/index.html and download the binary. Being pure
|
||||||
|
java it will run on virtually all java platforms. If you have any problems
|
||||||
|
please email the INTERFACES list.
|
||||||
|
|
||||||
If you have JDK1.1.x you need to type: make jdbc1
|
Once you have ANT, cd to the src directory and type "ant". This will compile
|
||||||
|
the correct driver for your JVM, and build a .jar file (Java ARchive) called
|
||||||
If you have JDK1.2 or JDK1.3, you need to type: make jdbc2
|
|
||||||
|
|
||||||
This will compile the driver, and build a .jar file (Java ARchive) called
|
|
||||||
postgresql.jar
|
postgresql.jar
|
||||||
|
|
||||||
That jar file will contain the driver for _your_ version of the JDK.
|
That jar file will contain the driver for _your_ version of the JDK.
|
||||||
|
|
||||||
|
Note: As of 7.1, you build from pgsql/src and not pgsql/src/interfaces/jdbc.
|
||||||
|
Well you can, but building from the top will also build some extra utilities
|
||||||
|
located under /contrib at the same time. Also later on (either 7.1.1 or 7.2)
|
||||||
|
it's intended to have the main configure script to build the driver
|
||||||
|
automatically if it finds both a JDK & ANT installed, so this is the first step
|
||||||
|
towards that.
|
||||||
|
|
||||||
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 that version of the API. You don't need to build it for each
|
that support that version of the API. You don't need to build it for each
|
||||||
platform.
|
platform.
|
||||||
@ -37,11 +52,8 @@ 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 more than one or two calls to
|
I advise you don't try running javac outside of ANT as it builds some classes
|
||||||
javac. This is normal, because the driver dynamically loads classes, and
|
on the fly.
|
||||||
the Makefile ensures everything gets compiled.
|
|
||||||
|
|
||||||
I advise you don't try running javac outside of make. You may miss something.
|
|
||||||
|
|
||||||
Possible problems
|
Possible problems
|
||||||
|
|
||||||
@ -51,10 +63,13 @@ postgresql/Driver.java:87: interface java.sql.Connection is an interface. It can
|
|||||||
return new Connection (host(), port(), props, database(), url, this);
|
return new Connection (host(), port(), props, database(), url, this);
|
||||||
|
|
||||||
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 ant.
|
||||||
|
|
||||||
If you are still having problems, I keep a copy of the driver (for different
|
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/
|
versions of the backend) on my web site http://www.retep.org.uk/postgres/
|
||||||
|
or http://jdbc.postgresql.org/
|
||||||
|
|
||||||
|
More details are in the Implementation file src/interfaces/jdbc/Implementation
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -67,6 +82,9 @@ ie: under LINUX/SOLARIS (the example here is my linux box):
|
|||||||
|
|
||||||
export CLASSPATH=.:/usr/local/lib/postgresql.jar
|
export CLASSPATH=.:/usr/local/lib/postgresql.jar
|
||||||
|
|
||||||
|
Please don't be tempted to extract the files from the .jar file. There are a
|
||||||
|
lot of files in there, and you may break the Exception handling.
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
USING THE DRIVER
|
USING THE DRIVER
|
||||||
@ -122,6 +140,14 @@ 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
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
1) If you are connecting to localhost or 127.0.0.1 you can leave it out of the
|
||||||
|
URL. ie: jdbc:postgresql://localhost/mydb can be replaced with
|
||||||
|
jdbc:postgresql:mydb
|
||||||
|
|
||||||
|
2) The port defaults to 5432 if it's left out.
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
That's the basics related to this driver. You'll need to read the JDBC Docs
|
That's the basics related to this driver. You'll need to read the JDBC Docs
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
build file to allow ant (http://jakarta.apache.org/ant/) to be used
|
build file to allow ant (http://jakarta.apache.org/ant/) to be used
|
||||||
to build the PostgreSQL JDBC Driver.
|
to build the PostgreSQL JDBC Driver.
|
||||||
|
|
||||||
$Id: build.xml,v 1.2 2000/12/20 16:22:48 peter Exp $
|
$Id: build.xml,v 1.3 2001/01/18 14:50:14 peter Exp $
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
<!-- set global properties for this build -->
|
<!-- set global properties for this build -->
|
||||||
<property name="src" value="." />
|
<property name="src" value="." />
|
||||||
|
<property name="jars" value="jars" />
|
||||||
<property name="dest" value="build" />
|
<property name="dest" value="build" />
|
||||||
<property name="package" value="org/postgresql" />
|
<property name="package" value="org/postgresql" />
|
||||||
<property name="major" value="7" />
|
<property name="major" value="7" />
|
||||||
@ -66,12 +67,14 @@
|
|||||||
<!-- This target removes any class files from the build directory -->
|
<!-- This target removes any class files from the build directory -->
|
||||||
<target name="clean">
|
<target name="clean">
|
||||||
<delete dir="${dest}" />
|
<delete dir="${dest}" />
|
||||||
|
<delete dir="${jars}" />
|
||||||
<delete file="${package}/Driver.java" />
|
<delete file="${package}/Driver.java" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- Prepares the build directory -->
|
<!-- Prepares the build directory -->
|
||||||
<target name="prepare">
|
<target name="prepare">
|
||||||
<mkdir dir="${dest}" />
|
<mkdir dir="${dest}" />
|
||||||
|
<mkdir dir="${jars}" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- This is the core of the driver. It is common for all three versions -->
|
<!-- This is the core of the driver. It is common for all three versions -->
|
||||||
@ -87,12 +90,27 @@
|
|||||||
<copy todir="${dest}" overwrite="true" filtering="on">
|
<copy todir="${dest}" overwrite="true" filtering="on">
|
||||||
<fileset dir="${src}">
|
<fileset dir="${src}">
|
||||||
<include name="**/*.properties" />
|
<include name="**/*.properties" />
|
||||||
|
<exclude name="${dest}/**" />
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<!-- This builds the jar file containing the driver -->
|
||||||
<target name="jar" depends="compile">
|
<target name="jar" depends="compile">
|
||||||
<jar jarfile="postgresql.jar" basedir="${dest}" includes="org/**" />
|
<jar jarfile="${jars}/postgresql.jar" basedir="${dest}" includes="org/**" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
This installs the jar file. It's called by the build.xml file in the
|
||||||
|
root directory of the source (where configure is). Refer to that file
|
||||||
|
on how to use it.
|
||||||
|
-->
|
||||||
|
<target name="install" depends="jar" if="install.directory">
|
||||||
|
<copy todir="${install.directory}" overwrite="true" filtering="off">
|
||||||
|
<fileset dir="${jars}">
|
||||||
|
<include name="**/*.jar" />
|
||||||
|
</fileset>
|
||||||
|
</copy>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
31
src/interfaces/jdbc/jdbc.jpx
Normal file
31
src/interfaces/jdbc/jdbc.jpx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--JBuilder XML Project-->
|
||||||
|
<project>
|
||||||
|
<property category="runtime.0" name="RunnableType" value="com.borland.jbuilder.runtime.ApplicationRunner" />
|
||||||
|
<property category="runtime.0" name="jsprunner.docbase" value="." />
|
||||||
|
<property category="runtime.0" name="jsprunner.jspfile" value="E%|/docs/java/xml/example6" />
|
||||||
|
<property category="sys" name="BackupPath" value="bak" />
|
||||||
|
<property category="sys" name="CheckStable" value="1" />
|
||||||
|
<property category="sys" name="Company" value="" />
|
||||||
|
<property category="sys" name="Copyright" value="Copyright (c) 2001" />
|
||||||
|
<property category="sys" name="DefaultPackage" value="org.postgresql.core" />
|
||||||
|
<property category="sys" name="Description" value="" />
|
||||||
|
<property category="sys" name="DocPath" value="doc" />
|
||||||
|
<property category="sys" name="ExcludeClassEnabled" value="0" />
|
||||||
|
<property category="sys" name="JDK" value="java 1.3.0-C" />
|
||||||
|
<property category="sys" name="LastTag" value="0" />
|
||||||
|
<property category="sys" name="Libraries" value="" />
|
||||||
|
<property category="sys" name="MakeStable" value="0" />
|
||||||
|
<property category="sys" name="OutPath" value="build" />
|
||||||
|
<property category="sys" name="SourcePath" value="." />
|
||||||
|
<property category="sys" name="Title" value="" />
|
||||||
|
<property category="sys" name="Version" value="1.0" />
|
||||||
|
<property category="sys" name="WorkingDirectory" value="." />
|
||||||
|
<node type="Package" name="org.postgresql.core" />
|
||||||
|
<file path="build.xml" />
|
||||||
|
<file path="CHANGELOG" />
|
||||||
|
<file path="Implementation" />
|
||||||
|
<file path="README" />
|
||||||
|
</project>
|
||||||
|
|
@ -10,7 +10,7 @@ import org.postgresql.largeobject.*;
|
|||||||
import org.postgresql.util.*;
|
import org.postgresql.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Id: Connection.java,v 1.11 2000/12/22 03:08:52 momjian Exp $
|
* $Id: Connection.java,v 1.12 2001/01/18 14:50:14 peter Exp $
|
||||||
*
|
*
|
||||||
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
|
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
|
||||||
* JDBC2 versions of the Connection class.
|
* JDBC2 versions of the Connection class.
|
||||||
@ -404,7 +404,9 @@ public abstract class Connection
|
|||||||
// This will let the driver reuse byte arrays that has already
|
// This will let the driver reuse byte arrays that has already
|
||||||
// been allocated instead of allocating new ones in order
|
// been allocated instead of allocating new ones in order
|
||||||
// to gain performance improvements.
|
// to gain performance improvements.
|
||||||
pg_stream.deallocate();
|
// PM 17/01/01: Commented out due to race bug. See comments in
|
||||||
|
// PG_Stream
|
||||||
|
//pg_stream.deallocate();
|
||||||
|
|
||||||
Field[] fields = null;
|
Field[] fields = null;
|
||||||
Vector tuples = new Vector();
|
Vector tuples = new Vector();
|
||||||
@ -871,6 +873,27 @@ public abstract class Connection
|
|||||||
* This is an attempt to implement SQL Escape clauses
|
* This is an attempt to implement SQL Escape clauses
|
||||||
*/
|
*/
|
||||||
public String EscapeSQL(String sql) {
|
public String EscapeSQL(String sql) {
|
||||||
|
//if (DEBUG) { System.out.println ("parseSQLEscapes called"); }
|
||||||
|
|
||||||
|
// If we find a "{d", assume we have a date escape.
|
||||||
|
//
|
||||||
|
// Since the date escape syntax is very close to the
|
||||||
|
// native Postgres date format, we just remove the escape
|
||||||
|
// delimiters.
|
||||||
|
//
|
||||||
|
// This implementation could use some optimization, but it has
|
||||||
|
// worked in practice for two years of solid use.
|
||||||
|
int index = sql.indexOf("{d");
|
||||||
|
while (index != -1) {
|
||||||
|
//System.out.println ("escape found at index: " + index);
|
||||||
|
StringBuffer buf = new StringBuffer(sql);
|
||||||
|
buf.setCharAt(index, ' ');
|
||||||
|
buf.setCharAt(index + 1, ' ');
|
||||||
|
buf.setCharAt(sql.indexOf('}', index), ' ');
|
||||||
|
sql = new String(buf);
|
||||||
|
index = sql.indexOf("{d");
|
||||||
|
}
|
||||||
|
//System.out.println ("modified SQL: " + sql);
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.net.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import org.postgresql.*;
|
import org.postgresql.*;
|
||||||
|
import org.postgresql.core.*;
|
||||||
import org.postgresql.util.*;
|
import org.postgresql.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -430,151 +431,5 @@ public class PG_Stream
|
|||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deallocate all resources that has been associated with any previous
|
|
||||||
* query.
|
|
||||||
*/
|
|
||||||
public void deallocate(){
|
|
||||||
bytePoolDim1.deallocate();
|
|
||||||
bytePoolDim2.deallocate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple and fast object pool implementation that can pool objects
|
|
||||||
* of any type. This implementation is not thread safe, it is up to the users
|
|
||||||
* of this class to assure thread safety.
|
|
||||||
*/
|
|
||||||
class ObjectPool {
|
|
||||||
int cursize = 0;
|
|
||||||
int maxsize = 16;
|
|
||||||
Object arr[] = new Object[maxsize];
|
|
||||||
|
|
||||||
public void add(Object o){
|
|
||||||
if(cursize >= maxsize){
|
|
||||||
Object newarr[] = new Object[maxsize*2];
|
|
||||||
System.arraycopy(arr, 0, newarr, 0, maxsize);
|
|
||||||
maxsize = maxsize * 2;
|
|
||||||
arr = newarr;
|
|
||||||
}
|
|
||||||
arr[cursize++] = o;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object remove(){
|
|
||||||
return arr[--cursize];
|
|
||||||
}
|
|
||||||
public boolean isEmpty(){
|
|
||||||
return cursize == 0;
|
|
||||||
}
|
|
||||||
public int size(){
|
|
||||||
return cursize;
|
|
||||||
}
|
|
||||||
public void addAll(ObjectPool pool){
|
|
||||||
int srcsize = pool.size();
|
|
||||||
if(srcsize == 0)
|
|
||||||
return;
|
|
||||||
int totalsize = srcsize + cursize;
|
|
||||||
if(totalsize > maxsize){
|
|
||||||
Object newarr[] = new Object[totalsize*2];
|
|
||||||
System.arraycopy(arr, 0, newarr, 0, cursize);
|
|
||||||
maxsize = maxsize = totalsize * 2;
|
|
||||||
arr = newarr;
|
|
||||||
}
|
|
||||||
System.arraycopy(pool.arr, 0, arr, cursize, srcsize);
|
|
||||||
cursize = totalsize;
|
|
||||||
}
|
|
||||||
public void clear(){
|
|
||||||
cursize = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple and efficient class to pool one dimensional byte arrays
|
|
||||||
* of different sizes.
|
|
||||||
*/
|
|
||||||
class BytePoolDim1 {
|
|
||||||
int maxsize = 256;
|
|
||||||
ObjectPool notusemap[] = new ObjectPool[maxsize];
|
|
||||||
ObjectPool inusemap[] = new ObjectPool[maxsize];
|
|
||||||
byte binit[][] = new byte[maxsize][0];
|
|
||||||
|
|
||||||
public BytePoolDim1(){
|
|
||||||
for(int i = 0; i < maxsize; i++){
|
|
||||||
binit[i] = new byte[i];
|
|
||||||
inusemap[i] = new ObjectPool();
|
|
||||||
notusemap[i] = new ObjectPool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] allocByte(int size){
|
|
||||||
if(size > maxsize){
|
|
||||||
return new byte[size];
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectPool not_usel = notusemap[size];
|
|
||||||
ObjectPool in_usel = inusemap[size];
|
|
||||||
byte b[] = null;
|
|
||||||
|
|
||||||
if(!not_usel.isEmpty()) {
|
|
||||||
Object o = not_usel.remove();
|
|
||||||
b = (byte[]) o;
|
|
||||||
} else
|
|
||||||
b = new byte[size];
|
|
||||||
in_usel.add(b);
|
|
||||||
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deallocate(){
|
|
||||||
for(int i = 0; i < maxsize; i++){
|
|
||||||
notusemap[i].addAll(inusemap[i]);
|
|
||||||
inusemap[i].clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple and efficient class to pool two dimensional byte arrays
|
|
||||||
* of different sizes.
|
|
||||||
*/
|
|
||||||
class BytePoolDim2 {
|
|
||||||
int maxsize = 32;
|
|
||||||
ObjectPool notusemap[] = new ObjectPool[maxsize];
|
|
||||||
ObjectPool inusemap[] = new ObjectPool[maxsize];
|
|
||||||
|
|
||||||
public BytePoolDim2(){
|
|
||||||
for(int i = 0; i < maxsize; i++){
|
|
||||||
inusemap[i] = new ObjectPool();
|
|
||||||
notusemap[i] = new ObjectPool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[][] allocByte(int size){
|
|
||||||
if(size > maxsize){
|
|
||||||
return new byte[size][0];
|
|
||||||
}
|
|
||||||
ObjectPool not_usel = notusemap[size];
|
|
||||||
ObjectPool in_usel = inusemap[size];
|
|
||||||
|
|
||||||
byte b[][] = null;
|
|
||||||
|
|
||||||
if(!not_usel.isEmpty()) {
|
|
||||||
Object o = not_usel.remove();
|
|
||||||
b = (byte[][]) o;
|
|
||||||
} else
|
|
||||||
b = new byte[size][0];
|
|
||||||
in_usel.add(b);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deallocate(){
|
|
||||||
for(int i = 0; i < maxsize; i++){
|
|
||||||
notusemap[i].addAll(inusemap[i]);
|
|
||||||
inusemap[i].clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
95
src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java
Normal file
95
src/interfaces/jdbc/org/postgresql/core/BytePoolDim1.java
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package org.postgresql.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple and efficient class to pool one dimensional byte arrays
|
||||||
|
* of different sizes.
|
||||||
|
*/
|
||||||
|
public class BytePoolDim1 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum size of the array we manage.
|
||||||
|
*/
|
||||||
|
int maxsize = 256;
|
||||||
|
/**
|
||||||
|
* The pools not currently in use
|
||||||
|
*/
|
||||||
|
ObjectPool notusemap[] = new ObjectPool[maxsize+1];
|
||||||
|
/**
|
||||||
|
* The pools currently in use
|
||||||
|
*/
|
||||||
|
ObjectPool inusemap[] = new ObjectPool[maxsize+1];
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
byte binit[][] = new byte[maxsize][0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new pool
|
||||||
|
*/
|
||||||
|
public BytePoolDim1(){
|
||||||
|
for(int i = 0; i <= maxsize; i++){
|
||||||
|
binit[i] = new byte[i];
|
||||||
|
inusemap[i] = new SimpleObjectPool();
|
||||||
|
notusemap[i] = new SimpleObjectPool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate a byte[] of a specified size and put it in the pool. If it's
|
||||||
|
* larger than maxsize then it is not pooled.
|
||||||
|
* @return the byte[] allocated
|
||||||
|
*/
|
||||||
|
public byte[] allocByte(int size) {
|
||||||
|
// for now until the bug can be removed
|
||||||
|
return new byte[size];
|
||||||
|
/*
|
||||||
|
// Don't pool if >maxsize
|
||||||
|
if(size > maxsize){
|
||||||
|
return new byte[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectPool not_usel = notusemap[size];
|
||||||
|
ObjectPool in_usel = inusemap[size];
|
||||||
|
byte b[] = null;
|
||||||
|
|
||||||
|
// Fetch from the unused pool if available otherwise allocate a new
|
||||||
|
// now array
|
||||||
|
if(!not_usel.isEmpty()) {
|
||||||
|
Object o = not_usel.remove();
|
||||||
|
b = (byte[]) o;
|
||||||
|
} else
|
||||||
|
b = new byte[size];
|
||||||
|
in_usel.add(b);
|
||||||
|
|
||||||
|
return b;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release an array
|
||||||
|
* @param b byte[] to release
|
||||||
|
*/
|
||||||
|
public void release(byte[] b) {
|
||||||
|
// If it's larger than maxsize then we don't touch it
|
||||||
|
if(b.length>maxsize)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ObjectPool not_usel = notusemap[b.length];
|
||||||
|
ObjectPool in_usel = inusemap[b.length];
|
||||||
|
|
||||||
|
in_usel.remove(b);
|
||||||
|
not_usel.add(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocate all
|
||||||
|
* @deprecated Real bad things happen if this is called!
|
||||||
|
*/
|
||||||
|
public void deallocate() {
|
||||||
|
//for(int i = 0; i <= maxsize; i++){
|
||||||
|
// notusemap[i].addAll(inusemap[i]);
|
||||||
|
// inusemap[i].clear();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
62
src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java
Normal file
62
src/interfaces/jdbc/org/postgresql/core/BytePoolDim2.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package org.postgresql.core;
|
||||||
|
|
||||||
|
public class BytePoolDim2 {
|
||||||
|
int maxsize = 32;
|
||||||
|
ObjectPool notusemap[] = new ObjectPool[maxsize+1];
|
||||||
|
ObjectPool inusemap[] = new ObjectPool[maxsize+1];
|
||||||
|
|
||||||
|
public BytePoolDim2(){
|
||||||
|
for(int i = 0; i <= maxsize; i++){
|
||||||
|
inusemap[i] = new SimpleObjectPool();
|
||||||
|
notusemap[i] = new SimpleObjectPool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[][] allocByte(int size){
|
||||||
|
// For now until the bug can be removed
|
||||||
|
return new byte[size][0];
|
||||||
|
/*
|
||||||
|
if(size > maxsize){
|
||||||
|
return new byte[size][0];
|
||||||
|
}
|
||||||
|
ObjectPool not_usel = notusemap[size];
|
||||||
|
ObjectPool in_usel = inusemap[size];
|
||||||
|
|
||||||
|
byte b[][] = null;
|
||||||
|
|
||||||
|
if(!not_usel.isEmpty()) {
|
||||||
|
Object o = not_usel.remove();
|
||||||
|
b = (byte[][]) o;
|
||||||
|
} else
|
||||||
|
b = new byte[size][0];
|
||||||
|
in_usel.add(b);
|
||||||
|
return b;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public void release(byte[][] b){
|
||||||
|
if(b.length > maxsize){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ObjectPool not_usel = notusemap[b.length];
|
||||||
|
ObjectPool in_usel = inusemap[b.length];
|
||||||
|
|
||||||
|
in_usel.remove(b);
|
||||||
|
not_usel.add(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocate the object cache.
|
||||||
|
* PM 17/01/01: Commented out this code as it blows away any hope of
|
||||||
|
* multiple queries on the same connection. I'll redesign the allocation
|
||||||
|
* code to use some form of Statement context, so the buffers are per
|
||||||
|
* Statement and not per Connection/PG_Stream as it is now.
|
||||||
|
*/
|
||||||
|
public void deallocate(){
|
||||||
|
//for(int i = 0; i <= maxsize; i++){
|
||||||
|
// notusemap[i].addAll(inusemap[i]);
|
||||||
|
// inusemap[i].clear();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
18
src/interfaces/jdbc/org/postgresql/core/MemoryPool.java
Normal file
18
src/interfaces/jdbc/org/postgresql/core/MemoryPool.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package org.postgresql.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines the methods to access the memory pool classes.
|
||||||
|
*/
|
||||||
|
public interface MemoryPool {
|
||||||
|
/**
|
||||||
|
* Allocate an array from the pool
|
||||||
|
* @return byte[] allocated
|
||||||
|
*/
|
||||||
|
public byte[] allocByte(int size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees an object back to the pool
|
||||||
|
* @param o Object to release
|
||||||
|
*/
|
||||||
|
public void release(Object o);
|
||||||
|
}
|
48
src/interfaces/jdbc/org/postgresql/core/ObjectPool.java
Normal file
48
src/interfaces/jdbc/org/postgresql/core/ObjectPool.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package org.postgresql.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines methods needed to implement a simple object pool.
|
||||||
|
* There are two known classes that implement this, one for jdk1.1 and the
|
||||||
|
* other for jdk1.2+
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ObjectPool {
|
||||||
|
/**
|
||||||
|
* Adds an object to the pool
|
||||||
|
* @param o Object to add
|
||||||
|
*/
|
||||||
|
public void add(Object o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an object from the pool
|
||||||
|
* @param o Object to remove
|
||||||
|
*/
|
||||||
|
public void remove(Object o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the top object from the pool
|
||||||
|
* @return Object from the top.
|
||||||
|
*/
|
||||||
|
public Object remove();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the pool is empty
|
||||||
|
*/
|
||||||
|
public boolean isEmpty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the number of objects in the pool
|
||||||
|
*/
|
||||||
|
public int size();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all objects in one pool to this one
|
||||||
|
* @param pool The pool to take the objects from
|
||||||
|
*/
|
||||||
|
public void addAll(ObjectPool pool);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the pool of all objects
|
||||||
|
*/
|
||||||
|
public void clear();
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package org.postgresql.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple and fast object pool implementation that can pool objects
|
||||||
|
* of any type. This implementation is not thread safe, it is up to the users
|
||||||
|
* of this class to assure thread safety.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SimpleObjectPool implements ObjectPool
|
||||||
|
{
|
||||||
|
// This was originally in PG_Stream but moved out to fix the major problem
|
||||||
|
// where more than one query (usually all the time) overwrote the results
|
||||||
|
// of another query.
|
||||||
|
int cursize = 0;
|
||||||
|
int maxsize = 16;
|
||||||
|
Object arr[] = new Object[maxsize];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an object to the pool
|
||||||
|
* @param o Object to add
|
||||||
|
*/
|
||||||
|
public void add(Object o)
|
||||||
|
{
|
||||||
|
if(cursize >= maxsize){
|
||||||
|
Object newarr[] = new Object[maxsize*2];
|
||||||
|
System.arraycopy(arr, 0, newarr, 0, maxsize);
|
||||||
|
maxsize = maxsize * 2;
|
||||||
|
arr = newarr;
|
||||||
|
}
|
||||||
|
arr[cursize++] = o;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the top object from the pool
|
||||||
|
* @return Object from the top.
|
||||||
|
*/
|
||||||
|
public Object remove(){
|
||||||
|
return arr[--cursize];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the given object from the pool
|
||||||
|
* @param o Object to remove
|
||||||
|
*/
|
||||||
|
public void remove(Object o) {
|
||||||
|
int p=0;
|
||||||
|
while(p<cursize && !arr[p].equals(o))
|
||||||
|
p++;
|
||||||
|
if(arr[p].equals(o)) {
|
||||||
|
// This should be ok as there should be no overlap conflict
|
||||||
|
System.arraycopy(arr,p+1,arr,p,cursize-p);
|
||||||
|
cursize--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the pool is empty
|
||||||
|
*/
|
||||||
|
public boolean isEmpty(){
|
||||||
|
return cursize == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the number of objects in the pool
|
||||||
|
*/
|
||||||
|
public int size(){
|
||||||
|
return cursize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all objects in one pool to this one
|
||||||
|
* @param pool The pool to take the objects from
|
||||||
|
*/
|
||||||
|
public void addAll(ObjectPool p){
|
||||||
|
SimpleObjectPool pool = (SimpleObjectPool)p;
|
||||||
|
|
||||||
|
int srcsize = pool.size();
|
||||||
|
if(srcsize == 0)
|
||||||
|
return;
|
||||||
|
int totalsize = srcsize + cursize;
|
||||||
|
if(totalsize > maxsize){
|
||||||
|
Object newarr[] = new Object[totalsize*2];
|
||||||
|
System.arraycopy(arr, 0, newarr, 0, cursize);
|
||||||
|
maxsize = maxsize = totalsize * 2;
|
||||||
|
arr = newarr;
|
||||||
|
}
|
||||||
|
System.arraycopy(pool.arr, 0, arr, cursize, srcsize);
|
||||||
|
cursize = totalsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the pool of all objects
|
||||||
|
*/
|
||||||
|
public void clear(){
|
||||||
|
cursize = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,8 @@ postgresql.geo.point:Conversion of point failed - {0}
|
|||||||
postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding. If that fails, try forcing the version supplying it to the command line using the argument -Djava.version=1.1 or -Djava.version=1.2\nException thrown was {0}
|
postgresql.jvm.version:The postgresql.jar file does not contain the correct JDBC classes for this JVM. Try rebuilding. If that fails, try forcing the version supplying it to the command line using the argument -Djava.version=1.1 or -Djava.version=1.2\nException thrown was {0}
|
||||||
postgresql.lo.init:failed to initialise LargeObject API
|
postgresql.lo.init:failed to initialise LargeObject API
|
||||||
postgresql.money:conversion of money failed - {0}.
|
postgresql.money:conversion of money failed - {0}.
|
||||||
|
postgresql.noupdate:This ResultSet is not updateable
|
||||||
|
postgresql.psqlnotimp:The backend currently does not support this feature.
|
||||||
postgresql.prep.is:InputStream as parameter not supported
|
postgresql.prep.is:InputStream as parameter not supported
|
||||||
postgresql.prep.param:No value specified for parameter {0}.
|
postgresql.prep.param:No value specified for parameter {0}.
|
||||||
postgresql.prep.range:Parameter index out of range.
|
postgresql.prep.range:Parameter index out of range.
|
||||||
|
@ -266,6 +266,8 @@ public class Statement implements java.sql.Statement
|
|||||||
*/
|
*/
|
||||||
public boolean execute(String sql) throws SQLException
|
public boolean execute(String sql) throws SQLException
|
||||||
{
|
{
|
||||||
|
if(escapeProcessing)
|
||||||
|
sql=connection.EscapeSQL(sql);
|
||||||
result = connection.ExecSQL(sql);
|
result = connection.ExecSQL(sql);
|
||||||
return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
|
return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet());
|
||||||
}
|
}
|
||||||
|
@ -888,12 +888,14 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
public void cancelRowUpdates() throws SQLException
|
public void cancelRowUpdates() throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// only sub-classes implement CONCUR_UPDATEABLE
|
||||||
|
notUpdateable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteRow() throws SQLException
|
public void deleteRow() throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// only sub-classes implement CONCUR_UPDATEABLE
|
||||||
|
notUpdateable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean first() throws SQLException
|
public boolean first() throws SQLException
|
||||||
@ -917,7 +919,11 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException
|
public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
try {
|
||||||
|
return new BigDecimal(getDouble(columnIndex));
|
||||||
|
} catch(NumberFormatException nfe) {
|
||||||
|
throw new PSQLException("postgresql.res.badbigdec",nfe.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException
|
public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException
|
||||||
@ -942,7 +948,15 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
public java.io.Reader getCharacterStream(int i) throws SQLException
|
public java.io.Reader getCharacterStream(int i) throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// New in 7.1
|
||||||
|
try {
|
||||||
|
String encoding = connection.getEncoding();
|
||||||
|
if(encoding==null)
|
||||||
|
return new InputStreamReader(getBinaryStream(i));
|
||||||
|
return new InputStreamReader(getBinaryStream(i),encoding);
|
||||||
|
} catch (UnsupportedEncodingException unse) {
|
||||||
|
throw new PSQLException("postgresql.res.encoding", unse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Clob getClob(String columnName) throws SQLException
|
public Clob getClob(String columnName) throws SQLException
|
||||||
@ -957,22 +971,34 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
public int getConcurrency() throws SQLException
|
public int getConcurrency() throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// New in 7.1 - The standard ResultSet class will now return
|
||||||
|
// CONCUR_READ_ONLY. A sub-class will overide this if the query was
|
||||||
|
// updateable.
|
||||||
|
return CONCUR_READ_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public java.sql.Date getDate(int i,java.util.Calendar cal) throws SQLException
|
public java.sql.Date getDate(int i,java.util.Calendar cal) throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// new in 7.1: If I read the specs, this should use cal only if we don't
|
||||||
|
// store the timezone, and if we do, then act just like getDate()?
|
||||||
|
// for now...
|
||||||
|
return getDate(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Time getTime(int i,java.util.Calendar cal) throws SQLException
|
public Time getTime(int i,java.util.Calendar cal) throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// new in 7.1: If I read the specs, this should use cal only if we don't
|
||||||
|
// store the timezone, and if we do, then act just like getTime()?
|
||||||
|
// for now...
|
||||||
|
return getTime(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getTimestamp(int i,java.util.Calendar cal) throws SQLException
|
public Timestamp getTimestamp(int i,java.util.Calendar cal) throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// new in 7.1: If I read the specs, this should use cal only if we don't
|
||||||
|
// store the timezone, and if we do, then act just like getDate()?
|
||||||
|
// for now...
|
||||||
|
return getTimestamp(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public java.sql.Date getDate(String c,java.util.Calendar cal) throws SQLException
|
public java.sql.Date getDate(String c,java.util.Calendar cal) throws SQLException
|
||||||
@ -992,17 +1018,16 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
public int getFetchDirection() throws SQLException
|
public int getFetchDirection() throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// new in 7.1: PostgreSQL normally sends rows first->last
|
||||||
|
return FETCH_FORWARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFetchSize() throws SQLException
|
public int getFetchSize() throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// new in 7.1: In this implementation we return the entire result set, so
|
||||||
}
|
// here return the number of rows we have. Sub-classes can return a proper
|
||||||
|
// value
|
||||||
public int getKeysetSize() throws SQLException
|
return rows.size();
|
||||||
{
|
|
||||||
throw org.postgresql.Driver.notImplemented();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getObject(String columnName,java.util.Map map) throws SQLException
|
public Object getObject(String columnName,java.util.Map map) throws SQLException
|
||||||
@ -1010,9 +1035,23 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
return getObject(findColumn(columnName),map);
|
return getObject(findColumn(columnName),map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This checks against map for the type of column i, and if found returns
|
||||||
|
* an object based on that mapping. The class must implement the SQLData
|
||||||
|
* interface.
|
||||||
|
*/
|
||||||
public Object getObject(int i,java.util.Map map) throws SQLException
|
public Object getObject(int i,java.util.Map map) throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
/* In preparation
|
||||||
|
SQLInput s = new PSQLInput(this,i);
|
||||||
|
String t = getTypeName(i);
|
||||||
|
SQLData o = (SQLData) map.get(t);
|
||||||
|
// If the type is not in the map, then pass to the existing code
|
||||||
|
if(o==null)
|
||||||
|
return getObject(i);
|
||||||
|
o.readSQL(s,t);
|
||||||
|
return o;
|
||||||
|
*/throw org.postgresql.Driver.notImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ref getRef(String columnName) throws SQLException
|
public Ref getRef(String columnName) throws SQLException
|
||||||
@ -1022,7 +1061,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
public Ref getRef(int i) throws SQLException
|
public Ref getRef(int i) throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// new in 7.1: The backend doesn't yet have SQL3 REF types
|
||||||
|
throw new PSQLException("postgresql.psqlnotimp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRow() throws SQLException
|
public int getRow() throws SQLException
|
||||||
@ -1033,12 +1073,15 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
// This one needs some thought, as not all ResultSets come from a statement
|
// This one needs some thought, as not all ResultSets come from a statement
|
||||||
public java.sql.Statement getStatement() throws SQLException
|
public java.sql.Statement getStatement() throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType() throws SQLException
|
public int getType() throws SQLException
|
||||||
{
|
{
|
||||||
throw org.postgresql.Driver.notImplemented();
|
// New in 7.1. This implementation allows scrolling but is not able to
|
||||||
|
// see any changes. Sub-classes may overide this to return a more
|
||||||
|
// meaningful result.
|
||||||
|
return TYPE_SCROLL_INSENSITIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertRow() throws SQLException
|
public void insertRow() throws SQLException
|
||||||
@ -1352,5 +1395,20 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
updateTimestamp(findColumn(columnName),x);
|
updateTimestamp(findColumn(columnName),x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper method. Throws an SQLException when an update is not possible
|
||||||
|
public void notUpdateable() throws SQLException
|
||||||
|
{
|
||||||
|
throw new PSQLException("postgresql.noupdate");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called by Statement to register itself with this statement.
|
||||||
|
* It's used currently by getStatement() but may also with the new core
|
||||||
|
* package.
|
||||||
|
*/
|
||||||
|
public void setStatement(org.postgresql.Statement statement) {
|
||||||
|
this.statement=statement;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class PSQLException extends SQLException
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expand any arguments
|
// Expand any arguments
|
||||||
if(args!=null)
|
if(args!=null && message != null)
|
||||||
message = MessageFormat.format(message,args);
|
message = MessageFormat.format(message,args);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user