本人开发的b/s系统,java + tomcat + sql server 2000 数据库已经打上sp4补丁,系统运行一段时间以后,常会出现 数据库无法连接 ,报的错有:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.stmxl.tools.DBHelper.getConnection(DBHelper.java:72)
at com.stmxl.dao.impl.tableinfo.SubjestQueryDaoImpl.queryMinOrganid(SubjestQueryDaoImpl.java:26)
at com.stmxl.service.impl.tableinfo.SubjestQueryServiceImpl.getThreeList(SubjestQueryServiceImpl.java:81)
at com.stmxl.action.tableinfo.ZtzxbmtzTableAction.initPage(ZtzxbmtzTableAction.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:399)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:262)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:213)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
因为本人对sqlServer不是很熟悉,请大家给予指教!谢谢
------解决方案--------------------
先打上SP3补丁,再看看驱动包很不是好的
------解决方案--------------------
以前我也碰到过类似的情况
刚开始我用的是DBCP的数据库连接方式,经常是运行一段时间后就会提示数据库连接错误
后面改用C3P0的连接方式,问题就解决了
------解决方案--------------------
一般情况下我先单独登录数据库··并且查看相应的服务开启了没有··如果没问题·再查看驱动对象是否可用··
------解决方案--------------------
数据库一般都有一个timeout设置,一旦超过这个时间就会自动关闭数据库