File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Oracle Connection from class used by Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Oracle Connection from class used by Servlet" Watch "Oracle Connection from class used by Servlet" New topic
Author

Oracle Connection from class used by Servlet

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Hi, I have a servlet that calls a method on a seperate plain Java class. This class creates a connection and a statement with Oracle. I have the Class.forName method to get the connection.
When I run this class by itself, it makes the connection, but once I put it into my tomcat webapp directory, it no longer works and I get Exceptions through Tomcat.
I moved my Oracle driver classes to the c:\tomcat\webapps\web-inf\classes directory. Is this correct?
I am also looking at the logs, so I can get the long exception that I can't see in my Win 98 Dos Window because it doesn't scroll back.
What is the log file name that I would look for?
Thanks
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

I don't know for sure, but try putting the driver in the JVM's classpath, when Tomcat start's up -- that's how our HP App Server picks things up.
As for the CommandLine window, increase the buffer size, so you cans scroll back and see what exceptions you get.
Right click on the window, click properties, in the Layout tab, increase the screen buffer size to 300 or maybe 500.


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Regus Patoff
Greenhorn

Joined: Oct 30, 2001
Posts: 8
If you are using classes12.zip (or a similarly named zip file) for the oracle class files,copy it and rename it to classes12.jar and put it in the common/lib directory under tomcat for full tomcat visibility.
HTH
Reg
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I have done that, but the classes12.jar file is the one for Oracle 9I, is this going to be a problem.
I should say I still get the error.
Here is the stackTrace. Sorry for it being so long.

Mark
[ April 24, 2002: Message edited by: Mark Spritzler ]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I posted this into the Apache/Tomcat forum. It might be more pertaining there, so you can close this thread.
Mark
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Oh, and Jessica I am running Win98, there is no buffer in the command window. Bummer huh?
Mark
arun sahni
Ranch Hand

Joined: Jan 16, 2002
Posts: 91
Mark
I am also using Oracle9i with tomcat. Try to code these lines into servlet:
-Place classes12.zip in jre/lib/ext or tomcat classpath.
DriverManager.registerDriver (new OracleDriver());
Connection conn = DriverManager.getConnection("jdbc racle ci8:@" + "yourserverinstance","scott", "tiger");
DatabaseMetaData meta = conn.getMetaData ();
out.println("JDBC driver version is " + meta.getDriverVersion());
yourserverinstance-->This you can create using sqlnet tool or follow your setup.
If you get version# then your tomcat to oracle setup is correct.
I hope this will help.
[ April 24, 2002: Message edited by: arun sahni ]

Arun Sahni<br />SCJP2,SWCD,<br />BEA Certified Specialist: Server <br />JCert Enterprise Developer for BEA.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
java.lang.UnsatisfiedLinkError: do_openat oracle.jdbc.oci8.OCIDBAccess.do_open(Native Method)
This looks like a problem with the installation of the OCI Driver. You may want to try using the thin driver instead and see if that solves your problem.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Thanks guys. I figured out what was going on.
For those who might come accross this error.
It wasn't a driver issue. The first problem was, and when I put the classes12.jar into the common/lib direcotyr of Tomcat, I was good.
My problems were in the Query itself. Wrong field name, wrong field type.
They way I found this out was to include a method called getHelp, in my plain Java code that the servlet calls. getHelp returns a String named, yes you guessed it "help".
In various points I assign a value to help. Like in my catch in the getConnection() portion of my code. I assigned it Exception.getMessage(). I also assigned my query to help. And then I have my servlet call getHelp, so I can see the real problem. The error message Tomcat gave me led me down a wrong tree.
I also jsut found out that I could have sent the stack trace to the out via Exception.printStackTrace(out);
Thanks
Mark
[ April 25, 2002: Message edited by: Mark Spritzler ]
 
wood burning stoves
 
subject: Oracle Connection from class used by Servlet
 
Similar Threads
very very basic ques about using servlets
Error : Maximum open cursors exceeded
can connect to localhost but not domain
Creating a build and deployable using Ant
Extending HttpServlet