Project

General

Profile

« Previous | Next » 

Revision 7309

correct the parameter/value setting in the prepared statements for retrieving log information.

View differences:

src/edu/ucsb/nceas/metacat/EventLog.java
201 201
            clauseAdded = true;
202 202
        }
203 203
        if (principal != null) {
204
        	if (clauseAdded) {
205
                query.append(" and ");
206
            }
204 207
        	query.append("principal in (");
205 208
        	for (int i = 0; i < principal.length; i++) {
206 209
        		if (i > 0) {
......
213 216
            clauseAdded = true;
214 217
        }
215 218
        if (docid != null) {
219
        	if (clauseAdded) {
220
                query.append(" and ");
221
            }
216 222
        	query.append("docid in (");
217 223
        	for (int i = 0; i < docid.length; i++) {
218 224
        		if (i > 0) {
......
225 231
            clauseAdded = true;
226 232
        }
227 233
        if (event != null) {
234
        	if (clauseAdded) {
235
                query.append(" and ");
236
            }
228 237
        	query.append("event in (");
229 238
        	for (int i = 0; i < event.length; i++) {
230 239
        		if (i > 0) {
......
264 273
            //set the param values
265 274
            int parameterIndex = 1;
266 275
            for (String val: paramValues) {
267
            	stmt.setString(parameterIndex, val);
276
            	stmt.setString(parameterIndex++, val);
268 277
            }
269 278
            if (startDate != null) {
270 279
                stmt.setTimestamp(parameterIndex++, startDate); 
......
342 351
        
343 352
        List<String> paramValues = new ArrayList<String>();
344 353
        if (ipAddress != null) {
354
        	if (clauseAdded) {
355
                query.append(" and ");
356
            }
345 357
        	query.append("ip_address in (");
346 358
        	for (int i = 0; i < ipAddress.length; i++) {
347 359
        		if (i > 0) {
......
354 366
            clauseAdded = true;
355 367
        }
356 368
        if (principal != null) {
369
        	if (clauseAdded) {
370
                query.append(" and ");
371
            }
357 372
        	query.append("principal in (");
358 373
        	for (int i = 0; i < principal.length; i++) {
359 374
        		if (i > 0) {
......
366 381
            clauseAdded = true;
367 382
        }
368 383
        if (docid != null) {
384
        	if (clauseAdded) {
385
                query.append(" and ");
386
            }
369 387
        	query.append("al.docid in (");
370 388
        	for (int i = 0; i < docid.length; i++) {
371 389
        		if (i > 0) {
......
378 396
            clauseAdded = true;
379 397
        }
380 398
        if (event != null) {
399
        	if (clauseAdded) {
400
                query.append(" and ");
401
            }
381 402
        	query.append("event in (");
382 403
    		query.append("?");
383 404
    		String eventString = event.xmlValue();
......
416 437
            //set the param values
417 438
            int parameterIndex = 1;
418 439
            for (String val: paramValues) {
419
            	stmt.setString(parameterIndex, val);
440
            	stmt.setString(parameterIndex++, val);
420 441
            }
421 442
            if (startDate != null) {
422 443
                stmt.setTimestamp(parameterIndex++, startDate); 

Also available in: Unified diff