Topic: struts-config.xml中配置data-source总是失败。帮帮忙看看。

  Print this page

1.struts-config.xml中配置data-source总是失败。帮帮忙看看。 Copy to clipboard
Posted by: someone
Posted on: 2003-08-21 17:13

我下载了struts 1.1。
在struts-config.xml中配置了如下的数据源:
<data-sources>
<data-source key="mysqlDB">
<set-property property="type" value="javax.sql.DataSource"/>
<set-property property="autoCommit" value="false"/>
<set-property property="description" value="Data Source Configuration"/>
<set-property property="driverClass" value="org.gjt.mm.mysql.Driver" />
<set-property property="url" value="jdbc:mysql://127.0.0.1:3306/head"/>
<set-property property="maxCount" value="5"/>
<set-property property="minCount" value="1"/>
<set-property property="user" value="abc"/>
<set-property property="password" value="12345678"/>
</data-source>
</data-sources>

在Actionform中用如下语句:
ServletContext context = servlet.getServletContext();
DataSource dataSource = (DataSource)context.getAttribute("mysqlDB");

试了很多次,dataSource总是==null。 这是怎么回事? 教教我,谢谢!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923