I have an error in Groovy sql.executeQuery():GRAVE: Message: Operation not allowed after ResultSet closed

1
0
-1

Hi all

I am a newbie at Bonita 7.2, struggling with displaying values, retrieved from a My SQL DB, in a custom table Widget. I need a little help, please.
I'm executin a groovy script, from Bonita 7.2 and I get an error saying: GRAVE: Message: Operation not allowed after ResultSet closed . I don't understand it because I don't have closed the resultSet.

This is my GroovyScript:

                 String consulta = "SELECT * FROM reportes";

                 SMSOpConfig smsOpConfig = new SMSOpConfig();
                 SMSOpBase.connectSMS(smsOpConfig.getDBUrl(), smsOpConfig.getDBUser(), smsOpConfig.getDBPass());
                 //SMSOpBase.connectSMS();
                 loggerJava.info("Notificacion: desc");
                         //+notificacionRiesgo.getDescripcion() +" , titulo: "+ notificacionRiesgo.getTitulo() +" , codigo: "+notificacionRiesgo.getCodigo(), notificacionRiesgo.getOperador(),notificacionRiesgo.getTipoOperacion(), notificacionRiesgo.getMatricula(), notificacionRiesgo.getVuelo(), notificacionRiesgo.getCallSign(), notificacionRiesgo.getModerador(), notificacionRiesgo.getEstado(), notificacionRiesgo.getObligatoriedad(), notificacionRiesgo.getIncidenciaPadre(), notificacionRiesgo.getDni(),notificacionRiesgo.getNombre(),notificacionRiesgo.getApellidos(),notificacionRiesgo.getCorreo(),notificacionRiesgo.getTipo()+" , asunto: "+notificacionRiesgo.getAsunto());
                 resultSet = SMSOpBase.getConn().executeQuery(consulta);
                 //   (consulta,notificacionRiesgo.getId(),notificacionRiesgo.getDescripcion(),notificacionRiesgo.getTitulo(),notificacionRiesgo.getCodigo(), notificacionRiesgo.getOperador(),notificacionRiesgo.getTipoOperacion(), notificacionRiesgo.getMatricula(), notificacionRiesgo.getVuelo(), notificacionRiesgo.getCallSign(), notificacionRiesgo.getModerador(), notificacionRiesgo.getEstado(), notificacionRiesgo.getObligatoriedad(), notificacionRiesgo.getIncidenciaPadre(), notificacionRiesgo.getDni(),notificacionRiesgo.getNombre(),notificacionRiesgo.getApellidos(),notificacionRiesgo.getCorreo(),notificacionRiesgo.getTipo(),notificacionRiesgo.getAsunto(),new Date());
                 while (resultSet.next()) {
                         loggerJava.info("************************************** REPORTES id: " + resultSet.getInt("id") +
                                 "entidad_reportante: " + resultSet.getString(2) +
                                 " entidad_reportante_name: " + resultSet.getString(3));
                   }
//               SMSOpBase.closeConnection();
                 loggerJava.info("#########################################################################################################script eNTRADA , scriptLeeReportes");
                 /*
                logger.error("-----ERROR guardar en bbdd"); */

        } catch (e2) {
                loggerJava.error("ERROR: scriptLeeReportes Notificación de BBDD*********************************");
                // loggerJava.error("Cause: "+          e2.getCause());
                loggerJava.error("Message Localized: "+         e2.getLocalizedMessage().toString());
                loggerJava.error("Message: "+           e2.getMessage().toString());
                loggerJava.error("GetStacktrace.ToString: "+            e2.getStackTrace().toString());
        }finally{
          try{resultSet.close();}catch(Exception e){}
          try{SMSOpBase.closeConnection();}catch(Exception e1){
                  loggerJava.error("ERROR: scriptLeeReportes Notificación de BBDD*********************************");
                  // loggerJava.error("Cause: "+                e2.getCause());
                  loggerJava.error("Message Localized: "+               e1.getLocalizedMessage().toString());
                  loggerJava.error("Message: "+         e1.getMessage().toString());
                  loggerJava.error("GetStacktrace.ToString: "+          e1.getStackTrace().toString());
          }
   }

Here is the hole StackTrace:

GRAVE: GetStacktrace.ToString: [com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074), com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988), com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974), com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919), com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:804), com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:6986), java_sql_ResultSet$next.call(Unknown Source), org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48), org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113), org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117), Script1.run(Script1.groovy:93), groovy.lang.GroovyShell.evaluate(GroovyShell.java:591), groovy.lang.GroovyShell.evaluate(GroovyShell.java:629), groovy.lang.GroovyShell.evaluate(GroovyShell.java:600), org.bonitasoft.connectors.scripting.GroovyScriptConnector.executeBusinessLogic(GroovyScriptConnector.java:48), org.bonitasoft.engine.connector.AbstractConnector.execute(AbstractConnector.java:77), org.bonitasoft.engine.core.connector.impl.SConnectorAdapter.execute(SConnectorAdapter.java:73), org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:205), org.bonitasoft.engine.connector.impl.ConnectorExecutorImpl$ExecuteConnectorCallable.call(ConnectorExecutorImpl.java:176), java.util.concurrent.FutureTask.run(FutureTask.java:262), java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145), java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615), java.lang.Thread.run(Thread.java:745)]

Thank you!!

Comments

Submitted by Lionel Palacin on Wed, 07/20/2016 - 04:55

Hi,

That's weird indeed. The code looks fine. However, how do you build your form, I wonder how you execute Groovy script in a form?

Cheers

Submitted by hectorta on Wed, 07/20/2016 - 15:52

The Groovy script is an On enter connector defined in a task and its executed when the activity is started.

Submitted by Lionel Palacin on Thu, 07/21/2016 - 20:12

I see. What value does your script return? I don't see any return in the code provided.

Thanks

Submitted by Lionel Palacin on Thu, 07/21/2016 - 20:14

Also, for this kind of operation, I would recommend to use a Database connector. They have better performance than a Groovy script connector.

Cheers

Submitted by hectorta on Fri, 07/22/2016 - 12:29

Ok, thnak you, I want to have one unique groovy script ot have many diferentes data base queries, and don't have to write many differents data base connecto,one for each query.

Thank you for your help.

No answers yet.
Notifications