简体   繁体   中英

how to handle java.lang.AbstractMethodError: com.mysql.jdbc.JDBC4CallableStatement.closeOnCompletion()

I am using mysql-connector-java-5.1.20-bin.jar with jdk7 and tomcat7 but my code is giving abstractMethodError while executing callableStatement.closeOnCompletion().Code is given below :

try {

    Session session = HibernateUtil.currentSession();
    CallableStatement st = session.connection().prepareCall(
    "{call getOfflineNodes('" + strDevice + "',"
    + System.currentTimeMillis() + "," + polltime + ","+ status + ")}");
    ResultSet rs = st.executeQuery();
    Transaction tx = session.beginTransaction();
    st.closeOnCompletion();
    tx.commit();
    HibernateUtil.closeSession();
    return rs;
}

and complete exception is :

java.lang.AbstractMethodError: com.mysql.jdbc.JDBC4CallableStatement.closeOnCompletion()V
at com.clearcube.util.DMLLayer.getOfflineNodes(DMLLayer.java:90)
at com.clearcube.logging.ShutBladeAlertService.<init>(ShutBladeAlertService.java:80)
at com.clearcube.common.CMSServiceLoaderServlet.init(CMSServiceLoaderServlet.java:95)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5015)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5302)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

can anybody tell me why this exception is coming and how to handle this.

code where i am using this returned resultSet is :

timer.scheduleAtFixedRate(new TimerTask() {
          public void run()
          {
            String bladeMacs = "";
            String vmMacs = "";
            try
            {
              int poll = Integer.parseInt(
                ServerConfigurationService.getProperty("blade.refresh.time"));

              Calendar callendar = Calendar.getInstance();

              String strblade = "";
              String strvm = "";
              String Ip = "";
              ResultSet BladeRs = (ResultSet)DMLLayer.getOfflineNodes(
                "Blade", poll, 1);
              if (BladeRs != null) {
                boolean isBladeAlive = false;
                int x = 0;
                try {
                  while (BladeRs.next()) {

                    String mac = BladeRs.getString("macAddress");
                    String ip = BladeRs.getString("Ip");
                    isBladeAlive = 
                      EchoUDPClientDiscoveryObjectResponse.echo(InetAddress.getByName(BladeRs
                      .getString("Ip")), 6502, "any", 
                      3, 500);

                    if (!isBladeAlive) {

                      if (x > 0)
                      {
                        strblade = strblade + "\n";
                        bladeMacs = bladeMacs + "\n";
                      }

                      strblade = strblade + ip;
                      x = 2;
                      bladeMacs = bladeMacs + mac;
                    }
                    else
                    {
                        String query = "update DiscoveredNode set DateModified=:DateModified where MacAddress=:MacAddress";

                      ShutBladeAlertService.objTypeVector.removeAllElements();
                      ShutBladeAlertService.objFieldVector.removeAllElements();
                      ShutBladeAlertService.objValueVector.removeAllElements();

                      ShutBladeAlertService.objTypeVector.add("Long");
                      ShutBladeAlertService.objFieldVector.add("DateModified");
                      ShutBladeAlertService.objValueVector.add(
                        Long.valueOf(System.currentTimeMillis()));
                      ShutBladeAlertService.objTypeVector.add("String");
                      ShutBladeAlertService.objFieldVector.add("MacAddress");
                      ShutBladeAlertService.objValueVector.add(mac);

                      DMLLayer.runUpdateQuery(query, 
                        ShutBladeAlertService.objFieldVector, ShutBladeAlertService.objValueVector, 
                        ShutBladeAlertService.objTypeVector);
                    }
                  }

                  BladeRs.close();

                }
                catch (Exception ex1) {
                  ex1.printStackTrace();
                }

              }
          }
      }

Thanks in advance.

closeOnCompletion() exists since Java 7. And the driver has been implemented with a previous version of the interface. So this method is not implemented by the MySQL driver.

Find if a more recent version exists with support for this method (but it doesn't seem to exist), or avoid calling this method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM