LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-12-2009, 09:34 AM   #1
cov
Member
 
Registered: Apr 2005
Location: Durban
Posts: 433

Rep: Reputation: 30
Query a postgres database with Java


Hi,

I'm trying to do what it says on the tin. (Query a postgres database with Java). On a Debian Lenny box.

I've installed the java and have these 2 directories in
Code:
ls /usr/lib/jvm/
java-1.5.0-gcj-4.3-1.5.0.0  java-gcj
Java is set up thus:
Code:
ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2009-12-12 13:10 /usr/bin/java -> /etc/alternatives/java
Which, if I run it gives this:
Code:
 java
Usage: gij [OPTION] ... CLASS [ARGS] ...
          to invoke CLASS.main, or
       gij -jar [OPTION] ... JARFILE [ARGS] ...
          to execute a jar file
Try `gij --help' for more information.
I have followed the directions here:
http://www.fankhausers.com/postgresql/jdbc/ but when I try to run the demo program I get the following errors:

Code:
java hellopostgres.java 
Exception in thread "main" java.lang.NoClassDefFoundError: hellopostgres.java
   at gnu.java.lang.MainThread.run(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: hellopostgres.java not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/usr/share/java/postgresql-jdbc3-8.2.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.90)
   at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
   at java.lang.ClassLoader.loadClass(libgcj.so.90)
   at java.lang.ClassLoader.loadClass(libgcj.so.90)
   at gnu.java.lang.MainThread.run(libgcj.so.90)
My Postgres version would appear to be 8.3.:
Code:
 psql --version
psql (PostgreSQL) 8.3.8
contains support for command-line editing
Does anyone have any suggestions?

I have visited Sun's dowload site and downloaded jdk-1.6.bin which I've run but which just extracted out to a directory jdk1.6.0_17 which I've placed in /usr/lib/jvm but which needs to be configured (obviously through /etc/alternatives if I can work it out).

I've done a fair bit of googling which seems to suggest that incompatibilities in the gij which might be causing it.
 
Old 12-12-2009, 10:29 AM   #2
cov
Member
 
Registered: Apr 2005
Location: Durban
Posts: 433

Original Poster
Rep: Reputation: 30
Hell!

No wonder I'm having difficulty, I've just noticed the bloody article I'm using is dated 2003.

:?

The 'net is littered with all these howtos that are out of date. </rant>

Can anyone recomend a reasonably up-to-date?

I'm trying to feed an excel worksheet into a postgres database using hssf/poi which are java apps, which is why I need Java to connect to the Postgres JDBC.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripts updating a postgres database ethnicme Programming 1 07-15-2006 11:21 AM
create table in postgres database kranti Linux - Newbie 1 11-15-2005 07:52 PM
Problem with Postgres Database Connection anjani.78 Linux - Software 1 10-07-2005 03:06 AM
changing password for postgres database anjani.78 Linux - Software 1 07-18-2005 11:58 PM
Connecting a Postgres Database from a Java application Paulo Ges Programming 4 08-23-2003 11:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration