Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/base/query/DefaultQueryExceutor.java @ 1120:d387a97807a3
Added an INFO log statement displaying the execution time of a database query.
geo-backend/trunk@1137 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 31 May 2010 07:23:21 +0000 |
parents | b757def3ff55 |
children | f76541120bcb |
comparison
equal
deleted
inserted
replaced
898:1e003d3b06e8 | 1120:d387a97807a3 |
---|---|
17 import java.sql.ResultSet; | 17 import java.sql.ResultSet; |
18 import java.sql.SQLException; | 18 import java.sql.SQLException; |
19 import java.sql.Statement; | 19 import java.sql.Statement; |
20 | 20 |
21 import java.util.Collection; | 21 import java.util.Collection; |
22 import java.util.Date; | |
22 | 23 |
23 import org.apache.log4j.Logger; | 24 import org.apache.log4j.Logger; |
24 | 25 |
25 /** | 26 /** |
26 * This is an Standard Implementation of the Interface QueryExecutor. | 27 * This is an Standard Implementation of the Interface QueryExecutor. |
78 try { | 79 try { |
79 // Submit the Query | 80 // Submit the Query |
80 connection = connectionPool.getConnection(this.connectionID); | 81 connection = connectionPool.getConnection(this.connectionID); |
81 if (connection != null){ | 82 if (connection != null){ |
82 Statement stmt = connection.createStatement(); | 83 Statement stmt = connection.createStatement(); |
84 Date start = new Date(); | |
83 ResultSet rs = stmt.executeQuery(queryString); | 85 ResultSet rs = stmt.executeQuery(queryString); |
86 Date end = new Date(); | |
87 log.info("-> Database query took " + | |
88 (end.getTime() - start.getTime()) + " ms."); | |
84 returnValue = super.createResultCollection(rs); | 89 returnValue = super.createResultCollection(rs); |
85 | |
86 }else{ | 90 }else{ |
87 log.error("Could not establish Databaseconnection."); | 91 log.error("Could not establish Databaseconnection."); |
88 throw new QueryException("Could not establish Databaseconnection."); | 92 throw new QueryException("Could not establish Databaseconnection."); |
89 } | 93 } |
90 | 94 |