困扰无法解决,请教各位大虾:Tomcat5.5配置连接池时的异常错误:org.apache.tomcat.dbcp.dbcp.SQLNestedException:
这两天在搭建一个项目的环境,用的是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)
at com.crm.common.struts.CommonFacade.executeCommand(CommonFacade.java:56)
at com.sinosoft.sysframework.web.model.BaseCommand.commandFacade(BaseCommand.java:13)
at com.sinosoft.sysframework.web.model.BaseSLSBCommandServerDelegate.execute(BaseSLSBCommandServerDelegate.java:9)
at com.sinosoft.sysframework.web.model.BaseCommand.execute(BaseCommand.java:9)
at com.crm.system.util.SystemParametersContainer.<init>(SystemParametersContainer.java:41)
at com.crm.system.util.SystemParametersContainerUtil.getInstance(SystemParametersContainerUtil.java:27)
at com.crm.system.util.InitCrmSystemServlet.init(InitCrmSystemServlet.java:111)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:254)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:386)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:413)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:164)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
... 27 more
摆弄一天了,找了很多帖子内容看了,都无法解决,哪位高手给指点指点啊,着急啊。万分感激。
[解决办法]
tnsnames.ora里面你用plsql连数据库的时候用的配置是什么
如果是
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0d54d5fb5b424f0)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
那么你的url应该是jdbc:oracle:thin:@loaclhost:1522:orcl