diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/DatabaseDefinition.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/DatabaseDefinition.java
new file mode 100644
index 0000000000000000000000000000000000000000..7dbdc0eefff14016f3c9491056e6bc15760556a2
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/DatabaseDefinition.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2010 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.plugin.query.server;
+
+import ch.systemsx.cisd.dbmigration.DatabaseConfigurationContext;
+
+/**
+ * 
+ *
+ * @author Franz-Josef Elmer
+ */
+public class DatabaseDefinition
+{
+    private final String label;
+    private final DatabaseConfigurationContext configurationContext;
+
+    public DatabaseDefinition(String label, DatabaseConfigurationContext configurationContext)
+    {
+        this.label = label;
+        this.configurationContext = configurationContext;
+    }
+
+    public String getLabel()
+    {
+        return label;
+    }
+
+    public DatabaseConfigurationContext getConfigurationContext()
+    {
+        return configurationContext;
+    }
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/QueryServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/QueryServer.java
new file mode 100644
index 0000000000000000000000000000000000000000..dd42c291e70992a7d3ad4787e1418928c55505d5
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/QueryServer.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2010 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.plugin.query.server;
+
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+
+import net.lemnik.eodsql.DataSet;
+import net.lemnik.eodsql.QueryTool;
+
+import org.springframework.stereotype.Component;
+
+import ch.rinn.restrictions.Private;
+import ch.systemsx.cisd.authentication.ISessionManager;
+import ch.systemsx.cisd.common.spring.ExposablePropertyPaceholderConfigurer;
+import ch.systemsx.cisd.common.utilities.BeanUtils;
+import ch.systemsx.cisd.common.utilities.ExtendedProperties;
+import ch.systemsx.cisd.dbmigration.DatabaseConfigurationContext;
+import ch.systemsx.cisd.openbis.generic.server.AbstractServer;
+import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory;
+import ch.systemsx.cisd.openbis.generic.server.plugin.IDataSetTypeSlaveServerPlugin;
+import ch.systemsx.cisd.openbis.generic.server.plugin.ISampleTypeSlaveServerPlugin;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel;
+import ch.systemsx.cisd.openbis.generic.shared.dto.Session;
+import ch.systemsx.cisd.openbis.plugin.query.shared.IQueryServer;
+import ch.systemsx.cisd.openbis.plugin.query.shared.ResourceNames;
+
+/**
+ * 
+ *
+ * @author Franz-Josef Elmer
+ */
+@Component(ResourceNames.QUERY_PLUGIN_SERVER)
+public class QueryServer extends AbstractServer<IQueryServer> implements
+        IQueryServer
+{
+    @Resource(name = "propertyConfigurer")
+    private ExposablePropertyPaceholderConfigurer configurer;
+    
+    private DatabaseDefinition databaseDefinition;
+    
+    public QueryServer()
+    {
+    }
+    
+    @Private
+    QueryServer(final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory,
+            final ISampleTypeSlaveServerPlugin sampleTypeSlaveServerPlugin,
+            final IDataSetTypeSlaveServerPlugin dataSetTypeSlaveServerPlugin)
+    {
+        super(sessionManager, daoFactory, sampleTypeSlaveServerPlugin, dataSetTypeSlaveServerPlugin);
+    }
+
+    public IQueryServer createLogger(boolean invocationSuccessful, long elapsedTime)
+    {
+        return new QueryServerLogger(getSessionManager(), invocationSuccessful, elapsedTime);
+    }
+    
+    public String tryToGetQueryDatabaseLabel()
+    {
+        DatabaseDefinition definition = tryToGetDatabaseDefinition();
+        return definition == null ? null : definition.getLabel();
+    }
+
+    public TableModel queryDatabase(String sessionToken, String sqlQuery)
+    {
+        checkSession(sessionToken);
+        DatabaseDefinition definition = tryToGetDatabaseDefinition();
+        if (definition == null)
+        {
+            throw new UnsupportedOperationException("Undefined query database");
+        }
+        DataSource dataSource = definition.getConfigurationContext().getDataSource();
+        DataSet<Map<String, Object>> result = QueryTool.select(dataSource, sqlQuery);
+        for (Map<String, Object> row : result)
+        {
+            System.out.println(row);
+        }
+        result.close();
+        return null;
+    }
+    
+    private DatabaseDefinition tryToGetDatabaseDefinition()
+    {
+        if (databaseDefinition == null)
+        {
+            ExtendedProperties databaseProperties =
+                    ExtendedProperties.getSubset(configurer.getResolvedProps(), "query-database",
+                            true);
+            if (databaseProperties.isEmpty() == false)
+            {
+                DatabaseConfigurationContext configurationContext =
+                        BeanUtils
+                                .createBean(DatabaseConfigurationContext.class, databaseProperties);
+                databaseDefinition =
+                        new DatabaseDefinition(databaseProperties.getProperty("label"),
+                                configurationContext);
+            }
+        }
+        return databaseDefinition;
+    }
+
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/QueryServerLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/QueryServerLogger.java
new file mode 100644
index 0000000000000000000000000000000000000000..22b5f35da42b29b7ecd2639da30fbd56b69b54b6
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/server/QueryServerLogger.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.plugin.query.server;
+
+import ch.systemsx.cisd.authentication.ISessionManager;
+import ch.systemsx.cisd.openbis.generic.server.AbstractServerLogger;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel;
+import ch.systemsx.cisd.openbis.generic.shared.dto.Session;
+import ch.systemsx.cisd.openbis.plugin.query.shared.IQueryServer;
+
+/**
+ * 
+ *
+ * @author Franz-Josef Elmer
+ */
+class QueryServerLogger extends AbstractServerLogger implements IQueryServer
+{
+    QueryServerLogger(final ISessionManager<Session> sessionManager,
+            final boolean invocationSuccessful, final long elapsedTime)
+    {
+        super(sessionManager, invocationSuccessful, elapsedTime);
+    }
+
+    public String tryToGetQueryDatabaseLabel()
+    {
+        return null;
+    }
+
+    public TableModel queryDatabase(String sessionToken, String sqlQuery)
+    {
+        logAccess(sessionToken, "query_database", "SQL(%s)", sqlQuery);
+        return null;
+    }
+
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/IQueryServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/IQueryServer.java
new file mode 100644
index 0000000000000000000000000000000000000000..548ecccb659b3d2eb5a5054e3fda14d7c10267c1
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/IQueryServer.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2010 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.plugin.query.shared;
+
+import org.springframework.transaction.annotation.Transactional;
+
+import ch.systemsx.cisd.openbis.generic.shared.IServer;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RoleSet;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel;
+
+/**
+ * 
+ *
+ * @author Franz-Josef Elmer
+ */
+public interface IQueryServer extends IServer
+{
+    public String tryToGetQueryDatabaseLabel();
+    
+    @Transactional(readOnly = true)
+    @RolesAllowed(RoleSet.POWER_USER)
+    public TableModel queryDatabase(String sessionToken, String sqlQuery);
+
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/ResourceNames.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/ResourceNames.java
new file mode 100644
index 0000000000000000000000000000000000000000..b6f14459e33298464292a27218a98f80af0eb455
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/ResourceNames.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.plugin.query.shared;
+
+/**
+ * 
+ *
+ * @author Franz-Josef Elmer
+ */
+public class ResourceNames
+{
+    public final static String QUERY_PLUGIN_SERVICE = "query-plugin-service";
+
+    public final static String QUERY_PLUGIN_SERVER = "query-plugin-server";
+
+    private ResourceNames()
+    {
+    }
+
+}