Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

accessing ojdbc14.jar from a servlet?

 
Ranch Hand
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 56
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Trust God, but always tether your camel... to this tiny ad.
ScroogeXHTML 9.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/731949/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic