I have an SQL exception inside a piece of code that works under and scheduled process every day. The patch of code is as follows:
log.info("*************inicio getFactsBajaRelsNoCerradas****************"); JSONArray facts = new JSONArray(); String query = "select nrelac, imprel, fact032, pfj032, no032, ap1032, ap2032, noc032 " + "from fiatc.sdt040 left join fiatc.gactb032 on cprof = fact032 " + "where scerrada = :relCerrada and sit032 = :sitFacturador "; Map where = new HashMap<>(); where.put("relCerrada", Constants.NO); where.put("sitFacturador", Constants.ESTAT_BAIXA); Map in = JDBCUtil.jdbcExecuteQuery(Constants.CONNEXIO_SALUD, query, where); Map out = XWM.execute(Constants.JDBC, Constants.EXECUTE_QUERY, in); List<Map> valuesList = (List<Map>) out.get(Constants.VALUES); for(Map mapValues : valuesList) { JSONObject facturador = new JSONObject(); facturador.put(Constants.NRELAC, mapValues.get(Constants.NRELAC).toString().trim()); facturador.put(Constants.IMPREL, mapValues.get(Constants.IMPREL).toString().trim()); facturador.put(Constants.FACT032, mapValues.get(Constants.FACT032).toString().trim()); facturador.put(Constants.PFJ032, mapValues.get(Constants.PFJ032).toString().trim()); facturador.put(Constants.NO032, mapValues.get(Constants.NO032) != null ? mapValues.get(Constants.NO032).toString().trim() : ""); facturador.put(Constants.AP1032, mapValues.get(Constants.AP1032) != null ? mapValues.get(Constants.AP1032).toString().trim() : ""); facturador.put(Constants.AP2032, mapValues.get(Constants.AP2032) != null ? mapValues.get(Constants.AP2032).toString().trim() : ""); facturador.put(Constants.NOC032, mapValues.get(Constants.NOC032) != null ? mapValues.get(Constants.NOC032).toString().trim() : ""); facts.put(facturador); }
There should be no connection problems with this but today i have a socket closed exception in my log in:
Map out = XWM.execute(Constants.JDBC, Constants.EXECUTE_QUERY, in);
Here is my log:
2022-07-06 07:00:27,262 [] INFO [es.fiatc.xwm.jdbc.ExecuteQuery.executeQuery]- Executing query: select nrelac, imprel, fact032, pfj032, no032, ap1032, ap2032, noc032 from fiatc.sdt040 left join fiatc.gactb032 on cprof = fact032 where scerrada = ? and sit032 = ? 2022-07-06 07:00:27,278 [] INFO [es.fiatc.xwm.jdbc.ExecuteQuery.executeQuery]- With params: [N, BA] 2022-07-06 07:01:30,020 [] ERROR [es.fiatc.xwm.jdbc.ExecuteQuery.execute]- com.microsoft.sqlserver.jdbc.SQLServerException: Socket closed at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2435) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1991) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:6310) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:7545) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:465) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:409) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7151) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2478) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:219) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:199) ~[mssql-jdbc-6.2.2.jre8.jar:?] at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:331) ~[mssql-jdbc-6.2.2.jre8.jar:?] at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:121) ~[tomcat-dbcp.jar:9.0.63] at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:121) ~[tomcat-dbcp.jar:9.0.63] at es.fiatc.xwm.jdbc.ExecuteQuery.executeQuery(ExecuteQuery.java:83) ~[965bfc6983ba2d05e4f861434399d06b8091c0c4.1631203556828/:?] at es.fiatc.xwm.jdbc.ExecuteQuery.execute(ExecuteQuery.java:39) ~[965bfc6983ba2d05e4f861434399d06b8091c0c4.1631203556828/:?] at es.fiatc.xwm.jdbc.ExecuteQuery.execute(ExecuteQuery.java:53) [965bfc6983ba2d05e4f861434399d06b8091c0c4.1631203556828/:?] at es.fiatc.xwm.mod.props.DefaultModule.execute(DefaultModule.java:100) [general-7.0.4.jar:?] at es.fiatc.xwm.XWM.execute(XWM.java:148) [general-7.0.4.jar:?] at es.fiatc.sld_facturadors.db.FacturadorsDB.getFactsBajaRelsNoCerradas(FacturadorsDB.java:996) [5e123940-6ba6-4fb5-a913-9044a66ae3ef/:?] at es.fiatc.sld_facturadors.dao.CercaDAO.getFactsBajaRelsNoCerradas(CercaDAO.java:69) [5e123940-6ba6-4fb5-a913-9044a66ae3ef/:?] at es.fiatc.sld_facturadors.actions.scheduler.FactsBajaRelsNoCerradasAction.execute(FactsBajaRelsNoCerradasAction.java:50) [5e123940-6ba6-4fb5-a913-9044a66ae3ef/:?] at es.fiatc.xwm.mod.props.DefaultModule.execute(DefaultModule.java:100) [general-7.0.4.jar:?] at es.fiatc.xwm.XWM.execute(XWM.java:148) [general-7.0.4.jar:?] at es.fiatc.launcher.xwm.XWMJob.execute(XWMJob.java:33) [62b55c76-b327-4cf5-b4a6-1ac84589f545/:?] at es.fiatc.launcher.ExecutionJob.run(ExecutionJob.java:38) [62b55c76-b327-4cf5-b4a6-1ac84589f545/:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_271] Caused by: java.net.SocketException: Socket closed at java.net.SocketInputStream.socketRead0(Native Method) ~[?:1.8.0_271] at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[?:1.8.0_271] at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[?:1.8.0_271] at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:1.8.0_271] at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1981) ~[mssql-jdbc-6.2.2.jre8.jar:?] ... 24 more
Any thoughts about why this could happen? First time this schedule gives us problems.
I have searched for other answers so i know that there should be a connection closed somewhere but we are using XWM for connections with our BBDD that´s why i am a little lost about this I have the feeling that i am missing some critical knowledge.
Advertisement
Answer
It has been a week and didn´t repeat, we suspect it was something outside our sphere of managment like a server going down at the exact moment of the call or something like that.
Not worth to keep searching for it so we gave the problem as solved until it happens again.