对于以下代码,我收到此警告:
[2013-08-07T16:44:27.442+0300] [glassfish 4.0] [WARNING] [] [javax.enterprise.resource.resourceadapter.com.sun.gjc.util] [tid: _ThreadID=94 _ThreadName=connectors-runtime-context] [timeMillis: 1375883067442] [levelValue: 900] [[
A potential statement leak detected for connection pool API. The stack trace of the thread is provided below :
com.sun.gjc.spi.base.PreparedStatementWrapper.<init>(PreparedStatementWrapper.java:107)
com.sun.gjc.spi.base.CallableStatementWrapper.<init>(CallableStatementWrapper.java:66)
com.sun.gjc.spi.jdbc40.CallableStatementWrapper40.<init>(CallableStatementWrapper40.java:65)
com.sun.gjc.spi.jdbc40.ConnectionWrapper40.callableCachedStatement(ConnectionWrapper40.java:291)
com.sun.gjc.spi.jdbc40.ConnectionWrapper40.callableCachedStatement(ConnectionWrapper40.java:52)
com.sun.gjc.spi.ManagedConnectionImpl.prepareCachedCallableStatement(ManagedConnectionImpl.java:1200)
com.sun.gjc.spi.jdbc40.ConnectionWrapper40.prepareCall(ConnectionWrapper40.java:127)
classes.xmlHandler.handleCall(xmlHandler.java:256)
azi.Scp.processRequest(Scp.java:54)
azi.Scp.doPost(Scp.java:105)
javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
org.a
pache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
java.lang.Thread.run(Thread.java:724)
]]
这是代码:
try (CallableStatement cs = con.prepareCall (" { call some_proc(?,?,?,?,?,?,?,?)} ")) {
String cdpa = xmlDocument.getCleanCdpa();
String firstChar;
firstChar = cdpa.substring(0,1);
cs.registerOutParameter(7, java.sql.Types.INTEGER);
cs.registerOutParameter(6, java.sql.Types.VARCHAR);
cs.registerOutParameter(8, java.sql.Types.VARCHAR);
cdpa = cdpa.substring(0, 4);
if("3000".equals(cdpa)){
cs.setLong(1, xmlDocument.getRdn());
}
else {
cs.setLong(1, xmlDocument.getMsisdn());
}
if("0".equals(firstChar) || cdpa.length() < 4)
cs.setLong(2, stringToLong("1111"+xmlDocument.getCdpa()));
else
cs.setLong(2, xmlDocument.getCdpa());
cs.setInt(3,xmlDocument.getPeriodduration());
cs.setString(4,xmlDocument.isCallactive());
cs.setInt(5, xmlDocument.getEvent());
cs.execute();
resultMessage = cs.getString(6);
resultCode = cs.getInt(7);
if(resultCode > 0){
xml = "...";
}
else{
xml = "...";
}
cs.close();
}
起初我只是将它包装在 try 中,但它一直发出警告,所以我添加 close 并且它仍然如此。有什么见解吗?