Error Scripting when using bean shell form binder to store data
Hi,
I want to insert Quantity in grid listing, but when i insert the record and Click Submit button , the error message displayed as below. For load grid im using JDBC, and for store the data using Bean Shell form binder.
I'm already refer this link below. Anyone can help me?
Load and Store Form Grid Data Using Bean Shell Form Binder
Code for Load Using JDBC
SELECT id, c_TypeRequisition FROM app_fd_TypeRequisition
→ to get value TypeRequisition from table TypeRequisition
Code for Store Data
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.Form;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.apps.form.service.FormUtil;
import org.joget.commons.util.UuidGenerator;
public saveGridRows(Element element, FormRowSet rows, FormData formData) {
String recordId = null;
Connection con = null;
try {
//Get Joget's current datasource configs
DataSource ds = (DataSource) AppUtil.getApplicationContext().getBean("setupDataSource");
con = ds.getConnection();
if(!con.isClosed()) {
//To generate new record IDs for storing into child table
// UuidGenerator uuid = UuidGenerator.getInstance();
//Iterate to add new records
Iterator i= rows.iterator();
while (i.hasNext()) {
FormRow row = (FormRow) i.next();
// String pId = uuid.getUuid();
String TypeRequisition = row.get("TypeRequisition");
String Quantity= row.get("Quantity");
String CTC = row.get("CTC");
String insertSql = "INSERT INTO app_fd_CompanySecretary (TypeRequisition,Quantity,CTC) VALUES (?,?,?);";
PreparedStatement stmtInsert = con.prepareStatement(insertSql);
//stmtInsert.setString(1, pId);
stmtInsert.setString(1, TypeRequisition);
stmtInsert.setString(2, Quantity);
stmtInsert.setString(3, CTC);
//Execute SQL statement
stmtInsert.executeUpdate();
}
}
} catch (Exception ex) {
LogUtil.error("Your App/Plugin Name", ex, "Error storing using jdbc");
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception ex) {
LogUtil.error("Your App/Plugin Name", ex, "Error closing the jdbc connection");
}
}
}
//Process and store grid rows
saveGridRows(element, rows, formData);

