Results 1 to 4 of 4
  1. #1
    kishan.java is offline Member
    Join Date
    Oct 2009
    Posts
    8
    Rep Power
    0

    Default java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

    Hi All,

    Can any boady please help me. I am new to java.

    I am facing a problem when i am trying to connect oracle DB with jsp.

    I set my class path as :C:\Program Files\Java\jdk1.6.0_14\lib;C:\Program Files\Tomcat 6.0\lib\servlet-api.jar;C:\Program Files\Java\jdk1.6.0_14\lib\ojdbc14.jar;.



    the error is as below:
    org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)


    root cause

    javax.servlet.ServletException: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:852)
    org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:781)
    org.apache.jsp.Access_jsp._jspService(Access_jsp.j ava:188)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)


    await yout reply.

    regards,
    kishan

  2. #2
    kishan.java is offline Member
    Join Date
    Oct 2009
    Posts
    8
    Rep Power
    0

    Default java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

    Hi In My JSP page i have used the following code:



    <%@ page language="java" import="java.sql.*" %>
    <%@ page language="java" import="java.io.*" %>
    <%@ page language="java" import="java.sql.Connection" %>
    <%@ page language="java" import="java.sql.DriverManager" %>
    <%@ page language="java" import="java.sql.Statement" %>


    <%
    response.setContentType("text/html");

    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=null;
    ResultSet rst=null;
    Statement stmt=null;

    try{
    String url="jdbc:oracle:thin:@localhost:1521:kishan-d630";
    con=DriverManager.getConnection(url,"scott","tiger ");
    stmt=con.createStatement();
    }
    catch(Exception e){
    System.out.println(e.getMessage());
    }
    if(request.getParameter("action") != null){
    String name=request.getParameter("name");
    String salary=request.getParameter("salary");
    stmt.executeUpdate("insert into emp_sal(name,salary) values('"+name+"','"+salary+"')");
    rst=stmt.executeQuery("select * from emp_sal");
    %>
    <html>
    <body>
    <center>
    <h2>Books List</h2>
    <table border="1" cellspacing="0" cellpadding ="0">
    <tr>
    <td><b>S.No</b></td>
    <td><b>Employee Name</b></td>
    <td><b>Salary</.b></td>
    </tr>
    <%
    int no=1;
    while(rst.next()){
    %>
    <tr>
    <td><%=no%></td>
    <td><%=rst.getString("name")%></td>
    <td> <%=rst.getString("salary")%> </td>
    </tr>
    <%
    no++;
    }
    rst.close();
    stmt.close();
    con.close();
    %>
    </table>
    </center>
    </body>
    </html>
    <%}else{%>
    <html>
    <head>
    <title>Employee Entry FormDocument</title>
    <script language="javascript">
    function validate(objForm){
    if(objForm.name.value.length==0){
    alert("Please enter Employee Name!");
    objForm.name.focus();
    return false;
    }
    if(objForm.salary.value.length==0){
    alert("Please enter Salary of employee!");
    objForm.salary.focus();
    return false;
    }
    return true;
    }
    </script>
    </head>
    <body>
    <center>
    <form action="Access.jsp" method="post" name="entry" onSubmit="return validate(this)">
    <input type="hidden" value="list" name="action">
    <table border="1" cellpadding="0" cellspacing="0">
    <tr>
    <td>
    <table>
    <tr>
    <td colspan="2" align="center">
    <h2>Book Entry Form</h2></td>
    </tr>
    <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
    <td>Employee Name:</td>
    <td><input name="name" type="text" size="50"></td>
    </tr>
    <tr>
    <td>salary:</td><td><input name="salary" type="text" size="50"></td>
    </tr>
    <tr>
    <td colspan="2" align="center"><input type="submit" value="Submit"></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    <%}%>

  3. #3
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    841
    Rep Power
    6

    Default

    try to explore ojdbc14.jar whether it has oracle.jdbc.driver.OracleDriver
    Ramya:cool:

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    First throw away that code and create a separate class for connecting to databases.
    Use JSPs for presentation only.
    Then add the oracle driver to your web application's WEB-INF/lib folder.

Similar Threads

  1. Replies: 10
    Last Post: 03-20-2012, 08:23 AM
  2. Replies: 6
    Last Post: 02-19-2010, 01:57 PM
  3. Replies: 0
    Last Post: 03-21-2008, 01:13 PM
  4. Replies: 1
    Last Post: 03-14-2008, 02:51 PM
  5. Replies: 1
    Last Post: 06-27-2007, 05:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •