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 ecb01a806f80ea020e99d3eb32e881ea3547ebb0..943c9c71b4cb52906e1ce666714c8c5ea169b27a 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 492bd6d741010ecf683b96d0b2eaf51ad0be7f87..939fae5214a392691785b93ead5a6fc014ed8829 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;