package com.franz.ag.examples;
import com.franz.ag.*;
public class AGConnecting {
/**
* Demonstrates basics of connecting to a running default server
*
* You will need to start the default server before running this example.
*
* @param args unused
* @throws AllegroGraphException
*/
public static void main(String[] args) throws AllegroGraphException {
// Connect to the default server, which must already be running.
System.out.println("Attempting to connect to the default server.");
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
// This example connects to a server on the default port.
// For servers listening on a non-default port, e.g. 4126,
// uncomment this to specify the port:
// ags.setPort(4126);
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem -- please ensure the default server is running.", e);
}
System.out.println("Connected to the server on port " + ags.getPort());
// Disconnect from the server
System.out.println("Disconnecting from the server.");
ags.disable();
System.out.println("Done.");
}
}