如何解决weblogic:使用连接池已关闭连接错误
我正在使用weblogic的连接池,但是即使每次都在finally
中关闭连接,它也会在错误日志下方显示。
我在weblogic监视中检查了保留请求时间失败,次数是4970
有什么解决方法可以始终保持打开的连接吗?
[ERROR] 2020-08-31 08:16:05,815 com.org.fwd.dao.ResponseDAO details - hrer1
[ERROR] 2020-08-31 08:16:05,815 com.org.fwd.dao.ResponseDAO details - connction issue
[ERROR] 2020-08-31 08:16:05,934 com.org.fwd.dao.ResponseDAO details - connction issue
[ERROR] 2020-08-31 08:16:05,944 com.org.fwd.dao.ResponseDAO details - Connection has already been closed.
java.sql.SQLException: Connection has already been closed.
at weblogic.jdbc.wrapper.PoolConnection.checkConnection(PoolConnection.java:99)
at weblogic.jdbc.wrapper.Statement.checkStatement(Statement.java:323)
at weblogic.jdbc.wrapper.Statement.preInvocationHandler(Statement.java:123)
at weblogic.jdbc.wrapper.PreparedStatement.setInt(PreparedStatement.java:529)
at com.org.fwd.dao.ResponseDAO.details(ResponseDAO.java:810)
at com.org.fwd.dao.ResponseDAO.getDetail(ResponseDAO.java:1434)
at com.org.fwd.services.responseservice.responsedetails(responseservice.java:280)
at com.org.fwd.controller.getDetailcontroller.stepdetailcontroller(getDetailcontroller.java:107)
at sun.reflect.GeneratedMethodAccessor1644.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:806)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:729)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.websocket.tyrus.TyrusServletFilter.doFilter(TyrusServletFilter.java:274)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:272)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
[ERROR] 2020-08-31 08:16:05,945 com.org.fwd.dao.ResponseDAO details - hrer1
[ERROR] 2020-08-31 08:16:05,945 com.org.fwd.dao.ResponseDAO details - connction issue
[ERROR] 2020-08-31 08:16:05,948 com.org.fwd.dao.ResponseDAO details - connction issue
[ERROR] 2020-08-31 08:16:05,963 com.org.fwd.dao.ResponseDAO details - Connection has already been closed.
java.sql.SQLException: Connection has already been closed.
at weblogic.jdbc.wrapper.PoolConnection.checkConnection(PoolConnection.java:112)
at weblogic.jdbc.wrapper.ResultSet.preInvocationHandler(ResultSet.java:93)
at weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_ForwardOnlyResultSet.getString(Unknown Source)
at com.org.fwd.dao.ResponseDAO.details(ResponseDAO.java:838)
at com.org.fwd.dao.ResponseDAO.getDetail(ResponseDAO.java:1445)
at com.org.fwd.services.responseservice.responsedetails(responseservice.java:280)
at com.org.fwd.controller.getDetailcontroller.stepdetailcontroller(getDetailcontroller.java:107)
at sun.reflect.GeneratedMethodAccessor1644.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:806)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:729)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.websocket.tyrus.TyrusServletFilter.doFilter(TyrusServletFilter.java:274)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:272)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
我正在使用的代码如下
'
public ArrayList<Response> getDetail(int id,int count) throws SQLException{
Connection con = null;
Statement stmt = null;
ArrayList<Integer> IdList = new ArrayList<Integer>();
ResultSet rs = null;
try {
DConnection dsobj = new DConnection(dbinstance);
con = (java.sql.Connection) dsobj.getConnection();
String sql = "select id from id_table where id=" + id + " order by entry_date";
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
// System.out.println(rs.getInt(1));
IdList.add(rs.getInt(1));
}
{
int chunks = IdList.size() / 5;
if (count == 1) {
ArrayList<Response> response = new ArrayList<Response>();
for (int i = 0; i < Math.round(chunks); i++) {
response.add(details(IdList.get(i).toString(),con));
}
return response;
}
if (count == 2) {
ArrayList<Response> response = new ArrayList<Response>();
for (int i = Math.round(chunks); i < Math.round(chunks) * 2; i++) {
response.add(details(IdList.get(i).toString(),con));
}
return response;
}
if (count == 3) {
ArrayList<Response> response = new ArrayList<Response>();
for (int i = Math.round(chunks) * 2; i < Math.round(chunks) * 3; i++) {
response.add(details(IdList.get(i).toString(),con));
}
return response;
}
if (count == 4) {
ArrayList<Response> response = new ArrayList<Response>();
for (int i = Math.round(chunks) * 3; i < Math.round(chunks) * 4; i++) {
response.add(details(IdList.get(i).toString(),con));
}
return response;
}
if (count == 5) {
ArrayList<Response> response = new ArrayList<Response>();
for (int i = Math.round(chunks) * 4; i < IdList.size(); i++) {
response.add(details(IdList.get(i).toString(),con));
}
return response;
} }
} catch (Exception e1) {
logger.error(e1.getMessage(),e1);
e1.printStackTrace();
}
finally {
if(con!=null)
{try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
}
return null;
}
public Response details(String s,Connection con) {
ResultSet RS1 = null;
ResultSet RS2 = null;
ResultSet RS3 = null;
ResultSet RS4 = null;
CallableStatement callStmt = null;
ArrayList<input> input = new ArrayList<input>();
ArrayList<output> output = new ArrayList<output>();
ArrayList<sub> sub = new ArrayList<sub>();
H1 hd=null;
// CallableStatement callStmt1 = null,callStmt2 = null;
try {
if (con == null) {
logger.error("connction issue");
}
} catch (Exception e) {
logger.error(e.getMessage(),e);
e.printStackTrace();
}
try {
callStmt = con.prepareCall("{call data.getdetails(?,?,?)}");
callStmt.setString(1,s);
callStmt.registerOutParameter(2,OracleTypes.CURSOR);
callStmt.registerOutParameter(3,OracleTypes.CURSOR);
callStmt.registerOutParameter(4,OracleTypes.CURSOR);
callStmt.registerOutParameter(5,OracleTypes.CURSOR);
callStmt.execute();
RS1 = (ResultSet) callStmt.getObject(2);
RS2 = (ResultSet) callStmt.getObject(3);
RS3 = (ResultSet) callStmt.getObject(4);
RS4 = (ResultSet) callStmt.getObject(5);
RS1.next();
String desc = RS1.getString(1);
String[] descArr = desc.split("#\\$@");
int id=Integer.parseInt(descArr[8]);
String clr = "";
CallableStatement callStmt2;
***callStmt2 = con.prepareCall("{call data.getda(?,?)}");***
callStmt2.setInt(1,id);
callStmt2.registerOutParameter(2,java.sql.Types.VARCHAR);
callStmt2.execute();
clr=callStmt2.getString(2);
callStmt2.close();
if(clr.equals("P")) {
clr="pink";
}
else if(clr.equals("R")) {
clr="red";
}
else {
clr="black";
}
// System.out.println(clr);
hd = new H1(Integer.parseInt(descArr[0]),descArr[1],descArr[2],descArr[3],descArr[4],descArr[5],descArr[6],descArr[7],Integer.parseInt(descArr[8]),clr);
while (RS2.next()) {
// String IP = RS2.getString(1);
String IP = RS2.getString(1) + " " + "#*@";
String[] IPArr = IP.split("#\\*@");
// System.out.println(IPArr.length);
String colour = "black";
String ipname=IPArr[2];
if(ipname!=null) {
CallableStatement callStmt1;
callStmt1 = con.prepareCall("{call data.getclr1(?,?)}"); // Calling
callStmt1.setInt(1,id);
callStmt1.setString(2,IPArr[2]);
callStmt1.registerOutParameter(3,java.sql.Types.VARCHAR);
callStmt1.execute();
colour=callStmt1.getString(3);
callStmt1.close();
}
input.add(new input((Integer.parseInt(IPArr[1])),IPArr[2],IPArr[3],IPArr[4],IPArr[5],IPArr[6],IPArr[7],(IPArr[8]),(IPArr[9]),(IPArr[10]),IPArr[11],IPArr[12],colour));
}
RS2.close();
while (RS3.next()) {
String OP = RS3.getString(1) + " " + "#*@";
// String OP = RS3.getString(1);
String[] OPArr = OP.split("#\\*@");
// System.out.println(OPArr.length);
output.add(new output((Integer.parseInt(OPArr[1])),OPArr[2],OPArr[3],OPArr[4],OPArr[5],OPArr[6],OPArr[7],OPArr[8],(OPArr[9]),(OPArr[10]),(OPArr[11]),OPArr[12]));
}
RS3.close();
RS4.next();
sub subName = new sub(RS4.getString(1));
sub.add(subName);
RS4.close();
return new Response(hd,input,output,sub);
// hdresponse1.add(new hdresponse(hd,input));
} catch (SQLException e) {
logger.error(e.getMessage(),e);
e.printStackTrace();
}
catch (Exception e) {
logger.error(e.getMessage(),e);
e.printStackTrace();
} finally {
try {
if (callStmt != null)
callStmt.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
logger.error("hrer1");
return null;
}
'
1个JSON文件的数据大小约为3 MB
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。