• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 635
  • Last Modified:

javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null'

I don't seem to be able to get to my database.  Thanks
for taking a look...


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null'
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
      org.apache.jsp.index2_jsp._jspService(org.apache.jsp.index2_jsp:165)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
      org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
      org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
      org.apache.jsp.index2_jsp._jspService(org.apache.jsp.index2_jsp:92)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
0
padmasambhava
Asked:
padmasambhava
  • 5
  • 3
  • 2
1 Solution
 
objectsCommented:
check your driver is available
and that you have specified the correct connect url string
0
 
objectsCommented:
And that the driver class name is specified correctly.
0
 
padmasambhavaAuthor Commented:
Here's the code that's giving me fits...

  Context iniCtx = new InitialContext();
  Context envCtx = (Context)    iniCtx.lookup("java:comp/env");
  DataSource ds =  (DataSource) envCtx.lookup("jdbc/something");
  Connection con = ds.getConnection();
  Statement  st = con.createStatement();

And here's the server.xml code as well...

        <Resource name="jdbc/something"
                  auth="Container"
                  type="javax.sql.DataSource"
                  driverClassName="org.postgresql.Driver"
                  url="jdbc:postgresql://127.0.0.1:5432/something"
                  username="something" password="password"
                  maxActive="20" maxIdle="10" maxWait="-1"/>
<!--
      
          <Resource name="jdbc/something" auth="Container"
                    type="javax.sql.DataSource">
          </Resource>

          <ResourceParams name="jdbc/something">
             <parameter>
               <name>factory</name>
               <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
             </parameter>

            <parameter>
              <name>removeAbandoned</name>
              <value>true</value>
            </parameter>

             <parameter>
               <name>driverClassName</name>
               <value>org.postgresql.Driver</value>
             </parameter>

             <parameter>
               <name>url</name>
               <value>jdbc:postgresql:something</value>
             </parameter>

             <parameter>
               <name>username</name>
               <value>something</value>
             </parameter>

             <parameter>
               <name>password</name>
               <value>password</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>
-->
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
objectsCommented:
WHere is your driver jar located?
0
 
padmasambhavaAuthor Commented:
Hey objects,

I forgot to mention that I'm a newbie, so how do I tell where my driver jar is located?

Thanks!
0
 
objectsCommented:
You need to put the jar file containing the jdbc driver in either <tomcat>/common/lib or <webapp>/WEB-INF/lib
0
 
padmasambhavaAuthor Commented:
Ok, the jar file was already there and I downloaded a newer version just to see if that
helped, but I still get the same error.

0
 
objectsCommented:
whats the error in the log say?
0
 
patbinCommented:
Context iniCtx = new InitialContext();
  Context envCtx = (Context)    iniCtx.lookup("java:comp/env");
  DataSource ds =  (DataSource) envCtx.lookup("jdbc/something");


instead of this try this soln

Context ic = new InitialContext();
       java.lang.Object objref =
          ic.lookup("java:comp/env/jdbc/something");

OR

private String dbName = "java:comp/env/jdbc/something";

InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);

Connection con =  ds.getConnection();



0
 
patbinCommented:
thanks for grade
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now