Bonjour,
dans le cadre d'une application jsp ou je gère des donnés sauvegardées dans une base de données MySQL je rencontre des soucis pour accéder à celle-ci. La connexion s'effectue sans soucis mes requêtes, son correctement exécutées seulement au bout d'un certain moment je ne peux plus accéder à ma base de donnée. Voici le message d'erreur :
J'ai lu que cela pouvait venir d'un problème de firewall, seulement ce n'est pas le cas puisque j'arrive à accéder à mes donnés pendant un certains laps de temps.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 Last packet sent to the server was 60 ms ago. com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error: ** BEGIN NESTED EXCEPTION ** com.mysql.jdbc.exceptions.jdbc4.CommunicationsException MESSAGE: Communications link failure Last packet sent to the server was 60 ms ago. STACKTRACE: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 60 ms ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465) at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1383) at bean.BaseDeDonnees.execQuery(BaseDeDonnees.java:47) at bean.Requetes.getFilles(Requetes.java:26) at org.apache.jsp.filles_jsp._jspService(filles_jsp.java:186) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at servlet.EncodingFilter.doFilter(EncodingFilter.java:30) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Unknown Source) Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2431) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2882) ... 33 more ** END NESTED EXCEPTION **
Autre chose, il me suffit de redémarrer mon serveur tomcat pour que je puisse y re-acceder...
J'ai cherché du coté de la fermeture de ma connexion à ma base de données, seulement cela ne change rien non plus quelle que soit le moment ou j'effectue la fermeture.
voici comment j'effectue ma connexion :
et ensuite j'ai mes propres methodes execQuery et execUpdate
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 private static Connection getConnexion() throws SQLException { if (instance_cnx == null) { try { Class.forName(PILOTE); } catch (ClassNotFoundException e) { System.out.println("pb durant la connexion"); } instance_cnx = DriverManager.getConnection("jdbc:mysql://86.***.***.**:3306/" + NOMBASE, UTILISATEUR,MOTDEPASSE); } return instance_cnx; }
que j'appelle dans une classe abstraite contenant mes requêtes.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 public static ResultSet execQuery(String query) throws SQLException { getConnexion(); Statement s = instance_cnx.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, 0); rs = s.executeQuery(query); return rs; }
Si jamais quelqu'un a une idée je lui en serais très reconnaissant car ça fait un moment que je suis bloqué la-dessus
Partager