aspose file tools*
The moose likes JDBC and the fly likes accessing ojdbc14.jar from a servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "accessing ojdbc14.jar from a servlet?" Watch "accessing ojdbc14.jar from a servlet?" New topic
Author

accessing ojdbc14.jar from a servlet?

eileen keeney
Ranch Hand

Joined: May 04, 2009
Posts: 51
Because a servlet can not see the CLASSPATH I can not figure out how to get it to see the libraries inside the ojdbc14.jar library file.

It does NOT solve the problem, to just put that file in the classes directory, directly under the WEB-INF.

Running a test (outside the servlet) if I empty the classpath
i.e.
issue at the prompt
CLASSPATH=
so it is empty,
The test code fails to find the needed db driver as well.
If I do this:
CLASSPATH=.
It still fails to find the needed db drivers, although the jar file is in the current directory.

However if I do this:
CLASSPATH=.:ojdbc14.jar (with the ojdbc14.jar file in the current path, which is ../WEB-INF/classes/)

my test program (non servlet program) has no trouble finding the needed library and connecting to the database.

This tells me that I need to explicitly have the ojdbc14.jar in my CLASSPATH (not just the directory it resides in).

But a servlet can not read the CLASSPATH.
So how do I get the servlet to find the ojdbc14.jar libraries?


Is there a way, within Java, while it is running, to set an environment variable.
I didn't have much luck calling a ksh program, to set it either. (doesn't like to . the ksh program, although it can run ksh programs directly, but this does not get the environment up to the parent process. Maybe I could write a better system call routine that did this.)

But I am thinking that I can not be the only one trying to run a servlet that access an Oracle database, so someone must have figured out how to get it to find the needed driver library.

Thank you


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18564
    
    8

eileen keeney wrote:Because a servlet can not see the CLASSPATH I can not figure out how to get it to see the libraries inside the ojdbc14.jar library file.

It does NOT solve the problem, to just put that file in the classes directory, directly under the WEB-INF.


No, it doesn't. That's because the rule is that you put dependent jars in the lib directory, directly under WEB-INF.
eileen keeney
Ranch Hand

Joined: May 04, 2009
Posts: 51
That worked.

So any jar files, go in the lib directory

So my javax.servlet.* stuff must not be needed at runtime, but only at compile time, because it is not in the lib directory.
When I did find it, I added the directory to my CLASSPATH in my .profile; and that worked).

Any methods I create, go into a class, that goes into a package, and that goes into the classes directory
(This also has to be in my CLASSPATH, because at compile time, it needs it there, although at runtime, it ignores the CLASSPATH.)

Some stuff it needs only at compile time, and other stuff at both compile time and runtime?

Anway,
Thanks, I really appreciate your help, it is probably saving me many hours of reading articles and trying stuff out.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: accessing ojdbc14.jar from a servlet?