LR的java协议脚本压测oracle数据库

 

/*
 * LoadRunner Java script. (Build: _build_number_)
 * 
 * Script Description: 
 *                     
 */
 
import lrapi.lr;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
 
public class Actions
{
    Connection conn = null;
 
    public int init() throws Throwable {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.23.180:1521:orcl","csbsys","dragon");
            if (conn == null) {
  lr.abort();
     }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }catch (Exception e) {
            e.printStackTrace();
        }
 
 return 0;
    }//end of init
 
 
    public int action() throws Throwable {
        Statement st = conn.createStatement();
 ResultSet rs = null;
 
 // 场景SQL
 String exsql = "select * from M_WB_SWJL where mid = 'b9f2e69aa0ca408c8406b85b5e645d6'and zjhm = '45112119940601289X'";
        
// String exsql = "select * from m_wb_swjl where mid = '*****';";//MID精确查询
 
 try {
     lr.start_transaction("多个精确条件查询");
     rs = st.executeQuery(exsql);
     if(rs!=null){
  lr.end_transaction("多个精确条件查询", lr.PASS);
     }else{
  lr.end_transaction("多个精确条件查询", lr.FAIL);
     }
     // 结果输出 while(rs.next()){ System.out.println(rs.getString(1));}
 }catch (Exception e) {
            e.printStackTrace();
        }
        rs.close();
        st.close();
        return 0;
    }//end of action
 
 
    public int end() throws Throwable {
        conn.close();
 return 0;
    }//end of end
}
 

1)多个精确条件查询(主键">+非主键) 0.015s

2)精确查询(主键)"> 0.057s、模糊查询(主键)"> 0.052s

3)模糊查询(非主键)">0.24s

4)多个模糊件查询(主键">+非主键)0.289s

5) 多个精确条件查询(非主键">+非主键)7.829s

6)精确查询(非主键)"> 8.395s

7) 多个模糊条件查询(非主键">+非主键)20.736s

posted on 2021-12-07 11:15  seamy  阅读(65)  评论(0编辑  收藏  举报