2016-10-27 104 views
0

我有一個運行在Windows Server 2012 R2上的Tomcat8上的java servlet應用程序。 Oracle 11g r2在具有相同子網的不同計算機上運行,​​因此java應用程序和oracle之間不存在任何防火牆。JDBC瘦適配器無法在高峯時間建立連接

java應用程序是多線程的並且在高峯時間具有海量負載。

我的問題是;當一切都很好,並且在異常發生的情況下正常工作。

java.lang.reflect.InvocationTargetException 
at sun.reflect.GeneratedMethodAccessor189.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at com.mulberry.request.MulberryRequestProcessor.run(MulberryRequestProcessor.java:168) 
at com.mulberry.request.MulberryRequestProcessor.lambda$run$0(MulberryRequestProcessor.java:78) 
at com.mulberry.request.MulberryRequestProcessor$$Lambda$32/461612128.run(Unknown Source) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:745) 
Caused by: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection 
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:743) 
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:666) 
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) 
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:566) 
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:277) 
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:181) 
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699) 
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:633) 
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:186) 
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127) 
at com.mulberry.data.connection.ConnectionManager.getConnection(ConnectionManager.java:86) 
at com.mulberry.data.MulberryOrm.getConnection(MulberryOrm.java:103) 
at com.mulberry.data.MulberryOrm.insertMulti(MulberryOrm.java:201) 
at com.mulberry.data.MulberryOrm.upsertMulti(MulberryOrm.java:192) 
at com.aril.profile.service.impl.LprBulkdataService.saveLoadProfileData(LprBulkdataService.java:86) 
... 11 more 
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection 
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:470) 
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:506) 
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:595) 
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:230) 
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1452) 
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:496) 
... 25 more 
Caused by: java.net.ConnectException: Connection refused: connect 
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) 
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) 
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345) 
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) 
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) 
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) 
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
at java.net.Socket.connect(Socket.java:589) 
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:161) 
at oracle.net.nt.ConnOption.connect(ConnOption.java:159) 
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:428) 
... 30 more 

當oracle站點發生此異常時; 專用用戶計數:〜5200

oracle的參數的會話(也大於1個的Tomcat instace與相同目的運行)被設置好的12000 預言跑步機也是Windows Server 2012中與64個CPU和96GB RAM

我正在使用tomcat jdbc連接池和應用程序在tomcat池下獲取連接。

連接字符串是服務器之間

jdbc:oracle:thin:@[IPADDRESS]:1521/[SERVICENAME] 

以太網萬兆是如此不考慮網絡延遲。

任何人都可以幫助我發現我的問題嗎?

+1

如果它在高負載時除外,那麼問題很可能發生在數據庫服務器端。 「拒絕連接」是非常具體的,它意味着服務器主動拒絕連接嘗試,可能是因爲它被超載或不在某些資源中。您將需要通過檢查服務器日誌並與您的DBA交談來實現此目的。 –

回答

0

你可以設置超時時間;

Properties props = new Properties(); 
props.setProperty("user", "dbuser"); 
props.setProperty("password", "dbpassword"); 
props.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_NET_CONNECT_TIMEOUT, "2000"); 

Connection con = DriverManager.getConnection("<JDBC connection string>", props); 
相關問題