Class TCPJDBCServer


  • public class TCPJDBCServer
    extends java.lang.Object
    Attaches to a DBSystem, and binds a TCP port and serves queries for JDBC connections. This object is used to programmatically create a TCP JDBC server on the local machine.

    Note that multiple servers can be constructed to serve the same DBSystem. You can not use this object to connect a single TCP server to multiple DBSystem objects.

    If the underlying database is shut down then this server is also shut down.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.net.InetAddress bind_address
      An InetAddress representing the interface that server is bound to - useful for multi-homed machines.
      private static int DEFAULT_TCP_PORT
      The default TCP port for Mckoi SQL Database.
      private TCPServer server
      The TCPServer object that is managing the connections to this database.
      private DBSystem system
      The DBSystem object that we are serving.
      private int tcp_port
      The TCP port that this server is bound to.
    • Constructor Summary

      Constructors 
      Constructor Description
      TCPJDBCServer​(DBSystem system)
      Constructs the TCP JDBC with the given DBSystem object, and sets the TCP port and address (for multi-homed computers) to the setting of the configuration in 'system'.
      TCPJDBCServer​(DBSystem system, int tcp_port)
      Constructs the TCP JDBC with the given DBSystem object, and sets the TCP port that we serve the database from.
      TCPJDBCServer​(DBSystem system, java.net.InetAddress bind_address, int tcp_port)
      Constructs the TCP JDBC with the given DBSystem object, and sets the inet address and TCP port that we serve the database from.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void registerShutdownDelegate()
      Registers the delegate that closes this server when the database shuts down.
      void start()
      Starts the server and binds it to the given port.
      void stop()
      Stops the server running on the given port.
      java.lang.String toString()
      Returns a string that contains some information about the server that is running.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_TCP_PORT

        private static final int DEFAULT_TCP_PORT
        The default TCP port for Mckoi SQL Database.
        See Also:
        Constant Field Values
      • system

        private DBSystem system
        The DBSystem object that we are serving.
      • bind_address

        private java.net.InetAddress bind_address
        An InetAddress representing the interface that server is bound to - useful for multi-homed machines. null means we bind to all interfaces.
      • tcp_port

        private int tcp_port
        The TCP port that this server is bound to.
      • server

        private TCPServer server
        The TCPServer object that is managing the connections to this database.
    • Constructor Detail

      • TCPJDBCServer

        public TCPJDBCServer​(DBSystem system,
                             java.net.InetAddress bind_address,
                             int tcp_port)
        Constructs the TCP JDBC with the given DBSystem object, and sets the inet address and TCP port that we serve the database from.

        Constructing this server does not open the port to receive connections from outside. To start the JDBC server you need to call the 'start' method.

      • TCPJDBCServer

        public TCPJDBCServer​(DBSystem system,
                             int tcp_port)
        Constructs the TCP JDBC with the given DBSystem object, and sets the TCP port that we serve the database from. This binds the server to all interfaces on the local machine.

        Constructing this server does not open the port to receive connections from outside. To start the JDBC server you need to call the 'start' method.

      • TCPJDBCServer

        public TCPJDBCServer​(DBSystem system)
        Constructs the TCP JDBC with the given DBSystem object, and sets the TCP port and address (for multi-homed computers) to the setting of the configuration in 'system'.

        Constructing this server does not open the port to receive connections from outside. To start the JDBC server you need to call the 'start' method.

    • Method Detail

      • registerShutdownDelegate

        private void registerShutdownDelegate()
        Registers the delegate that closes this server when the database shuts down.
      • start

        public void start()
        Starts the server and binds it to the given port. This method will start a new thread that listens for incoming connections.
      • stop

        public void stop()
        Stops the server running on the given port. This method will stop any threads that are listening for incoming connections.

        Note that this does NOT close the underlying DBSystem object. The DBSystem object must be closed separately.

      • toString

        public java.lang.String toString()
        Returns a string that contains some information about the server that is running.
        Overrides:
        toString in class java.lang.Object