|
| 1 | +This is a simple readme describing how to compile and use the jdbc driver. |
| 2 | + |
| 3 | +This isn't a guide on how to use JDBC - for that refer to Javasoft's web site: |
| 4 | + |
| 5 | + http://www.javasoft.com |
| 6 | + |
| 7 | +or the JDBC mailing list: |
| 8 | + |
| 9 | + jdbc@java.blackdown.org |
| 10 | + |
| 11 | + http://www.blackdown.org |
| 12 | + |
| 13 | +--------------------------------------------------------------------------- |
| 14 | + |
| 15 | +COMPILING |
| 16 | + |
| 17 | +To compile the driver, simply use make in the src/interfaces/jdbc directory. |
| 18 | +This will compile the driver, and build a .jar file (Java ARchive). |
| 19 | + |
| 20 | +REMEMBER: once you have compiled the driver, it will work on ALL platforms |
| 21 | +that support the JDK 1.1 api or later. |
| 22 | + |
| 23 | +That means you don't have to compile it on every platform. Believe me, I |
| 24 | +still hear from people who ask me "I've compiled it ok under Solaris, but it |
| 25 | +won't compile under Linux" - there's no difference. |
| 26 | + |
| 27 | +PS: When you run make, don't worry if you see just one or two calls to javac. |
| 28 | + If, while compiling a class, javac needs another class that's not compiled, |
| 29 | + it will compile it automatically. This reduces the numer of calls to javac |
| 30 | + that make has to do. |
| 31 | + |
| 32 | +--------------------------------------------------------------------------- |
| 33 | + |
| 34 | +INSTALLING THE DRIVER |
| 35 | + |
| 36 | +To install the driver, the .class files have to be in the classpath. This can be |
| 37 | +done in two ways: |
| 38 | + |
| 39 | +1: create a directory "postgresql" (and it must be called this) in the current |
| 40 | + directory (or a directory in the class path), and copy all .class files |
| 41 | + into it. |
| 42 | + |
| 43 | +2: copy the postgres.jar file into a directory, and add it to the classpath. |
| 44 | + |
| 45 | + ie: under LINUX/SOLARIS (the example here is my linux box): |
| 46 | + |
| 47 | + export CLASSPATH=.:/usr/local/lib/postgresql.jar:/usr/local/jdk1.1.1/lib/classes.zip |
| 48 | + |
| 49 | + note: in java, .zip and .jar files hold collections of classes. |
| 50 | + |
| 51 | +--------------------------------------------------------------------------- |
| 52 | + |
| 53 | +USING THE DRIVER |
| 54 | + |
| 55 | +To use the driver, you must introduce it to JDBC. Again, there's two ways |
| 56 | +of doing this: |
| 57 | + |
| 58 | +1: Hardcoded. |
| 59 | + |
| 60 | + This method hardcodes your driver into your application/applet. You |
| 61 | + introduce the driver using the following snippet of code: |
| 62 | + |
| 63 | + try { |
| 64 | + Class.forName("postgresql.Driver"); |
| 65 | + } catch(Exception e) { |
| 66 | + // your error handling code goes here |
| 67 | + } |
| 68 | + |
| 69 | + Remember, this method restricts your code to just the postgresql database. |
| 70 | + |
| 71 | +2: Parameters |
| 72 | + |
| 73 | + This method specifies the driver from the command line. When running the |
| 74 | + application, you specify the driver using the option: |
| 75 | + |
| 76 | + -Djdbc.drivers=postgresql.Driver |
| 77 | + |
| 78 | + eg: This is an example of running one of my other projects with the driver: |
| 79 | + |
| 80 | + java -Djdbc.drivers=postgresql.Driver finder.finder |
| 81 | + |
| 82 | + note: This method only works with Applications (not for Applets). |
| 83 | + However, the application is not tied to one driver, so if you needed |
| 84 | + to switch databases (why I don't know ;-) ), you don't need to |
| 85 | + recompile the application (as long as you havent hardcoded the url's). |
| 86 | + |
| 87 | +--------------------------------------------------------------------------- |
| 88 | + |
| 89 | +JDBC URL syntax |
| 90 | + |
| 91 | +The driver recognises JDBC URL's of the form: |
| 92 | + |
| 93 | + jdbc:postgresql:database |
| 94 | + |
| 95 | + jdbc:postgresql://host/database |
| 96 | + |
| 97 | + jdbc:postgresql://host:port/database |
| 98 | + |
| 99 | +Also, you can supply both username and passwords as arguments, by appending |
| 100 | +them to the URL. eg: |
| 101 | + |
| 102 | + jdbc:postgresql:database?user=me |
| 103 | + jdbc:postgresql:database?user=me&password=mypass |
| 104 | + |
| 105 | +--------------------------------------------------------------------------- |
| 106 | + |
| 107 | +That's the basics related to this driver. You'll need to read the JDBC Docs |
| 108 | +on how to use it. |
| 109 | + |
| 110 | +POSTGRESQL SPECIFICS |
| 111 | +-------------------- |
| 112 | + |
| 113 | +JDBC supports database specific data types using the getObject() call. The |
| 114 | +following types have their own Java equivalents supplied by the driver: |
| 115 | + |
| 116 | + box, circle, lseg, path, point, polygon |
| 117 | + |
| 118 | +When using the getObject() method on a resultset, it returns a PG_Object, |
| 119 | +which holds the postgres type, and its value. This object also supports |
| 120 | +methods to retrive these types. |
| 121 | + |
| 122 | + Eg: column 3 contains a point, and rs is the ResultSet: |
| 123 | + |
| 124 | + PG_Object o = (PG_Object)rs.getObject(3); |
| 125 | + PGpoint p = o.getPoint(); |
| 126 | + System.out.println("point returned x="+p.x+", y="+p.y); |
| 127 | + |
| 128 | +Also, when using these classes, their toString() methods return the correct |
| 129 | +syntax for writing these to the database. |
| 130 | + |
| 131 | +TODO |
| 132 | +---- |
| 133 | + |
| 134 | +Currently only host authentication is supported. Password authentication |
| 135 | +will be in there in a few days. |
| 136 | + |
| 137 | +Incorporating more features from the other driver (esp. in the MetaData's) |
| 138 | + |
| 139 | +Large Object support will also go in there, although it may not be done as |
| 140 | +pure JDBC, but as an extra API. |
| 141 | + |
| 142 | +Producing some documentation with javadoc - not all of the sources have them |
| 143 | +yet. |
| 144 | + |
| 145 | +--------------------------------------------------------------------------- |
| 146 | + |
| 147 | +Peter T Mount, August 30 1997 |
| 148 | +home email: pmount@maidast.demon.co.uk http://www.demon.co.uk/finder |
| 149 | +work email: peter@maidstone.gov.uk http://www.maidstone.gov.uk |
| 150 | + |
| 151 | +Adrian Hall |
| 152 | + email: adrian@hottub.org |
0 commit comments