1. 程式人生 > >oracle壓力測試腳本

oracle壓力測試腳本

n) start sign void auto num crypt all ren

1.根據oracle(2-Tier)協議;

#include"lrd.h"
static LRD_INIT_INFO InitInfo={LRD_INIT_INFO_EYECAT};
static LRD_DEFAULT_DB_VERSION DBTypeVersion[]={{LRD_DBTYPE_NONE,LRD_DBVERSION_NONE}};
static void FAR * OraEnv1;
static void FAR * OraSvc1;
static void FAR * OraSrv1;
static void FAR * OraSes1;
static void FAR * OraStm1;
static void FAR * OraDef1;
unsigned long rownum;
vuser_init()
{
	lrd_init(&InitInfo, DBTypeVersion);
	lrd_initialize_db(LRD_DBTYPE_ORACLE, 2, 0);
	lrd_env_init(LRD_DBTYPE_ORACLE, &OraEnv1, 0, 0);
	lrd_ora8_handle_alloc(OraEnv1, SERVER, &OraSrv1, 0);
	lrd_ora8_handle_alloc(OraEnv1, SVCCTX, &OraSvc1, 0);
	lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes1, 0);
	//lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes2, 0);
	//lrd_server_attach(OraSrv1, "qa70/orcl", 9, 0, 0);
	lrd_server_attach(OraSrv1, "orcl", -1, 0, 0);//lrd_server_attach(OraSrv1, "orcl", 4, 0, 0)
	lrd_ora8_attr_set_from_handle(OraSvc1, SERVER, OraSrv1, 0, 0);
	lrd_ora8_attr_set(OraSes1, USERNAME, "system", -1, 0);//lr_decrypt("58b3e02f8ba0e4201c2c")
	//lrd_ora8_attr_set(OraSes1, PASSWORD, lr_decrypt("5487fff63e812b81"), -1, 0);
	lrd_ora8_attr_set(OraSes1, PASSWORD, "password", -1, 0);
	lrd_ora8_attr_set_from_handle(OraSvc1, SESSION, OraSes1, 0, 0);
	lrd_session_begin(OraSvc1, OraSes1, 1, 0, 0);
	lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm1, 0);
	
	return 0;
}



//Action
Action()
{
	//這裏寫上你的sql語句
	lrd_ora8_stmt(OraStm1,"select * from aa01 where aae140=‘sys‘;",1,0,0);
	lrd_ora8_stmt(OraStm1,"select * from ry_jbxx,dz_zzxx where dz_zzxx.zzbh=ry_jbxx.RYZZBH ", 1, 32, 0);


	//lr_rendezvous("querry");

	lr_start_transaction("querry");

	//執行定義的sql,並且將結果行數返回到rownum中
	lrd_ora8_exec(OraSvc1,OraStm1,0,0,&rownum,0,0,0,0,1);

	lr_end_transaction("querry", LR_AUTO);





return 0;

}

//vuser_end
vuser_end()
{

    //釋放連接數據庫
	lrd_session_end(OraSvc1, OraSes1, 0, 0); 
	lrd_server_detach(OraSrv1, 0, 0); 
	lrd_handle_free(&OraSrv1, 0);
	lrd_handle_free(&OraSvc1, 0);
	lrd_handle_free(&OraSes1, 0);
	lrd_handle_free(&OraEnv1, 0);

}

  

oracle壓力測試腳本