comparison src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java @ 883:333bbac1e3e8

Optimise getParameterMetaData(). We can compute the number of parameters now, so avoid to go through all entries in column[] to test if it is a parameter.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Wed, 03 Apr 2024 14:10:15 +0200 (13 months ago)
parents 90e9d216b232
children 1956d8ba5ad3
comparison
equal deleted inserted replaced
882:cd6e5449fb1a 883:333bbac1e3e8
462 // create arrays for storing only the parameters meta data 462 // create arrays for storing only the parameters meta data
463 final String[] types = new String[array_size]; 463 final String[] types = new String[array_size];
464 final int[] jdbcTypes = new int[array_size]; 464 final int[] jdbcTypes = new int[array_size];
465 final int[] precisions = new int[array_size]; 465 final int[] precisions = new int[array_size];
466 final int[] scales = new int[array_size]; 466 final int[] scales = new int[array_size];
467 int param = 1; // parameters in JDBC start from 1 467 if (paramCount > 0) {
468 // now fill the arrays with only the parameters metadata 468 // fill the arrays with the parameters metadata
469 for (int i = 0; i < size; i++) { 469 int param = 1; // parameters in JDBC start from 1
470 /* when column[i] == null it is a parameter, 470 for (int i = paramStartIndex; i < size && param <= paramCount; i++) {
471 when column[i] != null it is a result column of the prepared query */ 471 types[param] = monetdbType[i];
472 if (column[i] != null) 472 jdbcTypes[param] = javaType[i];
473 continue; 473 precisions[param] = digits[i];
474 types[param] = monetdbType[i]; 474 scales[param] = scale[i];
475 jdbcTypes[param] = javaType[i]; 475 param++;
476 precisions[param] = digits[i]; 476 }
477 scales[param] = scale[i];
478 param++;
479 } 477 }
480 478
481 pmd = new MonetParameterMetaData((MonetConnection) getConnection(), 479 pmd = new MonetParameterMetaData((MonetConnection) getConnection(),
482 paramCount, types, jdbcTypes, precisions, scales); 480 paramCount, types, jdbcTypes, precisions, scales);
483 } 481 }