Hi ,

I have developped a JAVA code on bean shell form binder to display the list of username available in my jwdb database in a grid column . My code work well in Eclipse  :see below code


\-\-

package JogetCode;
import java.util.*;
import java.sql.*;
public class JavaCodeForJoget {

    /*\*
     * @param args
     * @throws ClassNotFoundException
     * @throws IllegalAccessException
     * @throws InstantiationException
     \*/
    public static void main(String\[\] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "");
            if(\!conn.isClosed()){

                String sql = "SELECT * FROM dir_user";
                PreparedStatement stmt = conn.prepareStatement(sql);
                ResultSet rs = stmt.executeQuery();
                while (rs.next()) {
                    System.out.println(rs.getString(1));
               }
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

\--\-

I have adapted this code to my joget form :

See below for code :

import org.joget.apps.form.model.*;
import org.joget.apps.form.service.*;
import java.sql.*;
import org.apache.commons.collections.SequencedHashMap;
import java.util.*;

public FormRowSet test() {
    FormRowSet f = new FormRowSet();
        f.setMultiRow(true);
        Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "root", "");

    if(\!con.isClosed()){
        String sql = "SELECT * FROM dir_user";
        PreparedStatement stmt = con.prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();
        while (rs.next()) {
        FormRow r1 = new FormRow();
            r1.put("gridColumn1", rs.getString(1));
            f.add(r1);
       }
    }
    return f;
}
return test();

\-\-

my display is :

FormUtilprojectleader
gridColumn1

x

x

x

x

x

x

x

x

x

x

x

x

x

x

x

I dont see the username but only delete row button . The number of user in my db is 15 . I can see 15 lines in the grid but the nale is not being displayed.

Thank you all for your help .

| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |