Forum Discussion
omatzura
17 years agoSuper Contributor
Hi Steven,
thanks for your post.. I don't think you should wrap the script in a class / main method.. try just
Hope this helps!
regards,
/Ole
eviware.com
thanks for your post.. I don't think you should wrap the script in a class / main method.. try just
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.model.testsuite.*;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try{
Class.forName("oracle.jdbc.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@someserver:1526:service",
"username", "password");
stmt = con.createStatement();
rs = stmt.executeQuery("select * from table where field like('somevalue%')");
while (rs.next()) {
SoapUI.log("user id: " + rs.getLong(1) + " username: " + rs.getString(2));
}
//print out properties
def propertyStep = testRunner.getTestCase().getTestStepByName("UserProperties");
SoapUI.log("baseName = " + propertyStep.getPropertyValue("baseName"));
//SoapUI.log("testing " + testRunner.testCase.name);
//SoapUI.log("baseName = " + context.getProperty("UserProperties", "baseName"));
}catch(SQLException e){
e.printStackTrace();
}catch(ClassNotFoundException e){
e.printStackTrace();
}finally{
try{rs.close();}catch(Exception e){}
try{stmt.close();}catch(Exception e){}
try{con.close();}catch(Exception e){}
}
Hope this helps!
regards,
/Ole
eviware.com
Related Content
- 4 years agosparrowenclave
Recent Discussions
- 15 hours agoKLWallace
- 7 days agoruchisingh