Have MySQL server 4.1 running, tomcat 5.5.1 running. Here's my java class for testing the connection:
part of modified server.xml:
I created a database called bird with MySQL, and the jsp file is placed in the folder webapps/jbird/, the Connect.class, web.xml and server.xml all sit at their right places. All necessary jar files(commons-dbcp-1.2.1.jar, commons-collections-3.1.jar ....) are correctly placed. And I not only tried rebooting the tomcat but also rebooted my laptop....but, miserably enough, always no connection and the information in the log file is:
INFO: Server startup in 4640 ms org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540) at com.chinabird.library.Connect.init(Connect.java:37) at org.apache.jsp.connect_jsp._jspService(org.apache.jsp.connect_jsp:50) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:302) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:246) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) .... Caused by: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver(Unknown Source) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773) ... 22 more
I've wasted way too much time on this issue, any suggestion or explaination would be greatly appreciated! Thank you very much in advance.
This is not something I've done before and I'm very interested to see how it all hangs together. My suggestion is to try the JNDI lookup without the "java:comp/env/" prefix - I don't see it anywhere else in your set-up.
If that fails and no one with greater experience than I pops up to help then I suggest that you work through the Tomcat example app provided with DBCP (I assume there is one) and see if you can get that working. Then look at the differences between the two.
I tried your treatment but it didn't work out. I found a better example here and I've given up this approach, and restored the original server.xml file. But still I'm eager to know why the code above always generated the same exceptions.
I'll be greatly obliged for any enlightenment.
posted 14 years ago
My previous answer was based on the Tomcat documentation for version 4.1 (this is what I use, sorry for not noticing the version you are using). I just had a look at the documentation for version 5.5 and it appears they have changed the server.xml structure. <ResourceParams> is no longer present. They have made all the configuration parameters as attributes of the <Resource> tag.
About the other approach, I have never used or seen that being done before. The conventional thing to do is to create DataSources (provided by application server) and perform a jndi lookup to get a reference to them.