You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Zheng Wen Zhe <zw...@espatial.com> on 2006/03/14 14:58:41 UTC
what's wrong?? ---Connection with MySQL database
Hi,
Why I got this error when initialize web server????
ERROR <14-Mar-2006 13:52:17> Initializing application data source userDB
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
class '' for connect URL 'jdbc:mysql://localhost:3306/struts'
*************************************************************************
Struts-config.xml file:
<data-source type="org.apache.commons.dbcp.BasicDataSource" key="userDB">
<set-property property="maxCount" value="4" />
<set-property property="minCount" value="2" />
<set-property property="description"
value="Artimus:MySQL Data Source Configuration" />
<set-property property="driverClass" value="com.mysql.jdbc.Driver" />
<set-property property="url" value="jdbc:mysql://localhost:3306/struts" />
<set-property property="autoCommit" value="true" />
<set-property property="user" value="root" />
<set-property property="password" value="password" />
</data-source>
Retrieve data in jsp file:
<sql:query var="rs" dataSource="userDB">
select id, foo, bar from testdata
</sql:query>
Regards,
Jason
[OT] Re: what's wrong?? ---Connection with MySQL database
Posted by Antonio Petrelli <br...@tariffenet.it>.
Dave Newton ha scritto:
> Total time spent (not including typing this email): about 1 minute, 45
> seconds.
> Time spent typing the email: 2 minutes.
> Time you'll wait to read a response on the newsgroup: 5-15 minutes.
> Ability to debug your own app: priceless.
>
There are things that you cannot buy, for all the rest there's Google :-P
P.S. I translated it from Italian, so if it is not correct blame the
Italian translators....
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: what's wrong?? ---Connection with MySQL database
Posted by Dave Newton <ne...@pingsite.com>.
Zheng Wen Zhe wrote:
> Why I got this error when initialize web server????
>
Well, let's take a look:
> ERROR <14-Mar-2006 13:52:17> Initializing application data source userDB
>
> org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
> class '' for connect URL 'jdbc:mysql://localhost:3306/struts'
>
It looks like the machine thinks you haven't defined a class for the
database driver.
Why could that be?
> <data-source type="org.apache.commons.dbcp.BasicDataSource" key="userDB">
> <set-property property="driverClass" value="com.mysql.jdbc.Driver" />
>
Hmm.
I'll bet _you_ thought you defined one.
I wonder what google says:
http://www.google.com/search?q=struts+%2Bdatasource
Looking at two of the returned hits:
http://struts.apache.org/struts-doc-1.2.x/faqs/database.html
http://www.roseindia.net/struts/strutsdatasourcemanagerontomcat5.shtml
Both seem to indicate that you actually want:
<set-property
property="driverClassName"
value="com.mysql.jdbc.Driver" />
See the difference? Try this and see if that fixes the problem.
Total time spent (not including typing this email): about 1 minute, 45
seconds.
Time spent typing the email: 2 minutes.
Time you'll wait to read a response on the newsgroup: 5-15 minutes.
Ability to debug your own app: priceless.
Google is your friend.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: what's wrong?? ---Connection with MySQL database
Posted by chuanjiang lo <lo...@gmail.com>.
did you include the mysql jdbc jar in your classpath?
On 3/14/06, Zheng Wen Zhe <zw...@espatial.com> wrote:
>
> Hi,
>
> Why I got this error when initialize web server????
>
>
>
> ERROR <14-Mar-2006 13:52:17> Initializing application data source userDB
>
> org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
> class '' for connect URL 'jdbc:mysql://localhost:3306/struts'
>
>
>
> *************************************************************************
>
> Struts-config.xml file:
>
> <data-source type="org.apache.commons.dbcp.BasicDataSource" key="userDB">
>
> <set-property property="maxCount" value="4" />
>
> <set-property property="minCount" value="2" />
>
> <set-property property="description"
>
> value="Artimus:MySQL Data Source Configuration" />
>
> <set-property property="driverClass" value="com.mysql.jdbc.Driver" />
>
> <set-property property="url" value="jdbc:mysql://localhost:3306/struts" />
>
> <set-property property="autoCommit" value="true" />
>
> <set-property property="user" value="root" />
>
> <set-property property="password" value="password" />
>
> </data-source>
>
>
>
> Retrieve data in jsp file:
>
> <sql:query var="rs" dataSource="userDB">
>
> select id, foo, bar from testdata
>
> </sql:query>
>
>
>
> Regards,
>
>
>
> Jason
>
>
>
>
>
Re: what's wrong?? ---Connection with MySQL database
Posted by ALEX HYDE <al...@btinternet.com>.
I use Tomcat and I've only ever created datasources in web.xml. Have u tried that?
Zheng Wen Zhe <zw...@espatial.com> wrote: Hi,
Why I got this error when initialize web server????
ERROR <14-Mar-2006 13:52:17> Initializing application data source userDB
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
class '' for connect URL 'jdbc:mysql://localhost:3306/struts'
*************************************************************************
Struts-config.xml file:
value="Artimus:MySQL Data Source Configuration" />
Retrieve data in jsp file:
select id, foo, bar from testdata
Regards,
Jason
---------------------------------
Yahoo! Messenger NEW - crystal clear PC to PC calling worldwide with voicemail