【发布时间】:2017-07-29 18:46:06
【问题描述】:
我正在开发一个在 Tomcat 下运行的简单 Java 应用程序。作为数据库,我选择了 MySQL,它通过 JDBC 连接器与 Tomcat 服务器通信。根据文档,我已经从 MySQL 网站下载了连接器,并将其放在 Tomcat 的 lib/ 目录下;我还在 server.xml 中添加了以下描述:
<Context docBase="user-accounts" path="/user-accounts" reloadable="true"
source="org.eclipse.jst.jee.server:user-accounts">
<Resource driverClassName="com.mysql.jdbc.Driver"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
initialSize="10"
maxActive="100"
maxIdle="50"
minEvictableIdleTimeMillis="55000"
minIdle="10"
name="jdbc/accountsDB"
password="password"
removeAbandoned="true"
removeAbandonedTimeout="55"
testOnBorrow="true"
timeBetweenEvictionRunsMillis="34000"
type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/account_schema"
username="user"
validationInterval="34"
validationQuery="select 1" />
</Context>
但我收到以下错误:
javax.servlet.ServletException: javax.naming.NameNotFoundException: Name [jdbc/accountsDB] is not bound in this Context. Unable to find [jdbc]
我错过了什么?
【问题讨论】: