This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hi All, This is quite a desperate cry, i've been trying to solve this problem now for over a day and a half, I've seen lots of other threads on google with the same issues and have have tried each solution I found but to no avail.
I cannot connect to my database using JNDI., the actual error is "DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
Quick Outline ; I tend to develop in netbeans 4, and then move the build over to another installation of tomcat for final testing before putting it on a live external server. The system works ok through netbeans IDE, but the tomcat 5.5.7 installation is not playing. I believe I ahve installed all the correct jar's for DBCP and Connector/J. In my common/lib folder there are the commons' jar's and also the mysql-connector-java-3.1.7-bin.jar file.
the MySql connector is also there in the web-inf/lib directory. I also have the jar listed in the classpath environment variable, so I cant see any problem in tomcat detecting the driver.
My Web.xml contains..... <resource-ref> <description> Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file. </description> <res-ref-name> jdbc/ez2000 </res-ref-name> <res-type> javax.sql.DataSource </res-type> <res-auth> Container </res-auth> </resource-ref>
What else.. hmm the JSP which i'm using to test is very simple, I include the JSTL tag and am testing the connection with the line
<sql:query var="queryresults" dataSource="jdbc/ez2000">SELECT * from keys</sql:query>
I can connected directly to the database using the netbeans IDE database explorer. so that proves url i'm is correct. And when I log into the tomcat admin screen, the database section lists my jdbc/ez2000 connection which says to me server.xml entries are correct.
If anyone can help, has any advice its greatly appreciated.
Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/url] - Check out Grails Forum
Joined: Mar 08, 2005
FINALLY !!! I have solved the problems I was having...
After battling with config files, and reading and reading of various posts online to try and solve the problem, I came across one article which mentioned using the Tomcat Admin tool. I thought this was quite a basic utility, I never saw that you can expand the Service Node in the left frame of the page. It isnt immediately obvious, and sadly I never read the readme for the Admin module.
Anyway for anybody who has been having similar troubles, You can use the admin tool and not worry about adding correct entries in the various xml config files.
So 1. Set up the DBCP Pool Data Source under the Resources node and 2. ("After" deploying your app), expand the Service node, then Host, the the Context node for your App and then you will be able to add a Data Source which will tie together with the data source added under Resources by its JNDI name.
Well I hope this saves some poor soul some of the frustration and lack of productivity I have been having this past couple of days.