我到jakarta的页面看了看,它给出了一个在struts-config.xml里配置datasource的例子,我按照例子做了如下配置:
<data-sources>
<!-- configuration for commons BasicDataSource -->
<data-source key="jdbc/mydb" type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<set-property property="url"
value="jdbc
![](images/smilies/default/shocked.gif)
racle:thin
![](images/smilies/default/huffy.gif)
localhost:1521:lanx" />
<set-property property="username"
value="scheduler" />
<set-property property="password"
value="calissfx" />
<set-propertyproperty="maxActive"
value="40" />
<set-property property="maxWait"
value="5000" />
<set-property property="defaultAutoCommit"
value="false" />
<set-property property="defaultReadOnly"
value="false" />
</data-source>
</data-sources>
但是我在jbuilder9里启动tomcat40的时候出现下面的错误:
StandardWrapper[/project:action]: Marking servlet action as unavailable
StandardContext[/project]: Servlet /project threw load() exception: javax.servlet.UnavailableException: Initializing application data source jdbc/mydb
javax.servlet.UnavailableException: Initializing application data source jdbc/mydb
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1091)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
... ...
为什么呢?
另外,如果整个工程直接在tomcat下运行,这个时候我的server.xml和struts-config.xml文件里都有datasource的配置,其中server.xml里是原来配置过的,可以使用,struts-config.xml是后来加的.
启动tomcat不会出现错误,但是只要访问数据库,就出现下面的错误:
HTTP Status 500 -