This content has been marked as final.
Show 6 replies
-
1. Re: Query Execution error
715399 Apr 26, 2010 2:58 PM (in response to 765900)Hi,
Can you provide us with some more information, for instance:
- Are you using a Joseki-based SPARQL endpoint for your queries? If so, you might want to double check the joseki configuration file to make sure it points to the right semantic model.
- If querying the model programmatically, please provide a small snippet illustrating the problem.
- What happens when you query the model through SEM_MATCH in sqlplus - do you still get back 0 rows?
Regards,
Vladimir -
2. Re: Query Execution error
765900 Apr 27, 2010 5:30 AM (in response to 715399)Is joseki necessary to run any SPARQL query?? I haven used it as of now..
When i run the query through SQL PLUS it works fine..
the code snippet is:
package com.rfc.tools.jena.manager.views;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.rfc.tools.jena.manager.domain.AppModel;
import com.rfc.tools.jena.manager.domain.QueryExecutor;
public class QueryTab implements Refreshable
{
private final String CRLF = System.getProperty("line.separator");
private Text queryTextBox;
private List modelsList;
private Table resultsTable;
private Button executeButton;
private Composite queryGroup;
public QueryTab(TabFolder parent)
{
TabItem tab = new TabItem(parent, SWT.NONE);
tab.setText("Query");
Application.addListener(this);
layout(tab, parent);
}
private void layout(TabItem tab, Composite parent)
{
Composite group = new Composite(parent, SWT.NONE);
group.setLayout(new GridLayout(1, false));
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
tab.setControl(group);
queryGroup = new Composite(group, SWT.NONE);
queryGroup.setLayout(new GridLayout(3, false));
queryGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
modelsList = new List(queryGroup, SWT.BORDER | SWT.MULTI);
modelsList.setLayoutData(new GridData(GridData.FILL_VERTICAL));
modelsList.addSelectionListener(new ModelSelectionListener());
queryTextBox = new Text(queryGroup, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
GridData queryTextLayoutData = new GridData(GridData.FILL_HORIZONTAL);
queryTextLayoutData.heightHint = 100;
queryTextBox.setLayoutData(queryTextLayoutData);
queryTextBox.setText("SELECT ?s ?p ?o" + CRLF + "WHERE { ?s ?p ?o . }");
executeButton = new Button(queryGroup, SWT.PUSH);
executeButton.setText("Execute");
executeButton.addSelectionListener(new ExecuteButtonListener());
resultsTable = new Table(group, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
resultsTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
resultsTable.setLinesVisible(true);
resultsTable.setHeaderVisible(true);
refresh();
}
public void refresh()
{
modelsList.removeAll();
if (Application.database.isConnected())
{
for (AppModel model : Application.database.listModels())
{
modelsList.add(model.getName());
}
}
refreshExecuteButton();
queryGroup.pack();
}
private void refreshExecuteButton()
{
if (modelsList.getSelectionCount() > 0)
{
executeButton.setEnabled(true);
}
else
{
executeButton.setEnabled(false);
}
}
class ModelSelectionListener extends SelectionAdapter
{
@Override
public void widgetSelected(SelectionEvent e)
{
refreshExecuteButton();
}
}
class ExecuteButtonListener extends SelectionAdapter
{
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e)
{
resultsTable.removeAll();
Collection<String> selectedModels = Arrays.asList(modelsList.getSelection());
QueryExecutor executor = new QueryExecutor();
for (AppModel appModel : Application.database.listModels())
{
if (selectedModels.contains(appModel.getName()))
{
executor.addModel(Application.database, appModel);
}
}
ArrayList<String> columns = new ArrayList<String>();
ResultSet results = executor.execute(queryTextBox.getText());
while (results.hasNext())
{
QuerySolution solution = results.nextSolution();
if (columns.size() == 0)
{
Iterator<String> names = solution.varNames();
while (names.hasNext())
{
String name = names.next();
columns.add(name);
TableColumn subject = new TableColumn(resultsTable, SWT.NONE);
subject.setText(name);
subject.setWidth(150);
}
}
TableItem item = new TableItem(resultsTable, SWT.NONE);
for (int i = 0; i < columns.size(); i++)
{
RDFNode node = solution.get(columns.get(i));
item.setText(i, node.toString());
}
}
}
}
} -
3. Re: Query Execution error
alwu-Oracle Apr 30, 2010 1:12 PM (in response to 765900)It will be helpful for us if you run the following SQL query in SQL*Plus. You need to replace the <model_name> part with the name of the model that your query is running against.
select count(1) from mdsys.SEMM_<model_name>;
Thanks,
Zhe Wu -
4. Re: Query Execution error
alwu-Oracle Apr 30, 2010 1:13 PM (in response to alwu-Oracle)Forgot to mention that Joseki is not required to run SPARQL queries. Joseki is necessary when you need to set up a SPARQL service endpoint.
Thanks,
Zhe -
5. Re: Query Execution error
765900 May 1, 2010 11:14 AM (in response to alwu-Oracle)Thank you so much for the suggestion.. tried that command.. It says table or view doesn exist..
One more question.. Is Configuring ARQ necessary?? i mean i ve included the arq jar file in my library. Do i need to set up the ARQROOT also?? workin in windows, can you please tell me how to do the same??
Thanks and regards,
Sneha C.J -
6. Re: Query Execution error
alwu-Oracle May 2, 2010 7:46 PM (in response to 765900)You are welcome. I guess you need to trace your method carefully.
You don't need to configure ARQ in order to run SPARQL through Jena APIs. Including those relevant jars in your classpath is enough.
Hope it helps,
Zhe Wu