Quantcast
Channel: Planet PostgreSQL
Viewing all articles
Browse latest Browse all 9645

Johann Oskarsson: PostgreSQL JDBC with GCJ

$
0
0
It is fairly easy to use the PostgreSQL JDBC driver with GCJ.

As of GCC 4.1 (used in this example) it does not compile the JDBC 4 driver, so JDBC 3 was used.

Step 1: Download the JDBC 3 driver from the PostgreSQL JDBC website.

Step 2: Compile the jar file:
gcj -c postgresql-9.1-901.jdbc3.jar

Step 3: In the application, load the driver with
Class.forName( "org.postgresql.Driver" );
Note that this is not needed when using the JDBC 4 driver with Oracle Java or OpenJDK.

Step 4: Compile the application
gcj -c Hello.java

Step 5: Link the object files with postgresql-9.1-901.jdbc3.o:
gcj -o hello --main=Hello Hello.o postgresql-9.1-901.jdbc3.o

The example application does nothing but print out the connection object to demonstrate it was able to connect to the database. If it does not connect an exception is thrown which prints a stack trace instead.

Downloads


Viewing all articles
Browse latest Browse all 9645

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>