BEAN SHELL SCRIPT
Replace the variables with your parameters.
#envVariable.jdbcDefaultUrl#
#envVariable.jdbcDefaultUser#
#envVariable.jdbcDefaultPassword#
=============================================
// Lit all user
import java.sql.*;
import java.util.*;
import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
public FormRowSet test() {
FormRowSet f = new FormRowSet();
f.setMultiRow(true);
Connection con = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("#envVariable.jdbcDefaultUrl#", "#envVariable.jdbcDefaultUser#", "#envVariable.jdbcDefaultPassword#"); // declare datasource
if(!con.isClosed())
{
PreparedStatement stmt = con.prepareStatement("select id, CONCAT(CONCAT(firstName, ' '), lastName) from dir_user order by firstname asc"); // SQL query
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
FormRow r1 = new FormRow();
r1.put(FormUtil.PROPERTY_VALUE, rs.getString(1));
r1.put(FormUtil.PROPERTY_LABEL, rs.getString(2));
f.add(r1);
}
}
return f;
}
return test();
Nenhum comentário:
Postar um comentário