[prev in list] [next in list] [prev in thread] [next in thread] 

List:       slide-dev
Subject:    DO NOT REPLY [Bug 50173] New: JDBCSampler discards ResultSet from a
From:       bugzilla () apache ! org
Date:       2010-10-28 14:14:41
Message-ID: bug-50173-55412 () https ! issues ! apache ! org/bugzilla/
[Download RAW message or body]

https://issues.apache.org/bugzilla/show_bug.cgi?id=50173

           Summary: JDBCSampler discards ResultSet from a
                    PreparedStatement.
           Product: JMeter
           Version: 2.4
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: notifications@jakarta.apache.org
        ReportedBy: whitingjr@hotmail.com


Hi,
 I am using JMeter with a Test Plan that uses a JDBC Request with a
PreparedStatement query type.
 When running this I am getting the following error in the jmeter.log file

2010/10/28 11:30:31 INFO  - jmeter.threads.JMeterThread: Thread started: JDBC
Users 1-1 
2010/10/28 12:13:38 ERROR - jmeter.threads.JMeterThread: Error while processing
sampler 'PREPARED SELECT Customer JDBC Request' :
java.lang.NullPointerException
    at
org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.getStringFromResultSet(JDBCSampler.java:415)
    at
org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.resultSetsToString(JDBCSampler.java:268)
    at
org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.sample(JDBCSampler.java:208)
    at
org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:348)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:243)
    at java.lang.Thread.run(Thread.java:619)

 The query (below) can be expected to return a number of records 
SELECT * FROM Customer WHERE ID=?;
the param is set to 1

 If I use instead a SelectStatement results are returned so the query itself is
not at fault.

 I have retrieved the code for the v2_4 tag to identify the root cause for the
NPE and create a patch. This bug report includes a patch against trunk as the
issue is also in trunk. 
 The root cause is due to:
org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler.sample(Entry e)

 The code path for PreparedStatements types starting on line 204 has in it a
call to
org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate() 
which returns a ResultSet. The side effect of the call is to set the
JDBCPreparedStatement.currentResultSet field member to null.
 JDBCSampler does not keep the ResultSet reference. Instead it is discarded.

 The call on the next line (208)
String sb = resultSetsToString(pstmt,true,null)
 again tries to get the ResultSet on line 267. This causes a
NullPointerException because the JDBCPreparedStatement.currentResultSet field
was set to null earlier.

 Looking at the code path for a CALLABLE statement type (line 190) shows better
handling for queries that return ResultSet.

 The two lines 
207,208

 replaced with
                boolean hasResultSet = pstmt.execute();
                String sb = resultSetsToString(pstmt,hasResultSet,null);

 fixes the defect.

Regards,
Jeremy Whiting
Red Hat

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@jakarta.apache.org
For additional commands, e-mail: notifications-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic