这两天在搭建一个项目的环境,用的是Tomcat5.5 + Oracle 10.2.0.1 ,在Tomcat里面配置数据源。server.xml 配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<!-- Comment these entries out to disable JMX MBeans support used for the
administration web application -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
<Resource name="platformDataSource" type="javax.sql.DataSource" password="kaizen" driverClassName="oracle.jdbc.driver.OracleDriver" maxIdle="2" maxWait="5000" username="kaizen" url="jdbc:oracle:thin:@//127.0.0.1:1521/orcl" maxActive="4"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8000" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding='UTF-8' />
<Connector port="8009"
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
<Context path="/platform" docBase="D:\city\workspace\crmse\platform" crossContext="true" debug="0" reloadable="true">
<Resource name="platformDataSource" type="javax.sql.DataSource" password="kaizen" driverClassName="oracle.jdbc.driver.OracleDriver" maxIdle="2" maxWait="5000" username="kaizen" url="jdbc:oracle:thin:@//127.0.0.1:1521/orcl" maxActive="4"/>
</Context>
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Service>
</Server>
启动Tomacat 时日志文件报错为:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Io 异常: The Network Adapter could not establish the connection)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at com.sinosoft.sysframework.reference.DBManager.open(DBManager.java:63)