You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/11/04 13:28:41 UTC
svn commit: r711240 - in /jakarta/jmeter/trunk:
src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
xdocs/changes.xml xdocs/usermanual/component_reference.xml
Author: sebb
Date: Tue Nov 4 04:28:40 2008
New Revision: 711240
URL: http://svn.apache.org/viewvc?rev=711240&view=rev
Log:
JDBC Request now handles quoted strings.
Modified:
jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
jakarta/jmeter/trunk/xdocs/changes.xml
jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Modified: jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java?rev=711240&r1=711239&r2=711240&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java (original)
+++ jakarta/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java Tue Nov 4 04:28:40 2008
@@ -18,6 +18,7 @@
package org.apache.jmeter.protocol.jdbc.sampler;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.sql.CallableStatement;
@@ -38,6 +39,7 @@
import org.apache.jmeter.samplers.AbstractSampler;
import org.apache.jmeter.samplers.Entry;
import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.save.CSVSaveService;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.threads.JMeterVariables;
import org.apache.jmeter.util.JMeterUtils;
@@ -55,6 +57,7 @@
private static final Logger log = LoggingManager.getLoggerForClass();
private static final String COMMA = ","; // $NON-NLS-1$
+ private static final char COMMA_CHAR = ',';
private static final String UNDERSCORE = "_"; // $NON-NLS-1$
@@ -238,6 +241,10 @@
res.setResponseMessage(ex.toString());
res.setResponseCode("000"); // TODO - is this correct?
res.setSuccessful(false);
+ } catch (IOException ex) {
+ res.setResponseMessage(ex.toString());
+ res.setResponseCode("000"); // TODO - is this correct?
+ res.setSuccessful(false);
} finally {
close(stmt);
close(conn);
@@ -250,7 +257,7 @@
return res;
}
- private String resultSetsToString(PreparedStatement pstmt, boolean result, int[] out) throws SQLException {
+ private String resultSetsToString(PreparedStatement pstmt, boolean result, int[] out) throws SQLException, UnsupportedEncodingException {
StrBuilder sb = new StrBuilder();
sb.append("\n"); // $NON-NLS-1$
int updateCount = 0;
@@ -293,11 +300,11 @@
}
- private int[] setArguments(PreparedStatement pstmt) throws SQLException {
+ private int[] setArguments(PreparedStatement pstmt) throws SQLException, IOException {
if (getQueryArguments().trim().length()==0) {
return new int[]{};
}
- String[] arguments = getQueryArguments().split(COMMA);
+ String[] arguments = CSVSaveService.csvSplitString(getQueryArguments(), COMMA_CHAR);
String[] argumentsTypes = getQueryArgumentsTypes().split(COMMA);
if (arguments.length != argumentsTypes.length) {
throw new SQLException("number of arguments ("+arguments.length+") and number of types ("+argumentsTypes.length+") are not equal");
@@ -401,8 +408,9 @@
* ResultSet passed in from a database query
* @return a Data object
* @throws java.sql.SQLException
+ * @throws UnsupportedEncodingException
*/
- private Data getDataFromResultSet(ResultSet rs) throws SQLException {
+ private Data getDataFromResultSet(ResultSet rs) throws SQLException, UnsupportedEncodingException {
ResultSetMetaData meta = rs.getMetaData();
Data data = new Data();
@@ -425,7 +433,7 @@
for (int i = 0; i < numColumns; i++) {
Object o = rs.getObject(i + 1);
if (o instanceof byte[]) {
- o = new String((byte[]) o); // TODO what charset applies here?
+ o = new String((byte[]) o, ENCODING);
}
data.addColumnValue(dbCols[i], o);
if (jmvars != null && i < varnames.length) {
Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=711240&r1=711239&r2=711240&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Nov 4 04:28:40 2008
@@ -142,6 +142,7 @@
<li>Add version attribute to JMeter Cookie class (needed for proper cookie support)</li>
<li>Cookie Manager now saves/restores cookie versions</li>
<li>Bug 41608 - misleading warning log message removed</li>
+<li>CSVSaveService - check for EOF while reading quoted string</li>
</ul>
<h3>Improvements</h3>
@@ -170,6 +171,7 @@
<li>Apache SOAP 2.3.1 does not give access to HTTP response code/message, so WebService sampler now treats an empty response as an error</li>
<li>Use Script to evaluate __jexl() function so can have multiple statements.</li>
<li>JDBC Request can optionally save the results of Select statements to variables.</li>
+<li>JDBC Request now handles quoted strings.</li>
</ul>
<h3>Non-functional changes</h3>
Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=711240&r1=711239&r2=711240&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Tue Nov 4 04:28:40 2008
@@ -378,6 +378,9 @@
Comma-separated list of parameter values. Use ]NULL[ to indicate a NULL parameter.
(If required, the null string can be changed by defining the property "jdbcsampler.nullmarker".)
<br></br>
+ The list must be enclosed in double-quotes if any of the values contain a comma or double-quote,
+ and any embedded double-quotes must be doubled-up, for example:
+ <pre>"Dbl-Quote: "" and Comma: ,"</pre>
There must be as many values as there are placeholders in the statement.
</property>
<property name="Parameter types" required="Yes, if a prepared or callable statement has parameters">
@@ -386,7 +389,7 @@
appropriate parameter types, e.g. instead of "INTEGER", use "INOUT INTEGER".
If not specified, "IN" is assumed, i.e. "DATE" is the same as "IN DATE".
<br></br>
- There must be as many values as there are placeholders in the statement.
+ There must be as many types as there are placeholders in the statement.
</property>
<property name="Variable Names" required="No">Comma-separated list of variable names to hold values returned by Select statements</property>
</properties>
@@ -395,7 +398,7 @@
<link href="build-db-test-plan.html">Building a Database Test Plan</link>
<complink name="JDBC Connection Configuration"/>
</links>
-
+<note>Versions of JMeter after 2.3.2 use UTF-8 as the character encoding. Previously the default was used.</note>
</component>
<component name="Java Request" index="§-num;.1.4" width="406" height="307" screenshot="java_request.png">
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org