指令碼——loadrunner串連oracle資料庫查詢資料

來源:互聯網
上載者:User

標籤:效能測試

import java.io.*;

import java.sql.*;



 import lrapi.lr;

public class Actions

{

   int sum=0;

 

   public int init() throws Throwable {

 

      return 0;

 

   }//end of init

 

   public int action() throws Throwable {

         try{

                //定義了資料庫連接串

 

    /*DSN=ORACL_LR;UID=FASP_150001;PWD=1;DBQ=192.168.100.218:1521/ORCL;

      DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;

      BNF=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=F;CSR=F;FWC=F;

      FBS=64000;TLO=O;MLD=0;ODA=F;*/

                String dbUrl = "jdbc:odbc:ORACL_LR";  //ORACL_LR是通過oracle資料庫建立出來的資料來源(安裝完oracle資料庫後,非oracle用戶端,在開始--運行--oracle12--配置和移植工具--net manager)

                //資料庫的使用者名稱

                String user = "FASP_150001";

                //資料庫的使用者口令

                String password = "1";

                //載入jdbc-odbc bridge驅動程式


                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

 

                //與url指定的資料來源建立串連

                Connection conn = DriverManager.getConnection(dbUrl, user, password);

             

                //採用Statement進行查詢

 

                    //插入LoadRunner的事務lr_select_data_trans

                lr.start_transaction("lr_select_data_trans");

      

                Statement stat = conn.createStatement();

                ResultSet rs = stat.executeQuery("SELECT code FROM fasp_t_causer where rownum<10;");

 

      

                lr.message("\t"+"code"+"\n");

                //函數輸出表的各個欄位名字

                while(rs.next())

                {

                    lr.message("\t"+rs.getString(1)

                            +"\n");

 

                    sum=sum+1;

                }

                rs.close();

                stat.close();

                conn.close();

 

 

         lr.message("Sum="+sum);

 

             // lr_select_data_trans事務結束

         lr.end_transaction("lr_select_data_trans ",lr.AUTO);

 

         }catch(Exception e){

                e.printStackTrace();

 

                System.out.println("Test Failed");

         }

 

      

         return 0;

      }//end of action

 

   public int end() throws Throwable {

      return 0;

   }//end of end

}


指令碼——loadrunner串連oracle資料庫查詢資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.