diff options
author | Bruce Momjian <bruce@momjian.us> | 1999-01-17 04:51:59 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1999-01-17 04:51:59 +0000 |
commit | 298682d9e0b0ec55d5f72cec1f4d43c23f2a1ac6 (patch) | |
tree | 57f9d4552366b3f9fe9552aafe47505ff61b14ac /src/interfaces/jdbc/postgresql/Driver.java | |
parent | 4a6285ee445efc13f0e726be1629762ff366e602 (diff) | |
download | postgresql-298682d9e0b0ec55d5f72cec1f4d43c23f2a1ac6.tar.gz |
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
Diffstat (limited to 'src/interfaces/jdbc/postgresql/Driver.java')
-rw-r--r-- | src/interfaces/jdbc/postgresql/Driver.java | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/interfaces/jdbc/postgresql/Driver.java b/src/interfaces/jdbc/postgresql/Driver.java index 90563d5460..b3cc57f4f2 100644 --- a/src/interfaces/jdbc/postgresql/Driver.java +++ b/src/interfaces/jdbc/postgresql/Driver.java @@ -27,8 +27,11 @@ public class Driver implements java.sql.Driver // These should be in sync with the backend that the driver was // distributed with static final int MAJORVERSION = 6; - static final int MINORVERSION = 4; - + static final int MINORVERSION = 5; + + // Cache the version of the JDK in use + static String connectClass; + static { try { @@ -49,6 +52,13 @@ public class Driver implements java.sql.Driver */ 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 if((props = parseURL(url,info))==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 { 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."); + } } |