jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prasanna bhat <prasannabha...@gmail.com>
Subject Help Required With Bean Shell Sampler
Date Thu, 06 May 2010 13:44:38 GMT
Hi,

1) I have a use case where in i have to read documents (stored as blob in
sql server) from database and from file system. Though the first part ( i.e
reading from database) can be done using JDBC Sampler, which i have tested
successfully, i want to do the same using a Java Program. So i thought of
using a BeanShell sampler to execute a java code.

I have included the following piece of code  in the BeanShell Sampler to
read from a database.

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class GetDocContentFromDB {
    public Connection con;
    public PreparedStatement pstmt;
    public ResultSet rs;

    public final String dbURL="jdbc:sqlserver://dbqahyd2.hyd.deshaw.com:1433
;DatabaseName=PAS_4_0_Build5_PERF;";
    public final String selectQuery="SELECT doc_content FROM
prasanna_sample_table_2 WHERE doc_id=?";

    public void readDocument() throws ClassNotFoundException, SQLException,
IOException {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        con=DriverManager.getConnection(dbURL, "qateam", "qa");

        pstmt=con.prepareStatement(selectQuery);
        pstmt.setInt(1, 5);

        rs=pstmt.executeQuery();

        rs.next();

        InputStream is=rs.getBinaryStream(1);

        int c;
        StringBuffer strBuff=new StringBuffer();

        while((c=is.read())!=-1){
            strBuff.append((char)c);
        }

        System.out.println(strBuff.toString());
    }
}

To test this, i'm just running it with Thread and 1 loop.

When i executed the test plan, i didn't get executed (because no output was
thrown to the console) and also i didn't notice any errors in the logs.

2)  Since i'm using the Bean Shell Sampler for the first time, i tried
running  a sample piece of java code from Bean Shell sampler

    public void fun1(){
        System.out.println("Inside Fun1");
    }

    public void fun2(){
        System.out.println("Inside Fun2");
    }

even this didn't get executed and again no errors in the logs.

I'm using jmeter 2.3.1 version and bsh-2.0b4.jar and bshclient.jar is
present in the lib directory

Can someone help me with this??

Thanks,
Prasanna

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message