possible db unclosed
Hi,
This is my code for jdbc load data binder. But i dont know why joget log keep response possible db unclosed. Is there any problem with my source code?
import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import javax.sql.DataSource;
import org.joget.apps.app.service.AppUtil;
import org.apache.commons.collections.SequencedHashMap;
import java.util.*;
public FormRowSet getIslas() {
FormRowSet f = new FormRowSet();
f.setMultiRow(true);
// Connection con = null;
DataSource ds = (DataSource)AppUtil.getApplicationContext().getBean("setupDataSource");// add this
con = ds.getConnection();// add this
if(!con.isClosed()){
String recordId = "#currentUser.lastName#"; // Get the url parameter
String sql = "SELECT c_firstName, c_username FROM app_fd_registration WHERE c_username=?"; // Here you can query from one or multiple tables using JOIN etc
PreparedStatement stmt = con.prepareStatement(sql);
stmt.setString(1, recordId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
FormRow r1 = new FormRow();
r1.put("nama_syarikat", rs.getString(1));
r1.put("id_pemohon", rs.getString(2));
f.add(r1);
}
}
return f;
con.close();
}
return getIslas();