zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    javascript DOM节点(一)
    [转]php初级教程(七)一个新闻管理系统(准备工作)
    [转]php初级教程(九)添加新闻内容程序的编写
    [转]php初级教程(六)php表单处理文件上传
    [转]php初级教程(一)php平台的搭建
    [转]php初级教程(三)php的常用函数和基本流程(20071217 14:46:16)[编辑][删除]
    [转]php初级教程(八)基本php配置文件的编写
    [转]php初级教程(十一)用户的注册
    [转]php初级教程(四)相关环境变量和服务器变量的获取
    [转]php初级教程(五)php表单处理
  • 原文地址:https://www.cnblogs.com/seamy/p/15650686.html
Copyright © 2011-2022 走看看