Re: JDBC Connection

From: "Nick Fankhauser" <nickf(at)ontko(dot)com>
To: "Guido" <lampo(dot)14(at)iol(dot)it>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC Connection
Date: 2001-11-10 12:48:55
Message-ID: NEBBLAAHGLEEPCGOBHDGOEHNDOAA.nickf@ontko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Guido-

I probably didn't say this clearly enough, or perhaps "environment" is the
wrong word, so I'll try to explain what I meant with an example:

In the project I'm working on, we're using Tomcat, so I develop using my
user account, but run as Tomcat's user.

When I'm actually writing & compiling the code, I'm working from my own user
account (nickf), so in the .profile for nickf I add the path to the jdbc jar
like so: "export CLASSPATH=$CLASSPATH:/usr/share/java/jdbc7.1-1.2.jar". This
works great for compiling and running any "main" test classes at the command
line, but my purpose is to produce code that Tomcat will run, and therein
lies the twist...

The Tomcat processes are started as detached processes by the "www-data"
user account on our system, so the change that I made to the CLASSPATH
environment variable for "nickf" doesn't help. In order to make the classes
work under this user, I have to do one of three things:

1)Add the classpath line that I used for "nickf" to the .profile for
"www-data"

2)Add the jar file to the classpath in the shell script that starts up
Tomcat

3)As Dave suggested, put it in the standard java extensions directory for
the system, so it is available to any user account by default.

I may be totally off base here, but it sounds very much like this is the
problem that is plaguing you with Forte- If a different user account is
running the code after you get it out of Forte, then you may lose the
CLASSPATH that you set.

The other thing that may be happening is that the CLASSPATH variable may not
be used by your JRE. It might help to look under the hood at the shell
script that invokes the JRE to see what is happening- the command to invoke
the JRE has a switch to set the classpath on it, and by convention, most
systems just equate this to CLASSPATH, but they don't have to. See if you
can locate the shell file (or .bat file) that invokes your JRE- it should
have a line that looks something like this:

java -cp $CLASSPATH <class file>

The problem of course, would be if the "CLASSPATH" variable either isn't
being used, or is being changed before this line is run. The only way I can
thin of to check this would be to find the shell script in question. Maybe
if you tell us what platform you're running on, someone who is familiar with
it can help.

Sorry- this response got rather long-winded- Hope it helps.

-Nick

> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Guido
> Sent: Friday, November 09, 2001 11:42 AM
> To: pgsql-jdbc(at)postgresql(dot)org
> Subject: Re: [JDBC] JDBC Connection
>
>
> First of all I'd like to thank everybody for the "pronto" help.
> But the problem is that
> 1. My shell doesn't have an enviroment variable called CLASSPATH;
> 2. I, then, tried to edit my .profile file, by adding the variable to it,
> i.e.
> CLASSPATH=/usr/java/jdk1.3.1_01/lib/jdbc7.1-1.2.jar
> export PATH CLASSPATH
> but, still doesn't work.
> 3. When I run the application in the Forte 3 enviroment, it works
> perfectly, but that becuase the IDE requires to copy the driver to the
> IDE's directory.
> 4. I use the same enviroment for developing and running the application.
> Thanks again.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Antonio Fiol Bonnín 2001-11-10 15:08:46 Re: Storing a tree
Previous Message postgres 2001-11-10 12:32:16 GCJ and JDBC Driver