Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle Connection from class used by Servlet

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Regus Patoff
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and Jessica I am running Win98, there is no buffer in the command window. Bummer huh?
Mark
 
arun sahni
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic