Go directly to the code, test method
public ApiResp test(ApiForm form) { IdentifyTotalData temp = new IdentifyTotalData();//创建List<IdentifyData>集合 String className = "com.mysql.jdbc.Driver";//Load database driver com.mysql.jdbc.Driver String url = "jdbc:mysql://127.0.0.1:3306/jfinal_cms?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull";//MySQL connection url: jdbc:mysql://{server address}:3306/{database name} ?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull String dbusername = "root"; // database name String password = "123456"; // password try { Class.forName(className); //Load MYSQL JDBC driver System.out.println("Success loading Mysql Driver!"); } catch (Exception e) { System.out.print("Error loading Mysql Driver!"); e.printStackTrace (); } try { Connection connect = DriverManager.getConnection(url,dbusername,password); //The connection URL is jdbc:mysql//server address/database name, and the next two parameters are the login user name and password System.out.println("Success connect Mysql server!"); Statement stmt = connect.createStatement(); ResultSet rs = stmt.executeQuery("select * from tb_video"); //tb_video is the name of your table while (rs.next()) { //next field IdentifyData data = new IdentifyData();//Create IdentifyData object data.setId(rs.getString(1));//Assign the data object, rs.getString(1) is to get the data of the first column of the current field data.setIdentifyCharacters(rs.getString(5)); data.setIdentifyCode(rs.getString(5)); data.setIdentifyImageUrl(rs.getString(8)); data.setIdentifyImageLocalUrl(null); data.setShowCharacters(rs.getString(4)); data.setShowVideoUrl(rs.getString(6)); data.setShowvideoLocaUrl(null); data.setShowImageUrl(rs.getString(8)); data.setShowIamgeLocalUrl(null); data.setVersionID(rs.getString(18)); temp.lists.add(data);//Store the data object in temp.lists } } catch (Exception e) { System.out.print("get data error!"); e.printStackTrace(); } ApiResp test = new ApiResp(form);//Create an ApiResp object test.setlists(temp.lists);//将temp.lists传给test return test; }