Forum Discussion
Steven_Smith
17 years agoNew Contributor
Forgot to include the script
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.*;
public class JDBCExample1 {
public static void main(String[] args) {
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){}
}
}
}
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.*;
public class JDBCExample1 {
public static void main(String[] args) {
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){}
}
}
}
Related Content
- 3 years agosparrowenclave
Recent Discussions
- 16 hours agoruchisingh