title: How to log an error when a JDBC request returns no data from DB in Jmeter?
body: <p>I need to know how to log an error when a JDBC request returns no data from DB in Jmeter.</p>
  
  <p>I have got:</p>
  
  <p><strong>JDBC request</strong></p>
  
  <p>Query:</p>
  
  <pre><code>SELECT names 
  FROM   customers 
  </code></pre>
  
  <p>Variable names:
  namesCustomers</p>
  
  <p><strong>Then I have got a BeanShell postProcessor with script:</strong></p>
  
  <pre><code>import org.apache.jmeter.util.JMeterUtils;
  JMeterUtils.setProperty("namesCustomer", vars.get("namesCustomer_1"));
  </code></pre>
  
  <p>And finally a simple controller called "set variables" which calls an external file with the following code:
  vars.put("namesCustomer",JMeterUtils.getProperty("namesCustomer"));</p>
  
  <p>The problem is that in another SOAP request I am using the variable namesCustomer_1, and if no data is returned from DB this request fails. I need to log an error when the JDBC returns no data.</p>
  
  <p>If I add to the post processor:</p>
  
  <p>log.error("Error example"); </p>
  
  <p>I see the error logged in jmeter.log when this request is ran. I need something like:</p>
  
  <pre><code>if(JMeterUtils.setProperty("namesCustomer", vars.get("namesCustomer_1")).toString().length()==0){
  log.error("DB returned no results")
  }
  </code></pre>
  
  <p>Any Ideas on how to log an error when the JDBC request returns no data?</p>