Scripting--loadrunner connecting Oracle database query data

Source: Internet
Author: User
Tags odbc throwable

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{

Defines the database connection string

/*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 is a data source created from an Oracle database (after the Oracle database is installed, non-Oracle clients, starting-running the--oracle12--configuration and porting Tools--net Manager)

User name of the database

String user = "fasp_150001";

User Password for database

String Password = "1";

Load JDBC-ODBC Bridge Driver


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

Establish a connection to the data source specified by the URL

Connection conn = drivermanager.getconnection (dburl, user, password);

Use statement to query

Insert LoadRunner Transaction 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");

Each field name of the function output table

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 Transaction End

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

}


Scripting--loadrunner connecting Oracle database query data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.