Lines 19-147
Link Here
|
19 |
package org.apache.jmeter.protocol.jdbc.sampler; |
19 |
package org.apache.jmeter.protocol.jdbc.sampler; |
20 |
|
20 |
|
21 |
import java.io.IOException; |
21 |
import java.io.IOException; |
22 |
import java.io.UnsupportedEncodingException; |
|
|
23 |
import java.lang.reflect.Field; |
24 |
import java.sql.CallableStatement; |
25 |
import java.sql.Connection; |
22 |
import java.sql.Connection; |
26 |
import java.sql.PreparedStatement; |
|
|
27 |
import java.sql.ResultSet; |
28 |
import java.sql.ResultSetMetaData; |
29 |
import java.sql.SQLException; |
23 |
import java.sql.SQLException; |
30 |
import java.sql.Statement; |
|
|
31 |
import java.util.ArrayList; |
32 |
import java.util.Collection; |
33 |
import java.util.HashMap; |
34 |
import java.util.LinkedHashMap; |
35 |
import java.util.List; |
36 |
import java.util.Map; |
37 |
|
24 |
|
38 |
import org.apache.commons.lang.text.StrBuilder; |
25 |
import org.apache.jmeter.protocol.jdbc.AbstractJdbcTestElement; |
39 |
import org.apache.jmeter.protocol.jdbc.config.DataSourceElement; |
26 |
import org.apache.jmeter.protocol.jdbc.config.DataSourceElement; |
40 |
import org.apache.jmeter.samplers.AbstractSampler; |
|
|
41 |
import org.apache.jmeter.samplers.Entry; |
27 |
import org.apache.jmeter.samplers.Entry; |
42 |
import org.apache.jmeter.samplers.SampleResult; |
28 |
import org.apache.jmeter.samplers.SampleResult; |
43 |
import org.apache.jmeter.save.CSVSaveService; |
29 |
import org.apache.jmeter.samplers.Sampler; |
44 |
import org.apache.jmeter.testbeans.TestBean; |
30 |
import org.apache.jmeter.testbeans.TestBean; |
45 |
import org.apache.jmeter.threads.JMeterVariables; |
|
|
46 |
import org.apache.jmeter.util.JMeterUtils; |
47 |
import org.apache.jorphan.logging.LoggingManager; |
31 |
import org.apache.jorphan.logging.LoggingManager; |
48 |
import org.apache.log.Logger; |
32 |
import org.apache.log.Logger; |
49 |
|
33 |
|
|
|
34 |
import ch.infonic.jmeter.jdbc.JDBCSamplerDiagnosticListener; |
35 |
|
50 |
/** |
36 |
/** |
51 |
* A sampler which understands JDBC database requests. |
37 |
* A sampler which understands JDBC database requests. |
52 |
* |
38 |
* |
53 |
*/ |
39 |
*/ |
54 |
public class JDBCSampler extends AbstractSampler implements TestBean { |
40 |
public class JDBCSampler extends AbstractJdbcTestElement implements Sampler, TestBean { |
55 |
private static final long serialVersionUID = 233L; |
41 |
|
56 |
|
|
|
57 |
private static final Logger log = LoggingManager.getLoggerForClass(); |
42 |
private static final Logger log = LoggingManager.getLoggerForClass(); |
58 |
|
43 |
|
59 |
private static final String COMMA = ","; // $NON-NLS-1$ |
|
|
60 |
private static final char COMMA_CHAR = ','; |
61 |
|
62 |
private static final String UNDERSCORE = "_"; // $NON-NLS-1$ |
63 |
|
64 |
// This value is used for both the connection (perConnCache) and statement (preparedStatementMap) caches. |
65 |
// TODO - do they have to be the same size? |
66 |
private static final int MAX_ENTRIES = |
67 |
JMeterUtils.getPropDefault("jdbcsampler.cachesize",200); // $NON-NLS-1$ |
68 |
|
69 |
// String used to indicate a null value |
70 |
private static final String NULL_MARKER = |
71 |
JMeterUtils.getPropDefault("jdbcsampler.nullmarker","]NULL["); // $NON-NLS-1$ |
72 |
|
73 |
private static final String INOUT = "INOUT"; // $NON-NLS-1$ |
74 |
|
75 |
private static final String OUT = "OUT"; // $NON-NLS-1$ |
76 |
|
77 |
// TODO - should the encoding be configurable? |
78 |
private static final String ENCODING = "UTF-8"; // $NON-NLS-1$ |
79 |
|
80 |
// key: name (lowercase) from java.sql.Types; entry: corresponding int value |
81 |
private static final Map<String, Integer> mapJdbcNameToInt; |
82 |
// read-only after class init |
83 |
|
84 |
static { |
85 |
// based on e291. Getting the Name of a JDBC Type from javaalmanac.com |
86 |
// http://javaalmanac.com/egs/java.sql/JdbcInt2Str.html |
87 |
mapJdbcNameToInt = new HashMap<String, Integer>(); |
88 |
|
89 |
//Get all fields in java.sql.Types and store the corresponding int values |
90 |
Field[] fields = java.sql.Types.class.getFields(); |
91 |
for (int i=0; i<fields.length; i++) { |
92 |
try { |
93 |
String name = fields[i].getName(); |
94 |
Integer value = (Integer)fields[i].get(null); |
95 |
mapJdbcNameToInt.put(name.toLowerCase(java.util.Locale.ENGLISH),value); |
96 |
} catch (IllegalAccessException e) { |
97 |
throw new RuntimeException(e); // should not happen |
98 |
} |
99 |
} |
100 |
} |
101 |
|
102 |
// Query types (used to communicate with GUI) |
103 |
// N.B. These must not be changed, as they are used in the JMX files |
104 |
static final String SELECT = "Select Statement"; // $NON-NLS-1$ |
105 |
static final String UPDATE = "Update Statement"; // $NON-NLS-1$ |
106 |
static final String CALLABLE = "Callable Statement"; // $NON-NLS-1$ |
107 |
static final String PREPARED_SELECT = "Prepared Select Statement"; // $NON-NLS-1$ |
108 |
static final String PREPARED_UPDATE = "Prepared Update Statement"; // $NON-NLS-1$ |
109 |
static final String COMMIT = "Commit"; // $NON-NLS-1$ |
110 |
static final String ROLLBACK = "Rollback"; // $NON-NLS-1$ |
111 |
static final String AUTOCOMMIT_FALSE = "AutoCommit(false)"; // $NON-NLS-1$ |
112 |
static final String AUTOCOMMIT_TRUE = "AutoCommit(true)"; // $NON-NLS-1$ |
113 |
|
114 |
private String query = ""; // $NON-NLS-1$ |
115 |
|
116 |
private String dataSource = ""; // $NON-NLS-1$ |
117 |
|
118 |
private String queryType = SELECT; |
119 |
private String queryArguments = ""; // $NON-NLS-1$ |
120 |
private String queryArgumentsTypes = ""; // $NON-NLS-1$ |
121 |
private String variableNames = ""; // $NON-NLS-1$ |
122 |
private String resultVariable = ""; |
123 |
|
124 |
/** |
44 |
/** |
125 |
* Cache of PreparedStatements stored in a per-connection basis. Each entry of this |
|
|
126 |
* cache is another Map mapping the statement string to the actual PreparedStatement. |
127 |
* The cache has a fixed size of MAX_ENTRIES and it will throw away all PreparedStatements |
128 |
* from the least recently used connections. |
129 |
*/ |
130 |
private static final Map<Connection, Map<String, PreparedStatement>> perConnCache = |
131 |
new LinkedHashMap<Connection, Map<String, PreparedStatement>>(MAX_ENTRIES){ |
132 |
private static final long serialVersionUID = 1L; |
133 |
@Override |
134 |
protected boolean removeEldestEntry(Map.Entry<Connection, Map<String, PreparedStatement>> arg0) { |
135 |
if (size() > MAX_ENTRIES) { |
136 |
final Map<String, PreparedStatement> value = arg0.getValue(); |
137 |
closeAllStatements(value.values()); |
138 |
return true; |
139 |
} |
140 |
return false; |
141 |
} |
142 |
}; |
143 |
|
144 |
/** |
145 |
* Creates a JDBCSampler. |
45 |
* Creates a JDBCSampler. |
146 |
*/ |
46 |
*/ |
147 |
public JDBCSampler() { |
47 |
public JDBCSampler() { |
Lines 165-171
Link Here
|
165 |
|
65 |
|
166 |
res.sampleStart(); |
66 |
res.sampleStart(); |
167 |
Connection conn = null; |
67 |
Connection conn = null; |
168 |
Statement stmt = null; |
68 |
JDBCSamplerDiagnosticListener diagnosticListener = getCollectDiagnostics() ? new JDBCSamplerDiagnosticListener() |
|
|
69 |
: null; |
169 |
|
70 |
|
170 |
try { |
71 |
try { |
171 |
|
72 |
|
Lines 175-242
Link Here
|
175 |
res.latencyEnd(); // use latency to measure connection time |
76 |
res.latencyEnd(); // use latency to measure connection time |
176 |
} |
77 |
} |
177 |
res.setResponseHeaders(conn.toString()); |
78 |
res.setResponseHeaders(conn.toString()); |
|
|
79 |
res.setResponseData(execute(conn)); |
178 |
|
80 |
|
179 |
// Based on query return value, get results |
|
|
180 |
String _queryType = getQueryType(); |
181 |
if (SELECT.equals(_queryType)) { |
182 |
stmt = conn.createStatement(); |
183 |
ResultSet rs = null; |
184 |
try { |
185 |
rs = stmt.executeQuery(getQuery()); |
186 |
res.setResponseData(getStringFromResultSet(rs).getBytes(ENCODING)); |
187 |
} finally { |
188 |
close(rs); |
189 |
} |
190 |
} else if (CALLABLE.equals(_queryType)) { |
191 |
CallableStatement cstmt = getCallableStatement(conn); |
192 |
int out[]=setArguments(cstmt); |
193 |
// A CallableStatement can return more than 1 ResultSets |
194 |
// plus a number of update counts. |
195 |
boolean hasResultSet = cstmt.execute(); |
196 |
String sb = resultSetsToString(cstmt,hasResultSet, out); |
197 |
res.setResponseData(sb.getBytes(ENCODING)); |
198 |
} else if (UPDATE.equals(_queryType)) { |
199 |
stmt = conn.createStatement(); |
200 |
stmt.executeUpdate(getQuery()); |
201 |
int updateCount = stmt.getUpdateCount(); |
202 |
String results = updateCount + " updates"; |
203 |
res.setResponseData(results.getBytes(ENCODING)); |
204 |
} else if (PREPARED_SELECT.equals(_queryType)) { |
205 |
PreparedStatement pstmt = getPreparedStatement(conn); |
206 |
setArguments(pstmt); |
207 |
boolean hasResultSet = pstmt.execute(); |
208 |
String sb = resultSetsToString(pstmt,hasResultSet,null); |
209 |
res.setResponseData(sb.getBytes(ENCODING)); |
210 |
} else if (PREPARED_UPDATE.equals(_queryType)) { |
211 |
PreparedStatement pstmt = getPreparedStatement(conn); |
212 |
setArguments(pstmt); |
213 |
pstmt.executeUpdate(); |
214 |
String sb = resultSetsToString(pstmt,false,null); |
215 |
res.setResponseData(sb.getBytes(ENCODING)); |
216 |
} else if (ROLLBACK.equals(_queryType)){ |
217 |
conn.rollback(); |
218 |
res.setResponseData(ROLLBACK.getBytes(ENCODING)); |
219 |
} else if (COMMIT.equals(_queryType)){ |
220 |
conn.commit(); |
221 |
res.setResponseData(COMMIT.getBytes(ENCODING)); |
222 |
} else if (AUTOCOMMIT_FALSE.equals(_queryType)){ |
223 |
conn.setAutoCommit(false); |
224 |
res.setResponseData(AUTOCOMMIT_FALSE.getBytes(ENCODING)); |
225 |
} else if (AUTOCOMMIT_TRUE.equals(_queryType)){ |
226 |
conn.setAutoCommit(true); |
227 |
res.setResponseData(AUTOCOMMIT_TRUE.getBytes(ENCODING)); |
228 |
} else { // User provided incorrect query type |
229 |
String results="Unexpected query type: "+_queryType; |
230 |
res.setResponseMessage(results); |
231 |
res.setSuccessful(false); |
232 |
} |
233 |
|
234 |
} catch (SQLException ex) { |
81 |
} catch (SQLException ex) { |
235 |
final String errCode = Integer.toString(ex.getErrorCode()); |
82 |
final String errCode = Integer.toString(ex.getErrorCode()); |
236 |
res.setResponseMessage(ex.toString()); |
83 |
res.setResponseMessage(ex.toString()); |
237 |
res.setResponseCode(ex.getSQLState()+ " " +errCode); |
84 |
res.setResponseCode(ex.getSQLState()+ " " +errCode); |
238 |
res.setSuccessful(false); |
85 |
res.setSuccessful(false); |
239 |
} catch (UnsupportedEncodingException ex) { |
86 |
if (diagnosticListener != null) { |
|
|
87 |
res.setResponseData(diagnosticListener.getDiagnosticMessages(), ENCODING); |
88 |
} |
89 |
} catch (UnsupportedOperationException ex) { |
240 |
res.setResponseMessage(ex.toString()); |
90 |
res.setResponseMessage(ex.toString()); |
241 |
res.setResponseCode("000"); // TODO - is this correct? |
91 |
res.setResponseCode("000"); // TODO - is this correct? |
242 |
res.setSuccessful(false); |
92 |
res.setSuccessful(false); |
Lines 245-251
Link Here
|
245 |
res.setResponseCode("000"); // TODO - is this correct? |
95 |
res.setResponseCode("000"); // TODO - is this correct? |
246 |
res.setSuccessful(false); |
96 |
res.setSuccessful(false); |
247 |
} finally { |
97 |
} finally { |
248 |
close(stmt); |
98 |
if (diagnosticListener != null) { |
|
|
99 |
diagnosticListener.detach(); |
100 |
} |
249 |
close(conn); |
101 |
close(conn); |
250 |
} |
102 |
} |
251 |
|
103 |
|
Lines 253-615
Link Here
|
253 |
res.sampleEnd(); |
105 |
res.sampleEnd(); |
254 |
return res; |
106 |
return res; |
255 |
} |
107 |
} |
256 |
|
|
|
257 |
private String resultSetsToString(PreparedStatement pstmt, boolean result, int[] out) throws SQLException, UnsupportedEncodingException { |
258 |
StrBuilder sb = new StrBuilder(); |
259 |
int updateCount = 0; |
260 |
if (!result) { |
261 |
updateCount = pstmt.getUpdateCount(); |
262 |
} |
263 |
do { |
264 |
if (result) { |
265 |
ResultSet rs = null; |
266 |
try { |
267 |
rs = pstmt.getResultSet(); |
268 |
sb.append(getStringFromResultSet(rs)).append("\n"); // $NON-NLS-1$ |
269 |
} finally { |
270 |
close(rs); |
271 |
} |
272 |
} else { |
273 |
sb.append(updateCount).append(" updates.\n"); |
274 |
} |
275 |
result = pstmt.getMoreResults(); |
276 |
if (!result) { |
277 |
updateCount = pstmt.getUpdateCount(); |
278 |
} |
279 |
} while (result || (updateCount != -1)); |
280 |
if (out!=null && pstmt instanceof CallableStatement){ |
281 |
CallableStatement cs = (CallableStatement) pstmt; |
282 |
sb.append("Output variables by position:\n"); |
283 |
for(int i=0; i < out.length; i++){ |
284 |
if (out[i]!=java.sql.Types.NULL){ |
285 |
sb.append("["); |
286 |
sb.append(i+1); |
287 |
sb.append("] "); |
288 |
sb.append(cs.getObject(i+1)); |
289 |
sb.append("\n"); |
290 |
} |
291 |
} |
292 |
} |
293 |
return sb.toString(); |
294 |
} |
295 |
|
296 |
|
297 |
private int[] setArguments(PreparedStatement pstmt) throws SQLException, IOException { |
298 |
if (getQueryArguments().trim().length()==0) { |
299 |
return new int[]{}; |
300 |
} |
301 |
String[] arguments = CSVSaveService.csvSplitString(getQueryArguments(), COMMA_CHAR); |
302 |
String[] argumentsTypes = getQueryArgumentsTypes().split(COMMA); |
303 |
if (arguments.length != argumentsTypes.length) { |
304 |
throw new SQLException("number of arguments ("+arguments.length+") and number of types ("+argumentsTypes.length+") are not equal"); |
305 |
} |
306 |
int[] outputs= new int[arguments.length]; |
307 |
for (int i = 0; i < arguments.length; i++) { |
308 |
String argument = arguments[i]; |
309 |
String argumentType = argumentsTypes[i]; |
310 |
String[] arg = argumentType.split(" "); |
311 |
String inputOutput=""; |
312 |
if (arg.length > 1) { |
313 |
argumentType = arg[1]; |
314 |
inputOutput=arg[0]; |
315 |
} |
316 |
int targetSqlType = getJdbcType(argumentType); |
317 |
try { |
318 |
if (!OUT.equalsIgnoreCase(inputOutput)){ |
319 |
if (argument.equals(NULL_MARKER)){ |
320 |
pstmt.setNull(i+1, targetSqlType); |
321 |
} else { |
322 |
pstmt.setObject(i+1, argument, targetSqlType); |
323 |
} |
324 |
} |
325 |
if (OUT.equalsIgnoreCase(inputOutput)||INOUT.equalsIgnoreCase(inputOutput)) { |
326 |
CallableStatement cs = (CallableStatement) pstmt; |
327 |
cs.registerOutParameter(i+1, targetSqlType); |
328 |
outputs[i]=targetSqlType; |
329 |
} else { |
330 |
outputs[i]=java.sql.Types.NULL; // can't have an output parameter type null |
331 |
} |
332 |
} catch (NullPointerException e) { // thrown by Derby JDBC (at least) if there are no "?" markers in statement |
333 |
throw new SQLException("Could not set argument no: "+(i+1)+" - missing parameter marker?"); |
334 |
} |
335 |
} |
336 |
return outputs; |
337 |
} |
338 |
|
339 |
|
340 |
private static int getJdbcType(String jdbcType) throws SQLException { |
341 |
Integer entry = mapJdbcNameToInt.get(jdbcType.toLowerCase(java.util.Locale.ENGLISH)); |
342 |
if (entry == null) { |
343 |
try { |
344 |
entry = Integer.decode(jdbcType); |
345 |
} catch (NumberFormatException e) { |
346 |
throw new SQLException("Invalid data type: "+jdbcType); |
347 |
} |
348 |
} |
349 |
return (entry).intValue(); |
350 |
} |
351 |
|
352 |
|
353 |
private CallableStatement getCallableStatement(Connection conn) throws SQLException { |
354 |
return (CallableStatement) getPreparedStatement(conn,true); |
355 |
|
356 |
} |
357 |
private PreparedStatement getPreparedStatement(Connection conn) throws SQLException { |
358 |
return getPreparedStatement(conn,false); |
359 |
} |
360 |
|
361 |
private PreparedStatement getPreparedStatement(Connection conn, boolean callable) throws SQLException { |
362 |
Map<String, PreparedStatement> preparedStatementMap = perConnCache.get(conn); |
363 |
if (null == preparedStatementMap ) { |
364 |
// MRU PreparedStatements cache. |
365 |
preparedStatementMap = new LinkedHashMap<String, PreparedStatement>(MAX_ENTRIES) { |
366 |
private static final long serialVersionUID = 240L; |
367 |
|
368 |
@Override |
369 |
protected boolean removeEldestEntry(Map.Entry<String, PreparedStatement> arg0) { |
370 |
final int theSize = size(); |
371 |
if (theSize > MAX_ENTRIES) { |
372 |
Object value = arg0.getValue(); |
373 |
if (value instanceof PreparedStatement) { |
374 |
PreparedStatement pstmt = (PreparedStatement) value; |
375 |
close(pstmt); |
376 |
} |
377 |
return true; |
378 |
} |
379 |
return false; |
380 |
} |
381 |
}; |
382 |
perConnCache.put(conn, preparedStatementMap); |
383 |
} |
384 |
PreparedStatement pstmt = preparedStatementMap.get(getQuery()); |
385 |
if (null == pstmt) { |
386 |
if (callable) { |
387 |
pstmt = conn.prepareCall(getQuery()); |
388 |
} else { |
389 |
pstmt = conn.prepareStatement(getQuery()); |
390 |
} |
391 |
preparedStatementMap.put(getQuery(), pstmt); |
392 |
} |
393 |
pstmt.clearParameters(); |
394 |
return pstmt; |
395 |
} |
396 |
|
397 |
private static void closeAllStatements(Collection<PreparedStatement> collection) { |
398 |
for (PreparedStatement pstmt : collection) { |
399 |
close(pstmt); |
400 |
} |
401 |
} |
402 |
|
403 |
/** |
404 |
* Gets a Data object from a ResultSet. |
405 |
* |
406 |
* @param rs |
407 |
* ResultSet passed in from a database query |
408 |
* @return a Data object |
409 |
* @throws java.sql.SQLException |
410 |
* @throws UnsupportedEncodingException |
411 |
*/ |
412 |
private String getStringFromResultSet(ResultSet rs) throws SQLException, UnsupportedEncodingException { |
413 |
ResultSetMetaData meta = rs.getMetaData(); |
414 |
|
415 |
StrBuilder sb = new StrBuilder(); |
416 |
|
417 |
int numColumns = meta.getColumnCount(); |
418 |
for (int i = 1; i <= numColumns; i++) { |
419 |
sb.append(meta.getColumnName(i)); |
420 |
if (i==numColumns){ |
421 |
sb.append('\n'); |
422 |
} else { |
423 |
sb.append('\t'); |
424 |
} |
425 |
} |
426 |
|
427 |
|
428 |
JMeterVariables jmvars = getThreadContext().getVariables(); |
429 |
String varnames[] = getVariableNames().split(COMMA); |
430 |
String resultVariable = getResultVariable().trim(); |
431 |
List<Map<String, Object> > results = null; |
432 |
if(resultVariable.length() > 0) { |
433 |
results = new ArrayList<Map<String,Object> >(); |
434 |
jmvars.putObject(resultVariable, results); |
435 |
} |
436 |
int j = 0; |
437 |
while (rs.next()) { |
438 |
Map<String, Object> row = null; |
439 |
j++; |
440 |
for (int i = 1; i <= numColumns; i++) { |
441 |
Object o = rs.getObject(i); |
442 |
if(results != null) { |
443 |
if(row == null) { |
444 |
row = new HashMap<String, Object>(numColumns); |
445 |
results.add(row); |
446 |
} |
447 |
row.put(meta.getColumnName(i), o); |
448 |
} |
449 |
if (o instanceof byte[]) { |
450 |
o = new String((byte[]) o, ENCODING); |
451 |
} |
452 |
sb.append(o); |
453 |
if (i==numColumns){ |
454 |
sb.append('\n'); |
455 |
} else { |
456 |
sb.append('\t'); |
457 |
} |
458 |
if (i <= varnames.length) { // i starts at 1 |
459 |
String name = varnames[i - 1].trim(); |
460 |
if (name.length()>0){ // Save the value in the variable if present |
461 |
jmvars.put(name+UNDERSCORE+j, o == null ? null : o.toString()); |
462 |
} |
463 |
} |
464 |
} |
465 |
} |
466 |
// Remove any additional values from previous sample |
467 |
for(int i=0; i < varnames.length; i++){ |
468 |
String name = varnames[i].trim(); |
469 |
if (name.length()>0 && jmvars != null){ |
470 |
final String varCount = name+"_#"; // $NON-NLS-1$ |
471 |
// Get the previous count |
472 |
String prevCount = jmvars.get(varCount); |
473 |
if (prevCount != null){ |
474 |
int prev = Integer.parseInt(prevCount); |
475 |
for (int n=j+1; n <= prev; n++ ){ |
476 |
jmvars.remove(name+UNDERSCORE+n); |
477 |
} |
478 |
} |
479 |
jmvars.put(varCount, Integer.toString(j)); // save the current count |
480 |
} |
481 |
} |
482 |
|
483 |
return sb.toString(); |
484 |
} |
485 |
|
486 |
public static void close(Connection c) { |
487 |
try { |
488 |
if (c != null) { |
489 |
c.close(); |
490 |
} |
491 |
} catch (SQLException e) { |
492 |
log.warn("Error closing Connection", e); |
493 |
} |
494 |
} |
495 |
|
496 |
public static void close(Statement s) { |
497 |
try { |
498 |
if (s != null) { |
499 |
s.close(); |
500 |
} |
501 |
} catch (SQLException e) { |
502 |
log.warn("Error closing Statement " + s.toString(), e); |
503 |
} |
504 |
} |
505 |
|
506 |
public static void close(ResultSet rs) { |
507 |
try { |
508 |
if (rs != null) { |
509 |
rs.close(); |
510 |
} |
511 |
} catch (SQLException e) { |
512 |
log.warn("Error closing ResultSet", e); |
513 |
} |
514 |
} |
515 |
|
516 |
public String getQuery() { |
517 |
return query; |
518 |
} |
519 |
|
520 |
@Override |
521 |
public String toString() { |
522 |
StrBuilder sb = new StrBuilder(80); |
523 |
sb.append("["); // $NON-NLS-1$ |
524 |
sb.append(getQueryType()); |
525 |
sb.append("] "); // $NON-NLS-1$ |
526 |
sb.append(getQuery()); |
527 |
sb.append("\n"); |
528 |
sb.append(getQueryArguments()); |
529 |
sb.append("\n"); |
530 |
sb.append(getQueryArgumentsTypes()); |
531 |
return sb.toString(); |
532 |
} |
533 |
|
534 |
/** |
535 |
* @param query |
536 |
* The query to set. |
537 |
*/ |
538 |
public void setQuery(String query) { |
539 |
this.query = query; |
540 |
} |
541 |
|
542 |
/** |
543 |
* @return Returns the dataSource. |
544 |
*/ |
545 |
public String getDataSource() { |
546 |
return dataSource; |
547 |
} |
548 |
|
549 |
/** |
550 |
* @param dataSource |
551 |
* The dataSource to set. |
552 |
*/ |
553 |
public void setDataSource(String dataSource) { |
554 |
this.dataSource = dataSource; |
555 |
} |
556 |
|
557 |
/** |
558 |
* @return Returns the queryType. |
559 |
*/ |
560 |
public String getQueryType() { |
561 |
return queryType; |
562 |
} |
563 |
|
564 |
/** |
565 |
* @param queryType The queryType to set. |
566 |
*/ |
567 |
public void setQueryType(String queryType) { |
568 |
this.queryType = queryType; |
569 |
} |
570 |
|
571 |
public String getQueryArguments() { |
572 |
return queryArguments; |
573 |
} |
574 |
|
575 |
public void setQueryArguments(String queryArguments) { |
576 |
this.queryArguments = queryArguments; |
577 |
} |
578 |
|
579 |
public String getQueryArgumentsTypes() { |
580 |
return queryArgumentsTypes; |
581 |
} |
582 |
|
583 |
public void setQueryArgumentsTypes(String queryArgumentsType) { |
584 |
this.queryArgumentsTypes = queryArgumentsType; |
585 |
} |
586 |
|
587 |
/** |
588 |
* @return the variableNames |
589 |
*/ |
590 |
public String getVariableNames() { |
591 |
return variableNames; |
592 |
} |
593 |
|
594 |
/** |
595 |
* @param variableNames the variableNames to set |
596 |
*/ |
597 |
public void setVariableNames(String variableNames) { |
598 |
this.variableNames = variableNames; |
599 |
} |
600 |
|
601 |
/** |
602 |
* @return the resultVariable |
603 |
*/ |
604 |
public String getResultVariable() { |
605 |
return resultVariable ; |
606 |
} |
607 |
|
608 |
/** |
609 |
* @param resultVariable the variable name in which results will be stored |
610 |
*/ |
611 |
public void setResultVariable(String resultVariable) { |
612 |
this.resultVariable = resultVariable; |
613 |
} |
614 |
|
615 |
} |
108 |
} |