I have improved my program which I am posting here in case it could be useful to others.
Code: Select allpackage com.openkm.workflow.archivage;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.bean.form.*;
public class InsertionMysql implements ActionHandler {
/**
*
*/
private static final long serialVersionUID = 1L;
//int date = 10;
//String direction = "informatique";
//String ordonnateur = "KOUADIO";
//String document = "stage";
//String justificatif = "Rappoart de stage";
//String description = "Stage pratique";
//String duree = "2 mois";
//String observations = "RAS";
@Override
public void execute(ExecutionContext executionContext) throws Exception {
Input date = (Input)executionContext.getContextInstance().getVariable("date");
Select direction = (Select) executionContext.getContextInstance().getVariable("direction");
Select requerant = (Select)executionContext.getContextInstance().getVariable("requerant");
Input document = (Input)executionContext.getContextInstance().getVariable("document");
Input justificatif = (Input)executionContext.getContextInstance().getVariable("justificatif");
TextArea description = (TextArea)executionContext.getContextInstance().getVariable("description");
Input duree = (Input)executionContext.getContextInstance().getVariable("duree");
TextArea observations = (TextArea)executionContext.getContextInstance().getVariable("observations");
Input avisarchiviste = (Input)executionContext.getContextInstance().getVariable("avisarchiviste");
Input dateretour = (Input)executionContext.getContextInstance().getVariable("dateretour");
// Input relance = (Input)executionContext.getContextInstance().getVariable("relance");
Input noteimportante = (Input)executionContext.getContextInstance().getVariable("noteimportante");
Input dateeffectiveretour = (Input)executionContext.getContextInstance().getVariable("dateeffectiveretour");
Input retard = (Input)executionContext.getContextInstance().getVariable("retard");
Input commentaire = (Input)executionContext.getContextInstance().getVariable("commentaire");
String myDriver = "com.mysql.jdbc.Driver";
String myUrl = "jdbc:mysql://localhost:3306/okmdb";
Class.forName(myDriver);
Connection conn = DriverManager.getConnection(myUrl, "kouadio", "1234");
Statement st = conn.createStatement();
// String sql1 = "INSERT INTO WORKFLOW_ARCHIVAGE (Ordre, Date, Direction, Requerant, document, Justificatif, Description, Duree, Observations) VALUES (Null, CURRENT_DATE(), '" + direction.getValue() + "', '" + requerant.getValue()+ "', '" + document.getValue()+ "', '" + justificatif.getValue()+ "', '" + description.getValue()+ "', '" + duree.getValue() +"', '" + observations.getValue()+"')";
String sql2 = "INSERT INTO WORKFLOW_ARCHIVAGE (Ordre, Date, Direction, Requerant, document, Justificatif, Description, Duree, Observations, avisarchiviste, dateretour, noteimportante, dateeffectiveretour, retard, commentaire) VALUES (Null, CURRENT_DATE(), '" + direction.getValue() + "', '" + requerant.getValue()+ "', '" + document.getValue()+ "', '" + justificatif.getValue()+ "', '" + description.getValue()+ "', '" + duree.getValue() +"', '" + observations.getValue()+"', '"+ avisarchiviste.getValue()+"', '"+ dateretour.getValue()+"', '"+ noteimportante.getValue()+"', '"+ dateeffectiveretour.getValue()+"', '"+ retard.getValue()+"', '"+ commentaire.getValue()+"')";
// if (executionContext.getContextInstance().getVariable("dateeffectiveretour") == null) {
// st.executeUpdate(sql1);
// }
// else {
st.executeUpdate(sql2);
// }
conn.close();
}
}