/*
* LoadRunner Java script. (Build: _build_number_)
*
* Script Description:
*
*/
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import lrapi.lr;
public class Actions
{
private Connection connection;
private CallableStatement proc=null;
public int init() throws Throwable {
Class.forName("com.mysql.jdbc.Driver");// 加载驱动程序
String url = "jdbc:mysql://10.10.10.29:******/*******";// URL指向要访问的数据库名message
String user = "root";// MySQL配置时的用户名
String password = "**************";// MySQL配置时的密码
connection = DriverManager.getConnection(url, user,password);// 连续数据库
System.out.println("=========init ==========");
return 0;
}
public int action() throws Throwable {
System.out.println("connection=========" + connection);
if (!connection.isClosed()){
System.out.println("Succeeded connecting to the Database!");
}
lr.start_transaction("开始");
try{
proc = connection.prepareCall("{call sendUserMessage(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) }");
proc.setInt(1,92296);//initial_id
proc.setString(2,"1");//message_replay
proc.setString(3,"1");//_message_jobflag
proc.setString(4,"1");//_message_autoflag
proc.setInt(5,lr.eval_int("<user_id1>"));//_user_id1
proc.setString(6,"1");//_user_id1_kind
proc.setString(7,"test_123");//_user_id1_name
proc.setInt(8,lr.eval_int("<user_id2>"));//_user_id2
proc.setString(9,"2");//_user_id2_kind
proc.setString(10,"test456");//_user_id2_name
proc.setString(11,"hello how are you !");//_message_title
proc.setString(12,"Andyguo test I will resume entrusted to you, help advertent");//_message_context
proc.setString(13,"01|38772");//_message_attach
proc.setString(14,"2");//_message_kind
proc.setString(15,"<createtime>");//_message_createtime
proc.execute();
}
catch(Exception e){
e.printStackTrace();
}
lr.end_transaction("开始", lr.AUTO);
return 0;
}
public int end() throws Throwable {
proc.close();//关闭执行存储过程
connection.close();//数据库连接
return 0;
}
}