Package spark.api

Examples of spark.api.Connection.createCommand()


  }
 
  public static void testQuery() throws Exception {
    DataSource myDS = new ProtocolDataSource("http://DBpedia.org/sparql");
    Connection conn = myDS.getConnection(NoCredentials.INSTANCE);
    Command query = conn.createCommand("SELECT ?p ?o WHERE { <http://dbpedia.org/resource/Terry_Gilliam> ?p ?o }");   
    Solutions solutions = query.executeQuery();
   
    showMetadata(solutions);
    logger.debug("vars = {}", solutions.getVariables());
    int row = 0;
View Full Code Here


  }
 
  public static void testQuery2() throws Exception {
    DataSource myDS = new ProtocolDataSource("http://DBpedia.org/sparql");
    Connection conn = myDS.getConnection(NoCredentials.INSTANCE);
    Command query = conn.createCommand("SELECT ?p ?o WHERE { <http://dbpedia.org/resource/Terry_Gilliam> ?p ?o }");   
    Solutions solutions = query.executeQuery();
   
    showMetadata(solutions);
    logger.debug("vars = {}", solutions.getVariables());
    int row = 0;
View Full Code Here

  }
 
  public static void testAsk() throws Exception {
    DataSource myDS = new ProtocolDataSource("http://DBpedia.org/sparql");
    Connection conn = myDS.getConnection(NoCredentials.INSTANCE);
    Command query = conn.createCommand("ASK { <http://dbpedia.org/resource/Terry_Gilliam> ?p ?o }");   
   
    Result r = query.execute();
    showMetadata(r);
    logger.debug("result = {}", ((BooleanResult)r).getResult());
   
View Full Code Here

  }
 
  public static void testAsk2() throws Exception {
    DataSource myDS = new ProtocolDataSource("http://DBpedia.org/sparql");
    Connection conn = myDS.getConnection(NoCredentials.INSTANCE);
    Command query = conn.createCommand("ASK { <http://dbpedia.org/resource/Terry_Gilliam> ?p ?o }");   
   
    logger.debug("result = {}", query.executeAsk());
   
    query.close();
    conn.close();
View Full Code Here

    final AtomicInteger counter = new AtomicInteger();

    Runnable r = new Runnable() {
      public void run() {
        Connection c = f.getSource().getConnection(NoCredentials.INSTANCE);
        Command cmd = c.createCommand("SELECT ?p ?o WHERE { <http://dbpedia.org/resource/Terry_Gilliam> ?p ?o }");
        cmd.setTimeout(30);
        try {
          Solutions s = cmd.executeQuery();
          Assert.assertNotNull(s);
          try {
View Full Code Here

 
  static void doQuery(DataSource ds, long timeout) {
    log("getting connection");
    Connection c = ds.getConnection(NoCredentials.INSTANCE);
    try {
      Command cmd = c.createCommand(query);
      cmd.setTimeout(timeout);
      exec(cmd);
    } catch (Exception e) {
      log("Exception (" + e.getMessage() + ")");
    } finally {
View Full Code Here

 
  public static void testCancel() throws Exception {
    final ProtocolDataSource ds = new ProtocolDataSource(url);
    ds.setConnectionPoolSize(1);
    Connection conn = ds.getConnection(NoCredentials.INSTANCE);
    final Command c = conn.createCommand(query);
    final Command c2 = conn.createCommand(query);
   
    final CountDownLatch done = new CountDownLatch(2);
    new Thread(new Runnable() {
      public void run() {
View Full Code Here

  public static void testCancel() throws Exception {
    final ProtocolDataSource ds = new ProtocolDataSource(url);
    ds.setConnectionPoolSize(1);
    Connection conn = ds.getConnection(NoCredentials.INSTANCE);
    final Command c = conn.createCommand(query);
    final Command c2 = conn.createCommand(query);
   
    final CountDownLatch done = new CountDownLatch(2);
    new Thread(new Runnable() {
      public void run() {
        exec(c);
View Full Code Here

    String port = args[1];
    String query = args[2];
    System.out.println("Connecting to " + host + ":" + port);
    DataSource ds = new SHPDataSource(host, Integer.parseInt(port));
    Connection conn = ds.getConnection(NoCredentials.INSTANCE);
    Command command = conn.createCommand(query);
    command.setTimeout(120000);
   
    System.out.println("Executing query....");
    Solutions results = command.executeQuery();
   
View Full Code Here

  public Solutions helpExecuteQuery(DummySherpaServer server, int batchSize) {
    InetSocketAddress serverAddress = server.getAddress();
    DataSource ds = new SHPDataSource(serverAddress.getHostName(),
        serverAddress.getPort());
    Connection conn = ds.getConnection(NoCredentials.INSTANCE);
    Command command = conn
        .createCommand("SELECT ?x ?y WHERE { this should be a real query but the test doesn't actually do anything real.");
    ((SHPCommand) command).setBatchSize(batchSize);
    return command.executeQuery();
  }
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.