JMeter使用JDBC Request取样器 获取查询结果
- 数据库连接配置
- 定义全局变量
- JDBC Request
创建文件路径以及文件的脚本
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
boolean result = false;
try {//String message= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(System.currentTimeMillis()));String message = vars.get("abc");//String message= String.valueOf(2);SimpleDateFormat formatter= new SimpleDateFormat("yyyyMMddHHmmss");Date date = new Date(System.currentTimeMillis());System.out.println(formatter.format(date));String logfile = vars.get("log");File folder = new File(logfile);File file = new File(folder.getPath()+"\\\\"+formatter.format(date)+".log");if(folder.exists() && file.createNewFile()) { result=true; }else if(folder.mkdir()&&file.createNewFile()) { result=true; }if(result){FileOutputStream out = new FileOutputStream(file);byte[] bytes = message.getBytes();out.write(bytes);out.close();SampleResult.setSuccessful(true);}else{SampleResult.setSuccessful(false);}
}catch (Exception e){e.printStackTrace();SampleResult.setSuccessful(false);
}
参考网址
Java json与object互转【Java json与object互转_jsonobject转object_java后生的博客-CSDN博客】
java如何判断文件或文件夹是否存在?【https://blog.csdn.net/weixin_45987729/article/details/124503383】
jmeter连接数据库-取数据【https://blog.csdn.net/weixin_40385652/article/details/115490432】
Jmeter常见使用方法【https://blog.csdn.net/weixin_41923467/article/details/127206795】【https://blog.csdn.net/qq_45138120/article/details/124056704】
使用JMeter进行MySQL的压力测试,对查询结果进行简单处理【https://zhuanlan.zhihu.com/p/551932532?utm_id=0】
【性能测试】JMeter(二)--进阶篇(提取多个值并遍历使用【https://blog.csdn.net/qq_35061334/article/details/123599146】
Java Object转JSONObject,ArrayList,取值【https://blog.csdn.net/qqqwwweeerasd/article/details/124629234】