try {
// retrieve connection from the default datasource
DataSource ds = (DataSource)AppUtil.getApplicationContext().getBean("setupDataSource");
con = ds.getConnection();
// execute SQL query
if(!con.isClosed()) {
String id = "18a8680c-1b6a-4425-b940-14230912db06";
stmt = con.prepareStatement("SELECT c_requestId,c_code from app_fd_vt_ali_sms_log where id=?");
stmt.setObject(1, id);
rs = stmt.executeQuery();
while (rs.next()) {
FormRow row = new FormRow();
row.setProperty("requestId", (rs.getObject("c_requestId") != null)?rs.getObject("c_requestId").toString():"");
row.setProperty("code", rs.getObject("c_code"));
rows.add(row);
}
}
} catch(Exception e) {
LogUtil.error("Sample app - Form 1", e, "Error loading data in load binder");
} finally {
//always close the connection after used
try {
if (rs != null) {
rs.close();
rs = null;
}
} catch (SQLException e) {/* ignored */}
try {
if (stmt != null) {
stmt.close();
stmt = null;
}
} catch (SQLException e) {/* ignored */}
try {
if (con != null) {
con.close();
con = null;
}
} catch (SQLException e) {/* ignored */}
}