Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
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();
	Class        f.setMultiRow(true);
        Class.forName("com.mysql.jdbc.Driver").newInstance();
	con = DriverManager.getConnection("jdbc:mysql://localhost:3307/jwdb?characterEncoding=UTF-8", "database username", "database password");

	if(!con.isClosed()){
		String recordId = "#requestParam.id#"; // Get the url parameter
		String sql = "SELECT * FROM test_table WHERE id=?"; // Here you can query from one or multiple tables using JOIN etc
		PreparedStatement stmt = con.prepareStatement(sql);
		stmt.setString(1, recordId);
		ResultSet rs = stmt.executeQuery();
		while (rs.next()) {
		FormRow r1 = new FormRow();
			r1.put("gridColumn1", rs.getString(1));
			r1.put("gridColumn1", rs.getString(2));
			r1.put("gridColumn1", rs.getString(3));
			f.add(r1);
	   }
	}
	return f;
}
return test();

...