Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Tomcat 5.5 and simple JDBC program issue

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a simple JDBC program that works fine with Weblogic and Oracle 8i[8.1.5].
The program fails with Tomcat and the same database with the message that no suitable driver.

snippet....

//Load Driver
Class.forName("oracle.jdbc.driver.OracleDriver");
out.println("Driver loaded");
//Get Connection
Connection con= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:santora8", "scott", "tiger");
out.println("Got Connected!!"+con);
..................

In weblogic it works fine.In Tomcat it messages till Driver Loaded and then fails to get connection with message..no suitable driver.
I tried to put classes12.zip in classpath..alsoin \Tomcat 5.5\common\lib..but no luck...Also tried with ojdbc14.zip ..no luck..!!!
Anyone familiar with Tomcat /Oracle...Pls. help!!
Thanks for your time..
Regards
BD
 
Sheriff
Posts: 67634
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"BD",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, you're mistaken: BD exists
[ February 03, 2007: Message edited by: Ulf Dittmer ]
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by BD:
Hi,


I tried to put classes12.zip in classpath..alsoin \Tomcat 5.5\common\lib..but no luck...Also tried with ojdbc14.zip ..no luck..!!!
Anyone familiar with Tomcat /Oracle...Pls. help!!
Thanks for your time..
Regards
BD



Try renaming the .zip to .jar

Regards, Jan
 
Binu Das
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..Changed name as per Naming Policy..

Thanks for the reply...It took me one step ahead.

Renaming the .zip to .jar helped.Though I am still unable to move forward in it.

Now I am getting java.lang.NullPointerException oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:403)

I tried with both the classes12.jar and ojdbc14.jar no luck.!!
Checked Oracle site for suitable driver..but its has oracle 8.1.7's jdbc driver that too for jdk1.2 and jdk1.1..and am with 8.1.5 and jdk 1.5..:-(.

If anyone knows a link where one can download suitable driver.Please help.

Thanks for the time.
Regards
Binu.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your null pointer may be due to your code and not the driver. You could post your code and full stack trace of the error.

I really cannot recommend a driver, you'll need to figure that one out. You don't mention the version of weblogic you were using. You could look at what driver was working with that. If I recall correctly the driver jar would be in a weblogic server/lib directory. The ojdbc14 drivers should work with java 1.5 aka 5. You may be able to use some of the later oracle drivers, but may have issues since you're on oracle 8.1.5.
 
Binu Das
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...
Thanks for the response.I tried with a diff. setup with little luck with tomcat.
Please find the info and jsp.
Regards
Binu

Test Environment1:[JSP FAILS ..ERROR LOG ATTACHED]
Oracle 9.2.0
Oracle JRE 1.3.1_01
Tomcat 5.5 [COPIED ALL THE JDBC JAR FILES FROM ORACLE'S JDBC\lib
TO Tomcat 5.5\common\lib]

Test Environment2:[WORKS FINE]
Oracle 9.2.0
Weblogic 8.1sp3

The jsp:

<html> <body>
<%@ page language="java" %>
<%@ page import= "java.io.*, java.sql.*" %>
<%
//Load Driver
Class.forName("oracle.jdbc.driver.OracleDriver");
out.println("Driver loaded");
//Get Connection
Connection con= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:century", "scott", "tiger");
out.println("Got Connected!!"+con);

%>
</body>
</html>

Error Log Trace of Tomcat:

Feb 5, 2007 4:45:33 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at oracle.jdbc.driver.OracleStatement.getStringValue(OracleStatement.java)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java)
at oracle.jdbc.dbaccess.DBAccess.setNlsParamsClient(DBAccess.java)
at oracle.jdbc.ttc7.TTC7Protocol.initNls(TTC7Protocol.java)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:214)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:193)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.apache.jsp.Datafetch3_jsp._jspService(org.apache.jsp.Datafetch3_jsp:52)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Binu Das:

Test Environment1:[JSP FAILS ..ERROR LOG ATTACHED]
Oracle 9.2.0
Oracle JRE 1.3.1_01
Tomcat 5.5 [COPIED ALL THE JDBC JAR FILES FROM ORACLE'S JDBC\lib
TO Tomcat 5.5\common\lib]



Could you provide more details on the failing environment?

Let me see if I understand,

1. Your database is oracle 9.2

2. How are you using Oracle JRE 1.3.1?

3. What jar files are these? What do you mean by Oracle's JDBC/lib dir?[COPIED ALL THE JDBC JAR FILES FROM ORACLE'S JDBC\lib
TO Tomcat 5.5\common\lib]


I'm not really a tomcat oracle user. Perhaps someone who is knows more about that can comment???
 
Replace the word "snake" with "danger noodle" in all tiny ads.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic