我有BLManager类,它首先打开连接并调用数据管理器类来从数据库获取数据并返回包含该数据的VO列表。
在BL管理器中完成所有计算后,我调用提交事务的方法并关闭连接。
这是我打开和关闭数据库连接所遵循的流程。今天我面临一些奇怪的例外情况,如下所示
com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.
This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable.
For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.
For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2104)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.cc.jas.datamanager.util.db.DBManager.getConnection(DBManager.java:83)
at com.cc.jas.blmanager.base.BaseBLManager.startTransaction(BaseBLManager.java:252)
at com.cc.jas.blmanager.system.systemconfig.SystemConfigBLManager.getConfigMap(SystemConfigBLManager.java:82)
at com.cc.jas.delegate.system.systemconfig.SystemConfigBusinessDelegate.getConfigMap(SystemConfigBusinessDelegate.java:39)
at com.cc.jas.common.cache.SystemConfigCacheManager.reloadCache(SystemConfigCacheManager.java:120)
at com.cc.jas.common.cache.SystemConfigCacheManager.getParameterValue(SystemConfigCacheManager.java:53)
at com.cc.jas.model.base.BaseReportVO.getDisplayDate(BaseReportVO.java:116)
at com.cc.jas.model.account.rvo.AccountItemReportVO.getDateString(AccountItemReportVO.java:111)
at sun.reflect.GeneratedMethodAccessor333.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1773)
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1132)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:686)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:290)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:115)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:100)
at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:104)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:787)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:751)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1422)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:879)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:801)
at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:536)
at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:63)
at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:209)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.BindException: Address already in use: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
这个例外说明了什么,解决方案是什么?
答案 0 :(得分:1)
引起:java.net.BindException:已在使用的地址:connect
这表示您尝试与进程绑定的ip:port
已经与其他进程绑定。
答案 1 :(得分:0)
尝试ping 127.0.0.1
查看tcp / ip是否正常工作。然后使用netstat -a
查看开放端口和套接字。