The error cannot create JDBC driver of class ''for connect URL 'null' has been reported many times.ArticleIn the hope that it will be helpful for future students. The original text is as follows:
Http://www.blogjava.net/flustar/archive/2007/04/17/111362.html
Use the tomcat5.5 connection pool to connect to MySQL (solution: cannot create JDBC driver of class ''for connect URL 'null ')
1) Start the Tomcat server, open the browser, and enter http: // localhost: 8080/admin (localhost is the name server or
Host ),
Go to the login page of the management interface. At this time, enter the user name and password required during the original installation and log on to the management interface,
2) Select resources-data sources to go to the data source configuration page. Select
Data Source actions-> select create new data source to go to the configuration details page.
The main content is 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 your published Web Application name. XML (for example
testpool. XML):
name = "JDBC/MySQL"
type = "javax. SQL. datasource "
Password =" 123456 "
driverclassname =" org. gjt. mm. mySQL. driver "
maxidle =" 2 "
maxwait =" 50 "
username =" root "
url =" JDBC: mysql: // localhost: 3306/test "
maxactive =" 4 "/>
</Context>
The content is the same as that in CONF/server. xml <globalnamingresources>
<Resource
Name = "JDBC/MySQL"
Type = "javax. SQL. datasource"
Password = "123456"
Driverclassname = "org. gjt. Mm. MySQL. Driver"
Maxidle = "2"
Maxwait = "50"
Username = "root"
Url = "JDBC: mysql: // localhost: 3306/test"
Maxactive = "4"/>
</Globalnamingresources>
If this step is missing, the following error occurs: cannot create JDBC driver of class ''for connect URL 'null'
4) modify web. xml
Open % atat_home %/CONF/Web. xml or yourwebapp/Web-INF/Web. xml and add the following content:
<Resource-ref>
<Description> dB connection </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 the res-ref-name must be the same as the JNDI name mentioned above.
Now, the configuration is complete!
5) use "Java: COMP/ENV/jdbc/MySQL" to reference JNDI ";
Create a file to test. jsp:
<% @ Page contenttype = "text/html; charset = UTF-8" %>
<% @ Page import = "Java. SQL. *" %>
<% @ Page import = "javax. SQL. *" %>
<% @ Page import = "javax. Naming. *" %>
<HTML>
<Head>
<Title> Tomcat connection pool test </title>
</Head>
<Body>
<%
Context CTX = new initialcontext ();
Connection conn = NULL;
Datasource DS = (datasource) CTX. Lookup ("Java: COMP/ENV/jdbc/MySQL ");
Conn = Ds. getconnection ();
Statement stmt = conn. createstatement (resultset. concur_read_only, resultset. concur_updatable );
Resultset rs1_stmt.exe cutequery ("select * From testexample ");
While (Rs. Next ()){
Out. println (Rs. getint (1 ));
Out. println (Rs. getstring (2 ));
Out. println (Rs. getstring (3 ));
}
Out. println ("database operation successful! ");
Rs. Close ();
Stmt. Close ();
Conn. Close ();
%>
</Body>
</Html>