AGSailConnections.java

package com.franz.agsail.examples;

import com.franz.ag.*;
import com.knowledgereefsystems.agsail.*;

import java.io.File;

import org.openrdf.sail.*;

public class AGSailConnections {

    /**
     * Demonstrates basics of connecting to a server
     * 
     * @param args unused
     * @throws AllegroGraphException
     */
    public static void main(String[] args) throws SailException {
        
        // Specify the SAIL, including AllegroGraph server and store parameters
        Sail sail = new AllegroSail("localhost", 4567, false, "store", new File(AGPaths.TRIPLE_STORES), 0, 0, false, false);
        
        // Connect and open the store (create it if necessary)  
        sail.initialize();
        
        // Can one open a read-only Sail?  Not currently.
        System.out.println("Sail isWritable: " + sail.isWritable());
        
        // Can one open a remote Sail?  Not currently.
        System.out.println("Sail DataDir: " + sail.getDataDir());
        
        // Get the connection object
        SailConnection sc = sail.getConnection();
       
        // Show some properties of the connection
        System.out.println("Sail Connection: " + sc);
        System.out.println("Sail Connection isOpen: " + sc.isOpen());
        System.out.println("Sail Connection size: " + sc.size());
        
        // Close the connection
        sc.close();
        System.out.println("Sail Connection isOpen: " + sc.isOpen());
        
        // Disconnect from the server
        sail.shutDown();
        System.out.println("Done.");
        
    }
    
}

Up | Next