• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Oracle JDBC connectivity

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access Oracle from JSP and my .jsp file is as below, I am getting class not found exception...am I missing something? I am using appropriate username,password,host and sid parameters.


<%@ page import="java.sql.*" %>

<HTML>
<HEAD>
<Title>Listing The Contents Of a Database Table</Title>
</Head>
<Body>
<p>Content of the Employee Table:
<Table Border=1 Cellpadding=0 Cellspacing=0>
<TR>
<TD> ID </TD>
<TD> Name </TD>
<TD> SSN </TD>

</TR>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc racle:thin:@<host>:<1521>:<sid>","<username>","<password>");
java.sql.Statement statement = conn.createStatement();
java.sql.ResultSet columns = statement.executeQuery("Select * from employee");

while (columns.next()) {
int ID = columns.getInt("ID");
String Name = columns.getString("Name");
int SSN = columns.getInt("SSN");


%>

<TR> <TD> <%= ID %> </TD>
<TD> <%= Name %> </TD>
<TD> <%= SSN %> </TD>

</TR>
<% } %>
</Table>
</Body>
</HTML>
 
Sheriff
Posts: 67752
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

Originally posted by Miki Nema:
I am getting class not found exception



Do you not think that it might be useful information to include which class?

If it's the Oracle driver, you need to be sure and include the Oracle jar file containing the driver in a location wheere the web container will pick it up.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is this class in the classpath?
oracle.jdbc.driver.OracleDriver.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont know which web server you are using, but if you are using tomcat 5.5.9 then download classes12.zip from oracle site rename it to classes12.jar and place it in tomcatDirectory\common\lib. or follow the instructions from here.

http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

thanx.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All you need a JDBC driver for ORACLE, regardless of any server you are using.
classes12.zip or classes111.zip, it depends on your ORACLE version.
Thanks.
 
Rahul Bajaj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added classes12.jar in my classpath location and I am using java SDK 1.4 server. I also checked the classpath by ,
<%out.println(System.getProperty("java.class.path"));%>
It doesn't show any of the classes like classes12.jar or ojdbc14.jar. Here is the output...

H:/Sun/AppServer/jdk/lib/tools.jar;H:/Sun/AppServer/lib/appserv-rt.jar;H:/Sun/AppServer/lib\activation.jar;H:/Sun/AppServer/lib\admin-cli.jar;H:/Sun/AppServer/lib\appserv-admin.jar;H:/Sun/AppServer/lib\appserv-cmp.jar;H:/Sun/AppServer/lib\appserv-ext.jar;H:/Sun/AppServer/lib\appserv-jstl.jar;H:/Sun/AppServer/lib\appserv-upgrade.jar;H:/Sun/AppServer/lib\commons-launcher.jar;H:/Sun/AppServer/lib\commons-logging.jar;H:/Sun/AppServer/lib\dom.jar;H:/Sun/AppServer/lib\j2ee-svc.jar;H:/Sun/AppServer/lib \j2ee.jar;H:/Sun/AppServer/lib\jax-qname.jar;H:/Sun/AppServer/lib\jaxr-api.jar;H:/Sun/AppServer/lib\jaxr-impl.jar;H:/Sun/AppServer/lib\jaxrpc-api.jar;H:/Sun/AppServer/lib\jaxrpc-impl.jar;H:/Sun/AppServer/lib\jmxremote.jar;H:/Sun/AppServer/lib\jmxremote_optional.jar;H:/Sun/AppServer/lib\jsf-api.jar;H:/Sun/AppServer/lib\jsf-impl.jar;H:/Sun/AppServer/lib\mail.jar;H:/Sun/AppServer/lib\relaxngDatatype.jar;H:/Sun/AppServer/lib\rmissl.jar;H:/Sun/AppServer/lib\saaj-api.jar;H:/Sun/AppServer/lib\saaj-impl .jar;H:/Sun/AppServer/lib\xalan.jar;H:/Sun/AppServer/lib\xercesImpl.jar;H:/Sun/AppServer/lib\xsdlib.jar;H:/Sun/AppServer/lib/install/applications/jmsra/imqjmsra.jar;H:/Sun/AppServer/imq/lib/jaxm-api.jar;H:/Sun/AppServer/imq/lib/fscontext.jar;H:/Sun/AppServer/lib/ant/lib/ant.jar;H:/Sun/AppServer/pointbase/lib/pbclient.jar;H:/Sun/AppServer/pointbase/lib/pbembedded.jar
 
Bear Bibeault
Sheriff
Posts: 67752
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

Originally posted by Miki Nema:
I also checked the classpath by



Servlet containers pay no attention wahtsoever to the system classpath. You need to be sure that the jar file is in one of the locations that the container will examine in order to create its own classpath.
 
Rahul Bajaj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so do I need to include that in my pointbase database's direcory?
 
Bear Bibeault
Sheriff
Posts: 67752
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
You can include it in the web app's WEB-INF/lib forder, or if you are going to use it in multiple web apps, you can include it in the shareed folder for the container. For Tomcat, that would be $CATALINA_HOME/common/lib.
 
Rahul Bajaj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java SDK doesn't have anything like WEB-INF/Lib folder....do you know whats the directory for SDK server?
 
Rahul Bajaj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I included that in web app's web-inf/lib folder and its working now...thanks.
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic