160 Connection
conn = null;
161 Statement stmt = null;
163 Long firstExecute = 0l;
165 Long firstIterate = 0l;
167 DescriptiveStatistics statsExecute =
new DescriptiveStatistics();
168 DescriptiveStatistics statsJdbc =
new DescriptiveStatistics();
169 DescriptiveStatistics statsIterate =
new DescriptiveStatistics();
170 DescriptiveStatistics statsTotal =
new DescriptiveStatistics();
176 logger.debug(
"Connecting to database url :" +
url);
179 long startTime = System.currentTimeMillis();
180 for (
int loop = 0; loop < iterations; loop++) {
182 stmt = conn.createStatement();
184 long timer = System.currentTimeMillis();
185 ResultSet rs = stmt.executeQuery(sql);
187 long executeTime = 0;
192 executeTime = ((HeavyAIStatement) stmt).getQueryInternalExecuteTime();
193 jdbcTime = (System.currentTimeMillis() - timer) - executeTime;
195 jdbcTime = (System.currentTimeMillis() - timer);
199 logger.debug(
"Query Timeout/AKA internal Execution Time was "
200 + stmt.getQueryTimeout() +
" ms Elapsed time in JVM space was "
201 + (System.currentTimeMillis() - timer) +
"ms");
203 timer = System.currentTimeMillis();
207 Object obj = rs.getObject(1);
208 if (obj != null && obj.equals(statsExecute)) {
209 logger.info(
"Impossible");
213 long iterateTime = (System.currentTimeMillis() - timer);
215 if (resultCount != expected) {
217 "Expect " + expected +
" actual " + resultCount +
" for query " + sql);
223 firstJdbc = jdbcTime;
224 firstExecute = executeTime;
225 firstIterate = iterateTime;
228 statsJdbc.addValue(jdbcTime);
229 statsExecute.addValue(executeTime);
230 statsIterate.addValue(iterateTime);
231 statsTotal.addValue(jdbcTime + executeTime + iterateTime);
238 totalTime = System.currentTimeMillis() - startTime;
240 }
catch (SQLException se) {
242 se.printStackTrace();
243 }
catch (Exception e) {
252 }
catch (SQLException se2) {
258 }
catch (SQLException se) {
259 se.printStackTrace();
265 statsTotal.getMean(),
268 statsTotal.getPercentile(85),
269 statsExecute.getMean(),
270 statsExecute.getMin(),
271 statsExecute.getMax(),
272 statsExecute.getPercentile(85),
273 statsExecute.getPercentile(25),
274 statsExecute.getStandardDeviation(),
278 statsJdbc.getPercentile(85),
279 statsIterate.getMean(),
280 statsIterate.getMin(),
281 statsIterate.getMax(),
282 statsIterate.getPercentile(85),
288 (long) statsTotal.getSum() + firstExecute + firstJdbc + firstIterate);
static final String JDBC_DRIVER