Cannot create JDBC driver of class ' for connect URL ' null ' problem resolution

Source: Internet
Author: User
Tags tomcat server

Cannot create JDBC driver of class ' for connect URL ' null ' workaround 1 Technically, it's not a mistake, just a different version. tomcat-5.0.28 is this form<resource name= "Jdbc/conn" type= "Javax.sql.DataSource"/><resourceparams name= "Jdbc/conn" ><parameter><name>maxwait</name><value>5000</ Value></parameter><parameter><name>maxactive</name><value>10</value> </parameter><parameter><name>password</name><value>tiger</value></ Parameter><parameter><name>url</name><value>jdbc:oracle:thin: @localhost: oracle</ Value></parameter><parameter><name>driverclassname</name><value> Oracle.jdbc.driver.oracledriver</value></parameter><parameter><name>maxidle</name ><value>1</value></parameter><parameter><name>username</name><value >scott</value></parameter></ResourceParams>   but apache-tomcat-6.0.32 is going to have this form < Resource name= "Jdbc/conn" auth= "Container" type= "Javax.sql.DataSource" maxactive= "Ten" maxidle= "1" maxwait= "5000" Username= "Scott" password= "Tiger" DRiverclassname= "Com.mysql.jdbc.Driver" url= "Jdbc:mysql://localhost:3306/neusys"/> cannot create  JDBC driver of class  '  for connect URL  ' null ' problem solving method 2

1) Start the Tomcat server, open the browser, enter http://localhost:8080/ Admin (where localhost is the name server or host),
Enter the Admin Interface landing page, this time please enter the original installation required the user name and password, login to the management interface,

2) Select Resources-data Sources Enter the configuration data source interface, select
 data source Actions, select Create NewData source, enter the configuration details interface
The main contents are as follows:
JNDI Name:  ->jdbc/mysql
Data Source url ->jdbc:mysql://localhost:3306/test
JDBC Driver class-> org.gjt.mm.mysql.Driver
3) Modify the \conf\catalina\localhost directory to create an XML file named the name of the Web app you are publishing. XML, such as Testpool.xml, opens adding content as follows:
<?xml version= "1.0" encoding= "UTF-8"?
<context>
 < Resource
     name= "Jdbc/mysql"
     type= " Javax.sql.DataSource "
     password=" 123456 "
      Driverclassname= "Org.gjt.mm.mysql.Driver"
     maxidle= "2"
      maxwait= "" "
     username=" root "
     url = "Jdbc:mysql://localhost:3306/test"
     maxactive= "4"/>

</context>
contents are <globalnamingresources> with Conf/server.xml;
 <resource
      name= "Jdbc/mysql"
     type= "Javax.sql.DataSource"
      password= "123456"
     driverclassname= " Org.gjt.mm.mysql.Driver "
     maxidle=" 2 "
     maxwait = "" "
     username=" root "
     url=" jdbc:mysql:// Localhost:3306/test "
     maxactive=" 4 "/>
 </globalnamingresources

Missing This step will error: Cannot create JDBC driver of class ' for connect URL ' null '
4) modify Web. XML

Open%tomcat_home%\conf\web.xml or Yourwebapp/web-inf/web.xml and add the following:
<resource-ref>
<description>DBConnection</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Note that res-ref-name fills in the same name as the Jndi name mentioned earlier in this section.
Here, the configuration work is basically done!

5) Use "Java:comp/env/jdbc/mysql" when referencing Jndi;
To establish a file test test.jsp:
<% @page contenttype= "Text/html;charset=utf-8"%>
<% @page import= "java.sql.*"%>
<% @page  import= "javax.sql.*"%>
<% @page  import= "javax.naming.*"%>
<title>tomcat Connection Pool test </ Title>
<body>
<%
  Context ctx=new initialcontext ();
  Connection Conn=null;
  datasourceds= (DataSource) ctx.lookup ("Java:comp/env/jdbc/mysql");
  conn=ds.getconnection ();
  Statementstmt=conn.createstatement (resultset.concur_read_only,resultset.concur_updatable);
  ResultSet rs=stmt.executequery ("SELECT * fromtestexample");
  while (Rs.next ()) {
  out.println (Rs.getint (1));
  Out.println (rs.getstring (2));
  Out.println (rs.getstring (3));
 }
  OUT.PRINTLN ("Database operation succeeded! ");
  Rs.close ();
  Stmt.close ();
  Conn.close ();
    
 %>
</body>

Cannot create JDBC driver of class ' for connect URL ' null ' problem resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.