Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
I found it this is correct
r1.put(FormUtil.PROPERTY_VALUE, rs.getString(1));
r1.put(FormUtil.PROPERTY_LABEL, rs.getString(1));
type of con is not defined. It should be
Connection con = DriverManager.getConnection("jdbc:sqlserver://host:1433;DatabaseName=databasename;useUnicode=true;characterEncoding=UTF-8", "database user", "database password");
You're returning the result before closing the connection.
con.close(); return f;
Thank you for your help but it didn't change anything.
I try to load name and surname to a select box, from an external MS SQL server and then retrieve the mail of that selected user. I get no error but the list shows only blank entries.
I've used JDBC Datalist Database Binder and works fine. Do you have any idea how can I do this?
I really appreciate any help you can provide.
This is my 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.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverManager.getConnection("jdbc:sqlserver://host:1433;DatabaseName=databasename;useUnicode=true;characterEncoding=UTF-8", "database user", "database password");
if(!con.isClosed()){
String sql = "SELECT surname FROM Table";
PreparedStatement stmt = con.prepareStatement(sql);
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(1));
f.add(r1);
}
}
return f;
con.close();
}
return test();