Skip to content
Snippets Groups Projects
Commit 35f6fc87 authored by buczekp's avatar buczekp
Browse files

[LMS-2301] more verbose error logging when there is a problem with parsing the query

SVN: 22041
parent e788babf
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment