From 35f6fc87e0fbfcc944f55a5cd464afb08043b36c Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Thu, 7 Jul 2011 11:47:59 +0000 Subject: [PATCH] [LMS-2301] more verbose error logging when there is a problem with parsing the query SVN: 22041 --- .../api/v1/impl/DataSourceQueryService.java | 16 +++++++++++++++- .../api/internal/v1/IDataSourceQueryService.java | 6 +++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java index ecb01a806f8..943c9c71b4c 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java @@ -21,8 +21,13 @@ import java.util.Map; import javax.sql.DataSource; import net.lemnik.eodsql.DataSet; +import net.lemnik.eodsql.InvalidQueryException; import net.lemnik.eodsql.QueryTool; +import org.apache.log4j.Logger; + +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.openbis.dss.generic.shared.DataSourceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IDataSourceQueryService; @@ -32,6 +37,8 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IDataSourceQu */ public class DataSourceQueryService implements IDataSourceQueryService { + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, + DataSourceQueryService.class); private DataSourceProvider getDataSourceProvider() { @@ -42,7 +49,14 @@ public class DataSourceQueryService implements IDataSourceQueryService Object... parameters) { DataSource dataSource = getDataSourceProvider().getDataSource(dataSourceName); - return QueryTool.select(dataSource, query, parameters); + try + { + return QueryTool.select(dataSource, query, parameters); + } catch (InvalidQueryException ex) + { + operationLog.error(ex.getCause().getMessage()); + throw ex; + } } public DataSet<Map<String, Object>> select(String dataSourceName, String query) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java index 492bd6d7410..939fae5214a 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java @@ -57,6 +57,8 @@ public interface IDataSourceQueryService * @param query The SQL query to execute, possibly including parameters marked by '?'. * @return A List of Maps with the data. Do not forget to close the result when done! * @throw IllegalArgumentException Throws if there is no data source with the given name. + * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match + * the given parameters. */ DataSet<Map<String, Object>> select(String dataSourceName, String query) throws IllegalArgumentException; @@ -69,7 +71,9 @@ public interface IDataSourceQueryService * @param query The SQL query to execute, possibly including parameters marked by '?'. * @param parameters The values for filling in the query parameters. * @return A List of Maps with the data. Do not forget to close the result when done! - * @throw IllegalArgumentException Throws if there is no data source with the given name. + * @throw IllegalArgumentException Thrown if there is no data source with the given name. + * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match + * the given parameters. */ DataSet<Map<String, Object>> select(String dataSourceName, String query, Object... parameters) throws IllegalArgumentException; -- GitLab