????1. ???? JDBC ????(sqljdbc4.jar)
????2. ?? run-time setting ?μ? classpath ?? JDBC ????????
1 /*
2  * LoadRunner Java script. (Build: _build_number_)
3  *
4  * Script Description:
5  *
6  */
8 import lrapi.lr;
9 import java.io.*;
10 import java.sql.Connection;
11 import java.sql.DriverManager;
12 import java.sql.ResultSet;
13 import java.sql.ResultSetMetaData;
14 import java.sql.SQLException;
15 import java.sql.Statement;
16 import lrapi.web;
17
18 public class Actions
19 {
20     int sum = 0;
21     int columnCount = 0;
22     String conURL = "jdbc:sqlserver://192.168.1.99:1433;DatabaseName=JingPai110_test_Data";
23     String user = "jingpai2014_99";
24     String password = "jingpai2014_99";
25     Statement stat;
26     ResultSet result;
27     Connection conn;
28
29     public int init() throws Throwable {
30         lr.think_time(5);
31         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
32         System.out.println("???????????...");
33
34         // ?????????
35         lr.think_time(5);
36         conn = DriverManager.getConnection(conURL?? user?? password);
37         lr.think_time(5);
38         stat = conn.createStatement();
39         System.out.println(stat);
40         return 0;
41     }//end of init