我想问一下,是否有方法通过代码创建JMeter的JDBC连接配置实例,而不是通过GUI创建。Jmeter在java代码中创建JDBC连接配置实例
我有以下线程组:
SetupThreadGroup threadGroup = new SetupThreadGroup();
threadGroup.setNumThreads(jMeterParam.getNumOfConnections());
threadGroup.setRampUp(0);
threadGroup.setDuration(7200);
JDBCSampler sampler = new JDBCSampler();
sampler.setQuery("select top 1 * from Production.ProductPhoto;");
sampler.setVariableNames("firstPrfile");
sampler.setQueryType("Select Statement");
ConstantTimer timer = new ConstantTimer();
timer.setDelay("300");
我需要为了设置JMeter的变量名,连接的最大数目,池超时,并在JDBC连接配置JMeter的GUI所有即时拍摄参数来创建JDBCConnectionConfiguration实例。
问题是我需要编写java代码才能配置测试计划并通过JMeter运行它。 我也想你的建议,以创建JDBC连接波纹管:
SetupThreadGroup threadGroup = new SetupThreadGroup();
threadGroup.setNumThreads(jMeterParam.getNumOfConnections());
threadGroup.setRampUp(0);
threadGroup.setDuration(7200);
DefaultPoolController defaultPoolController = new DefaultPoolController();
JdbcConnectionFactory jdbcFactory = new JdbcConnectionFactory("jdbc:sqlserver://10.10.10.171:1401;databaseName=AdventureWorks","sa","[email protected]",true,"True","com.microsoft.sqlserver.jdbc.SQLServerDriver");
JdbcConnectionPool jdbcConnPool= new JdbcConnectionPool(jdbcFactory,defaultPoolController,0,10,true);
JDBCSampler sampler = new JDBCSampler();
sampler.setQuery("select top 1 * from Production.ProductPhoto;");
sampler.setVariableNames("firstPrfile");
sampler.setQueryType("Select Statement");
ConstantTimer timer = new ConstantTimer();
timer.setDelay("300");
sampler.addTestElement(timer);
// Test plan
TestPlan testPlan = new TestPlan("MY TEST PLAN");
hashTree.add("testPlan", testPlan);
hashTree.add("threadGroup", threadGroup);
hashTree.add("JDBC Connection Configuration", jdbcConnPool);
hashTree.add("sampler", sampler);
jm.configure(hashTree);
jm.run();
当运行WARN味精所示: 1)“用于装载bean类org.apache.jmeter.protocol.jdbc豆信息当坏事发生。 sampler.JDBCSampler “ 2)没有发现” ..... ApacheJMeter.jar /公地IO-2.2.jar的/ etc ....
你知道如何解决这个问题?
谢谢很多, 希洛