我遇到一个随机问题,即在使用informix执行连接时会发生以下错误:
java.sql.SQLException: System or internal error java.io.IOException
at com.informix.util.IfxErrMsg.getSQLException(Unknown Source)
at com.informix.jdbc.IfxSqli.handleSocketException(Unknown Source)
at com.informix.jdbc.IfxSqli.receiveMessage(Unknown `enter code here`Source)
at com.informix.jdbc.IfxSqli.executePrepare(Unknown Source)
at com.informix.jdbc.IfxPreparedStatement.setupExecutePrepare(Unknown Source)
at com.informix.jdbc.IfxPreparedStatement.processSQL(Unknown Source)
at com.informix.jdbc.IfxPreparedStatement.<init>(Unknown Source)
at com.informix.jdbc.IfxSqliConnect.createPreparedStmt(Unknown Source)
at com.informix.jdbc.IfxSqliConnect.prepareStatement(Unknown Source)
at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.prepareStatement(DelegatingConnection.java:291)
at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.prepareStatement(DelegatingConnection.java:291)
at br.com.solcast.integrador.dao.sisdia.PedidoVendaDAO.carregar(PedidoVendaDAO.java:169)
at br.com.solcast.integrador.service.sisdia.PedidoVendaService.carregar(PedidoVendaService.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at br.com.solcast.integrador.security.RestAuthenticationFilter.doFilter(RestAuthenticationFilter.java:43)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException
at com.informix.asf.IfxDataInputStream.readFully(Unknown Source)
at com.informix.asf.IfxDataInputStream.readSmallInt(Unknown Source)
... 61 more
我的课程连接
public class DAOManager {
private DataSource src;
private Connection con;
public void open() throws SQLException {
try {
if(this.con==null || this.con.isClosed())
this.con = src.getConnection();
} catch(SQLException e) { throw e; }
}
public void close() throws SQLException {
try {
if(this.con!=null && !this.con.isClosed()) {
this.con.close();
this.con = null;
}
} catch(SQLException e) {
throw e;
} finally {
if (this.con != null) {
try { this.con.close(); } catch (SQLException e) { ; }
this.con = null;
}
}
}
public DAOManager() throws NamingException {
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
this.src = (DataSource)envContext.lookup("jdbc/cortex-sisdia");
}
public Object gerarDAO(DAO dao) throws SQLException
{
if (this.con == null || this.con.isClosed())
this.open();
switch (dao) {
case AGENDAMENTOOFICINA:
return new AgendamentoOficinaDAO(this.con);
case ESTOQUE:
return new EstoqueDAO(this.con);
case PEDIDOVENDA:
return new PedidoVendaDAO(this.con);
case PESSOA:
return new PessoaDAO(this.con);
case VEICULO:
return new AgendamentoOficinaDAO(this.con);
default:
return null;
}
}
@Override
protected void finalize()
{
try{
this.close();
} catch (SQLException e) {
e.printStackTrace();
}
finally{
try {
super.finalize();
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
实例化新连接并执行prepareStatement后,错误会随机发生。