Tomcat-Konfiguration mit DBCP

Bekommen wir ein CommunicationsException (von DBCP) nach iding für eine Weile (ein paar Stunden). Die Fehlermeldung (der Ausnahme) wird am Ende dieser Frage - aber ich sehe nicht ein wait_timeout definiert in einer der Konfigurations-Dateien. (Wo sollten wir suchen? Irgendwo aus dem tomcat/conf-Verzeichnis?).

Zweitens, wie vorgeschlagen, durch die Ausnahme, wo findet man den "Connector/J-Verbindung-Eigenschaft 'autoReconnect=true'"? Hier ist die Ressourcen-definition in der Datei conf/context.xml in tomcat einrichten:

<Resource name="jdbc/TomcatResourceName" auth="Container" type="javax.sql.DataSource"
           maxActive="100" maxIdle="30" maxWait="10000"
           removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"
           username="xxxx" password="yyyy"
           driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://127.0.0.1:3306/dbname?autoReconnect=true"/>

Drittens, warum die JVM warten Sie, bis der Aufruf von executeQuery() die Ausnahmen? Wenn die Verbindung hat das Zeitlimit überschritten, die getConnection-Methode sollte die Ausnahme sein, sollte es nicht? Dies ist der Abschnitt der source-code, den ich spreche:

        try {
                conn = getConnection (true);
                stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
                                                ResultSet.CONCUR_READ_ONLY);
                rset = stmt.executeQuery (bQuery);
                while (rset.next()) {
                     ....

Schließlich, hier sind die 1. paar Zeilen der Stack-trace,...

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 84,160,724 milliseconds ago.  The last packet sent successfully to the server was 84,160,848 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3291)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1938)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2107)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2642)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2571)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1451)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)

Diese sind die Gründe, einige von uns denken, "vergessen dbcp, es kann also abhängig von IDE-Konfigurationen und unter-die-Haube Magie, die DriverManager.getConnection(...) kann mehr zuverlässig". Alle Kommentare zu, dass? Danke für deine Einblicke, - MS

Schreibe einen Kommentar