How to use jdbc?

Adrian Custer acuster@nature.berkeley.edu
Sat Jul 28 13:50:00 GMT 2001


Hey everyone, 

...continuing this converstaion on the list...

I'm using gcj to compile a program to access a postgresql database. For
the moment the database is on this same machine but this should work
across the network since java can only use network sockets.

I'm on mandrake 8.0++ (cooker). The distribution has a number of
postgresql rpm's including the jdbc so I don't actually know how hard it
is to compile. The jdbc rpm includes a critical java archive. In the
PosgreSQL JDBC documentation, this is called postgresql.jar (e.g.
http://jdbc.postgresql.org/docs/ ) but in Mandrake that file is
jdbc7.0-1.2.jar which is found in the directory /usr/share/pgsql/. 

I copied that file into the directory where my java code was and ran the
following:
gcj --main=DatabaseTester -o DatabaseTester jdbc7.0-1.2.jar
DatabaseTester.java
	(grr. Evolution wraps that line.)
The code file is an attachment to a previous post. I suspect that I
could simply have setup the classpath variable to find the file but I've
never understood the classpath variable cleanly. 

(For anyone, checking this against a blackdown java setup, to use the
javac compiler, put the jdbc7.0-1.2.jar in the ext/ folder as in:
/usr/local/j2sdk1.3.0/jre/lib/ext/jdbc7.0-1.2.jar
)

That's all. It's actually quite clean. I use a Makefile that looks like
this:

#A makefile for both gcj and javc
gcj:
        gcj --main=DatabaseTester -o DatabaseTester jdbc7.0-1.2.jar
DatabaseTester.java 
# The above should be a single line, evolution is word wrapping it.

gcjrun:
        ./DatabaseTester

gcjdoc:
        doxygen docs/

clean:
        rm -f *.class *~ \#*\# DatabaseTester.java

javac:
        /usr/local/j2sdk1.3.0/bin/javac DatabaseTester.java

java:
        /usr/local/j2sdk1.3.0/bin/java  DatabaseTester 
#end of makefile.

I hope that helps anyone who is interested in playing with this.

cheers,
adrian


On 28 Jul 2001 14:19:26 -0600, Tom Tromey wrote:
> >>>>> "Adrian" == Adrian Vance Custer <acuster@nopause.berkeley.edu> writes:
> 
> Adrian> Beautiful! Another late night hiccup. This is really good
> Adrian> news, first that gcj supports jdbc and second that it does so
> Adrian> this transparently.
> 
> You're using it with Postgresql?
> Was it hard to build the Postgres JDBC library?
> Let us know how it works out for you.
> I don't know how much the java.sql in libgcj has been tested.
> I'm definitely interested in how well it works, and also how well it
> interacts with Postgres.
> 
> Tom
> 




More information about the Java mailing list