diff options
author | Peter Mount <peter@retep.org.uk> | 2000-10-12 08:55:28 +0000 |
---|---|---|
committer | Peter Mount <peter@retep.org.uk> | 2000-10-12 08:55:28 +0000 |
commit | f41dcbe4d810f0906f43d1b345cf506d72c792ac (patch) | |
tree | 797e86d7fb86667e9b89595bb2f722b8018c39c6 /src/interfaces/jdbc/utils/CheckVersion.java | |
parent | f20d2a87fb46284d9aca549321c407f00451f849 (diff) | |
download | postgresql-f41dcbe4d810f0906f43d1b345cf506d72c792ac.tar.gz postgresql-f41dcbe4d810f0906f43d1b345cf506d72c792ac.zip |
Major update part I involving delayed patches, reworked Makefile, and how
the versioning works. There's also a new utils directory used by Makefile
Diffstat (limited to 'src/interfaces/jdbc/utils/CheckVersion.java')
-rw-r--r-- | src/interfaces/jdbc/utils/CheckVersion.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/interfaces/jdbc/utils/CheckVersion.java b/src/interfaces/jdbc/utils/CheckVersion.java new file mode 100644 index 00000000000..b82ba335fd3 --- /dev/null +++ b/src/interfaces/jdbc/utils/CheckVersion.java @@ -0,0 +1,68 @@ +package utils; + +/** + * This little app checks to see what version of JVM is being used. + * It does this by checking first the java.vm.version property, and + * if that fails, it looks for certain classes that should be present. + */ +public class CheckVersion +{ + /** + * Check for the existence of a class by attempting to load it + */ + public static boolean checkClass(String c) { + try { + Class.forName(c); + } catch(Exception e) { + return false; + } + return true; + } + + /** + * This first checks java.vm.version for 1.1, 1.2 or 1.3. + * + * It writes jdbc1 to stdout for the 1.1.x VM. + * + * For 1.2 or 1.3, it checks for the existence of the javax.sql.DataSource + * interface, and if found writes enterprise to stdout. If the interface + * is not found, it writes jdbc2 to stdout. + * + * PS: It also looks for the existence of java.lang.Byte which appeared in + * JDK1.1.0 incase java.vm.version is not heeded by some JVM's. + * + * If it can't work it out, it writes huho to stdout. + * + * The make file uses the written results to determine which rule to run. + * + * Bugs: This needs thorough testing. + */ + public static void main(String args[]) + { + String vmversion = System.getProperty("java.vm.version"); + + // We are running a 1.1 JVM + if(vmversion.startsWith("1.1")) { + System.out.println("jdbc1"); + System.exit(0); + } + + // We are running a 1.2 or 1.3 JVM + if(vmversion.startsWith("1.2") || + vmversion.startsWith("1.3") || + checkClass("java.lang.Byte") + ) { + + // Check to see if we have the standard extensions. If so, then + // we want the enterprise edition, otherwise the jdbc2 driver. + if(checkClass("javax.sql.DataSource")) + System.out.println("enterprise"); + else + System.out.println("jdbc2"); + System.exit(0); + } + + System.out.println("huho"); + System.exit(0); + } +} |