Hi all, I am new to AXON IVY. Hope you can be patient with me.
I am trying to use that code above (provided by Ivy Support Team) in a Java class in a CustomValidator class to look up a database table. Somehow I could not resolve the Ivy object.
I tried looking up getProcessEngineHook method in https://developer.axonivy.com/doc/latest/PublicAPI but the search doesn't return any results.
My codes as follows:
package trial.facesValidation;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import java.sql.Connection;
// To validate if Item Name already existed in Parts table in Database
@FacesValidator("trial.facesValidation.CustomItemValidator")
public class CustomItemValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
//connect to the database
Connection dbconnection = ivy.getProcessEngineHook().getDbConnection("TrialDBConn");
try
{
// execute some sql queries
} finally {
// close the connection
dbconnection.close();
}