Jmeter Run SQL script from file

2019-09-21 03:22发布

问题:

I am trying to run a couple SQL scripts in a Jmeter SetUp thread. Is it possible to run the SQL code from a .SQL file through Jmeter so I can initialize a database before my other threads get executed. I just don't want to break my code up and copy/paste code inside Jmeter using JDBC connection and JDBC request. Thanks!

回答1:

__FileToString() function seems to be something you're looking for, you can put it inside your JDBC Request sampler and specify path to your .sql file there like:

See Apache JMeter Functions - An Introduction to get familiarized with the JMeter Functions concept