import java.sql.*;
import java.util.ArrayList;

String driver = "com.mysql.cj.jdbc.Driver";
String url = "XXX";
String user = "XXX";
String password = "XXX";
try {
    Class.forName(driver);
    Connection connection = DriverManager.getConnection(url, user, password);
    Statement statement = connection.createStatement();
    String sql = "XXXXXXXXXXXXXXXXXXXX";//sql语句
    ResultSet resultSet = statement.executeQuery(sql);//执行sql
    String res = null;
    ArrayList list = new ArrayList();//按需处理
    while (resultSet.next()){
        res = resultSet.getString("version_code");//按需处理
        list.add(res);//按需处理
    }
    int size = list.size();//按需处理
    Object obj = list.get(size-2);//按需处理
    log.info(obj);
    vars.put("version_code", obj);//设置变量为version_code,后面步骤可用${version_code}引用
    resultSet.close();
    connection.close();
} catch (Exception throwables) {
        throwables.printStackTrace();
}


↙↙↙阅读原文可查看相关链接,并与作者交流