|
java vuser中的java脚本是:
import java.io.*;
import lrapi.lr;
import java.sql.*;
public class Actions
{
int sum = 0;
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
try{
String sqldriver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(sqldriver);
System.out.println("driver is OK !");
String url ="jdbcdbc:Test_LR"; //建立数据连接,连数据库
String user = "sa"; //数据库用户名
String password = "111111";//数据库密码
String sel = "select * from UserInfo"; //执行的查询语句
Connection conn = DriverManager.getConnection(url,user,password);
System.out.println("conn succes");
//lr.start_transaction("select");
Statement sta = conn.createStatement();
ResultSet rs = sta.executeQuery(sel);
System.out.print("\t"+"UserName"+"\t"+"assWord"+"\n"); //函数输出表的各个字段名字
while(rs.next())
{
System.out.print("\t"+rs.getString(1));
System.out.print("\t"+rs.getString(2)+"\n"); sum = sum + 1 ;
}
rs.close();
sta.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
System.out.println("Test Failed");
}
lr.message("Sum = "+sum);
//lr.end_transaction("select", lr.AUTO);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
可是输出的日志为:
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Actions.
System.out: driver is OK ! Notify:
System.out: conn succes Notify:
Sum = 10
Ending action Actions.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
回放日志中没有查询结果显示!!!???
为什么??? |
|