Unfortunate Java exception: Java lang.NoSuchMethodError

I wrote an application that worked for 3 years, but!

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)

MysqLConnectionPatch. The code of 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 want to know why Boolean isvalid = false; Throw exception Java lang.NoSuchMethodError:java. sql. Connection. isValid(I)Z.

Note that the only difference is JRE (the former is 1.6 and the new is 1.7)

Solution

Strange It obviously refers to Java sql. Isvalid (int) method in connection

In your stack trace, I also see an I and a Z: Java sql. Connection. isValid(I)Z

Those correspond to int (I) and Boolean (z), which is Java sql. The exact signature of the method in conneciton So one method must be called Note: the character to the right of the bracket indicates the return type of the method, and this method returns Boolean (z)

Here is the only idea I can think of:

>The source code you provided does not correspond to the code actually running in your environment (for example, maybe your "patch" has never really been applied?) > In addition, your environment may be running Java 5 because the isvalid (int) method will not display until Java 6

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>