import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.joget.apps.form.model.*;
import org.joget.commons.util.LogUtil;
public FormRowSet storeData(Element element, FormRowSet rows, FormData formData) {
FormRow row = rows.get(0);
Connection con = null;
String id="";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=myDatabase", "username", "password");
String sp="EXEC SPInsertPhoneAvailability ?,?,?";
PreparedStatement istmt = con.prepareStatement(sp);
istmt.setString(1, row.getProperty("phone"));
istmt.setString(2, row.getProperty("from"));
istmt.setString(3, row.getProperty("to"));
ResultSet rs = istmt.executeQuery();
if (rs.next()){
id=rs.getString(1);
LogUtil.info("Sample app","The id is:"+id);
}
} catch (Exception e) {
LogUtil.error("Sample app", e, "Error storing using jdbc");
}
row.setProperty("id",id);
return rows;
}
return storeData(element, rows, formData);