tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: Oracle 10g with Tomcat 6
Date Tue, 22 May 2007 12:22:55 GMT
You are using an old syntax for defining resource parameters.  
Parameters of a resource are defined as attributes of the <Resource   /> 
element since tomcat 5.5.  See the following docs for the correct method:

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

--David

Mohammed Zabin wrote:

> Hi All
> I want to conigure DBCP to connect to Oracle 10g on my localhost on 
> Tomcat6.
> I did the following error, I don't know how to solve it, is there is a
> third-party jar file that must be added to classpath???
>
> *1. I put the following in server.xml*
> *<Resource name="jbdc/myoracledb" auth="Container"
>                  type="javax.sql.DataSource" />
>
>    <ResourceParams name="jdbc/myoracledb">
>       <parameter>
>          <name>factory</name>
>          <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>       </parameter>
>       <parameter>
>          <name>driverClassName</name>
>          <value>oracle.jdbc.OracleDriver</value>
>       </parameter>
>       <parameter>
>          <name>url</name>
>          <value>jdbc:oracle:thin:@127.0.0.1:1521:orcldb</value>
>       </parameter>
>       <parameter>
>          <name>username</name>
>          <value>hr</value>
>       </parameter>
>       <parameter>
>          <name>password</name>
>          <value>hr</value>
>       </parameter>
>       <parameter>
>          <name>maxActive</name>
>          <value>20</value>
>       </parameter>
>       <parameter>
>          <name>maxIdle</name>
>          <value>10</value>
>       </parameter>
>       <parameter>
>          <name>maxWait</name>
>          <value>-1</value>
>       </parameter>
>    </ResourceParams>*
>
> *2. The following in web.xml:*
> *<resource-ref>
>   <description>Oracle Datasource example</description>
>   <res-ref-name>jdbc/myoracledb</res-ref-name>
>   <res-type>javax.sql.DataSource</res-type>
>   <res-auth>Container</res-auth>
> </resource-ref>*
>
> 3. And here is my JSP Code:
>
> <%@ page import="javax.sql.*, javax.naming.*, java.sql.*" %>
>
> <%
>  Context initContext = new InitialContext();
>  Context envContext  = (Context)initContext.lookup("java:/comp/env");
>  DataSource ds = (DataSource)envContext.lookup("jdbc/myoracledb");
>  Connection conn = ds.getConnection();
>
>  out.println( "Connection Established" );
> %>
>
> When running the page, i got the following error:
>
> *org.apache.jasper.JasperException: An exception occurred processing
> JSP page /jsp/testDBCP.jsp at line 7
>
> 4:   Context initContext = new InitialContext();
> 5:   Context envContext  = (Context)initContext.lookup("java:/comp/env");
> 6:   DataSource ds = (DataSource)envContext.lookup("jdbc/myoracledb");
> 7:   Connection conn = ds.getConnection();
> 8:
> 9:   out.println( "Connection Established" );
> 10: %>
>
>
> Stacktrace:
>     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)

>
>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408) 
>
>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) 
>
>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)*
>
> **
>
> *root cause *
>
> *javax.servlet.ServletException:
> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
> driver of class '' for connect URL 'null'
>     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)

>
>     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)

>
>     org.apache.jsp.jsp.testDBCP_jsp._jspService(testDBCP_jsp.java:73)
>     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) 
>
>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) 
>
>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)*
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message