I have been searching and searching for the answer to this, and despite
seeing many similar questions, I have yet to find the answer. I have a
struts 1.1 application using Tomcat 4.x that I will eventually move to
Tomcat 5.0. I have the mysql-connector-java-3.1.10-bin.jar, the 4
commons jar files in /$CATALINA_HOME/common/lib.
When I try to lookup the DataSource I get the following error:
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver
of class '' for connect URL 'null', cause:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
... etc...
Here is the serverl.xml:
<Resource name="jdbc/jsidb" auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="user" password="password"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/jsi_db?autoReconnect=true"/>
Here is the web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/jsidb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
And finally the code that is trying to get a Connection:
InitialContext initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/jsidb");
I do not understand why this is so complicated, it seems pretty
straightforward - but I have already spent two days trying a variety of
combinations and still I cannot get the DataSource to work.
I really, really appreciate any help you can offer.
onemonk - 20 Dec 2005 10:14 GMT
here...
instead of this:
>>>> url="jdbc:mysql://127.0.0.1:3306/jsi
insert this:
>>>> url="jdbc:mysql:127.0.0.1:3306/jsi
disclaimer:
Found it googling .. :)
the url:
http://tecfa.unige.ch/guides/java/staf2x/ex/jdbc/coffee-break/