Dear reader, I could run a simple beanshell script in JMeter but about jdbc connection, do i need to add special lib into JMeter? except ojdbc that i added it . how can i trace and debug beanshell code..? thnx
On Sat, Feb 26, 2011 at 3:49 PM, Ali Navab <[email protected]> wrote: > Hi All, > > I need some help using JMeter as Functional testing and compare JMeter > results with DB results. > I think one of the solutions is using BeanShell Assertion to acquiring the > DB result into Jmeter variable or csv and then compare it with result from > webservice (for example ). > but i have problem with it .. nothing doing .. > i test the beanshell script with "bsh-2.0b4.jar" but with no error doing > nothing .. > the simple script is: > -------------------------------------------------------- > import java.io.File; > import java.sql.DriverManager; > import java.sql.SQLException; > import java.sql.*; > //import org.hsqldb.jdbcDriver; > import oracle.jdbc.driver.OracleConnection; > import oracle.jdbc.pool.OracleDataSource; > > out_file = "C:/Program Files/Java/jre6/data/table.csv"; > db_url = "jdbc:oracle:thin:@ > (description=(address=(host=~~)(protocol=~~)(port=~~))(connect_data=(SERVER=DEDICATED)(sid=ORA8)))"; > driver = "oracle.jdbc.driver.OracleDriver"; > user = "~~"; > password = "~~"; > > sql_statement = "select * from AA;"; > //sql_statement = "select TABLE_NAME from SYSTEM_TABLES ;"; > > try { > > Class.forName(driver); > Connection con = DriverManager.getConnection(db_url,user,password); > Statement stmt = con.createStatement(); > ResultSet rs = stmt.executeQuery(sql_statement); > > > File out = new File(out_file); > FileWriter o = new FileWriter(out); > > meta = rs.getMetaData(); > cols = meta.getColumnCount(); > > i = 1; > buf = ""; > > while (i <= cols){ > if ( i > 1 ) { > buf = buf + ","; > } > buf = buf + meta.getColumnLabel(i); > i = i + 1; > } > o.write(buf+ "\n"); > buf = "----------"; > o.write(buf+ "\n"); > > > > while (rs.next()) { > ii = 1; > buf = ""; > while (ii <= cols){ > if ( ii > 1 ) { > buf = buf + ","; > } > col_name_get = meta.getColumnLabel(ii); > buf = buf + rs.getString(col_name_get); > ii = ii + 1; > } > o.write(buf + "\n"); > } > stmt.close(); > con.close(); > o.close(); > > } catch ( e ) { > e.printStackTrace(); > } > --------------------------------------------- > > What should i do ?? > And how can i store the returned values in an array to compare it easily ? > one another question is about "Compare Assertion" element and "Comparison > Assertion Visualizer" in Jmeter.. what is it for? and how can i use it? any > manual or help ? > > Thanks for reading:) > > Regards, > Ali Navab > >>

