需要配置好java环境变量 在运行它之前需要把JDBC加载到VM中去。 /* * LoadRunner Java script. (Build: 3020) * * Script Description: * */ import lrapi.lr; import java.sql.*; public class Actions { public int init() throws Throwable { return 0; }//end of init public int action() throws Throwable { Connection conn; Statement stm; ResultSet rs; try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:orcl", "nancy", "oracle"); stm = conn.createStatement(); rs = stm.executeQuery("select * from pm_number"); while (rs.next()) { String str = rs.getString("NAME"); System.out.println(str); } rs.close(); conn.close(); } catch (Exception ex) { System.out.println("Error:"+ex.toString()); } return 0; }//end of action public int end() throws Throwable { return 0; }//end of end } 复制代码