quinta-feira, 23 de janeiro de 2014

JOGET Bean Shell Form Binder

An example of how to populate a combo using Bean Shell Form Binder.
Pay attention to the driver
com.microsoft.sqlserver.jdbc.SQLServerDriver
I'm connecting to a Microsoft SQLServer.



// Listar todas as demandas
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.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverManager.getConnection("jdbc:sqlserver://148.6.7.999:1433;databaseName=dbChapolim;user=usr_kiko;password=usr_kiko;"); // declare datasource

if(!con.isClosed())
{
PreparedStatement stmt = con.prepareStatement("select NomeSistema ID, NomeSistema from TB_SISTEMA order by NomeSistema 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