I wrote an application, an it was working fine for 3 years, but! today when they try to run this application, an unexpected exception raised:
INFO | jvm 1 | 2013/04/17 10:02:40 | Exception in thread "Thread-1" java.lang.NoSuchMethodError: java.sql.Connection.isValid(I)Z
INFO | jvm 1 | 2013/04/17 10:02:40 | at lib.MySQLConnectionPatch.SearchInCache(MySQLConnectionPatch.java:103)
INFO | jvm 1 | 2013/04/17 10:02:40 | at lib.MySQLConnectionPatch.getConnection(MySQLConnectionPatch.java:79)
INFO | jvm 1 | 2013/04/17 10:02:40 | at lib.SQLManager.establishSqlConnection(SQLManager.java:62)
INFO | jvm 1 | 2013/04/17 10:02:40 | at lib.SQLManager.establishSqlConnection(SQLManager.java:30)
INFO | jvm 1 | 2013/04/17 10:02:40 | at lib.tasks.classes.sql.executeQuery.execute(executeQuery.java:49)
INFO | jvm 1 | 2013/04/17 10:02:40 | at Components.TTask.run(TTask.java:86)
INFO | jvm 1 | 2013/04/17 10:02:40 | at Components.ThreadTask.run(ThreadTask.java:29)
INFO | jvm 1 | 2013/04/17 10:02:40 | at lib.tasks.classes.fori.execute(fori.java:66)
INFO | jvm 1 | 2013/04/17 10:02:40 | at Components.TTask.run(TTask.java:86)
INFO | jvm 1 | 2013/04/17 10:02:40 | at Components.ThreadTask.run(ThreadTask.java:29)
INFO | jvm 1 | 2013/04/17 10:02:40 | at lib.tasks.classes.fori.execute(fori.java:66)
INFO | jvm 1 | 2013/04/17 10:02:40 | at Components.TTask.run(TTask.java:86)
INFO | jvm 1 | 2013/04/17 10:02:40 | at Components.ThreadTask.run(ThreadTask.java:29)
INFO | jvm 1 | 2013/04/17 10:02:40 | at Components.ThreadTask.run(ThreadTask.java:44)
INFO | jvm 1 | 2013/04/17 10:02:40 | at LauncherService.LaunchService.run(LaunchService.java:38)
code of MySQLConnectionPatch.java/SearchInCache is
private Connection SearchInCache(String key) {
Connection result = null;
try{
if (!connections.isEmpty())
result = connections.get(key);
} catch (Exception ex){
}
if (result != null){
boolean isValid = false; /** THIS IS LINE 103 WHERE EXCEPTION RAISED **/
try {
Statement s = result.createStatement();
if (s.execute("SHOW STATUS;")){
isValid = true;
}
s.close();
} catch (Exception ex) {
isValid = false;
}
if (!isValid){
connections.remove(key);
messageLog.stdwar("MySQL_PATCH: ONE CONNECTION EXPIRED :: force close");
try {
result.close();
} catch (SQLException ex) {
messageLog.stderr("MySQL_PATCH: CLOSING CONNECTION ERROR: "+ex.getMessage());
}
result = null;
}
}
return result;
}
I wonder why boolean isValid = false;
raise Exception java.lang.NoSuchMethodError: java.sql.Connection.isValid(I)Z
.
Note that the only thing differs is JRE (former was 1.6, and the new is 1.7)
boolean
will never throw aNoSuchMethodError
(this exception is only thrown when you are invoking a class part of a library and that version of the class does not contain that particular method). The sources you are showing are not for the compiled and running app. Make sure you're showing the proper source for that code. – Per