franz inc logo  
  download learning center franz inc search franz inc resources franz inc          

allegrograph
racer
tbc
services
support
  Learning Center
  Documentation
  Updates
     Info
  FAQ
about

RSS Feeds

AllegroServe at opensource.franz.com

AGDisconnecting.java

package com.franz.ag.examples;

import com.franz.ag.*;

public class AGDisconnecting {

    /**
     * Demonstrates basics of disconnecting from and reconnecting to a running 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 {
            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();
        
        // Confirm disconnection
        System.out.println("Connection status enabled? " + ags.isEnabled());
        
        // Reconnect to the server.
        System.out.println("Attempting to reconnect.");
        try {
            ags.enable();
        } catch (Exception e) {
            throw new AllegroGraphException("Server connection problem -- please ensure the default server is running.", e);
        }

        System.out.println("Reconnected to the server on port " + ags.getPort());
        
        // Show current server parameter settings
        AGServerInfo.showConnectionInstanceInfo(ags);
        
        // Disconnect from the server
        System.out.println("Disconnecting from the server.");
        ags.disable();
        System.out.println("Done.");

    }
    
}

Up | Next

 

© 2008 Franz Inc - Privacy Statement
[ Consulting Services | Franz | TopQuadrant | Racer Systems ]