Class ClientSession

java.lang.Object
org.basex.api.client.Session
org.basex.api.client.ClientSession
All Implemented Interfaces:
Closeable, AutoCloseable

public class ClientSession extends Session
This class contains methods to execute database commands via the client/server architecture. Commands are sent to the server instance over a socket connection:
  • A socket instance is created by the constructor.
  • The execute(java.lang.String, java.io.OutputStream) method sends database commands to the server. All strings are encoded as UTF8 and suffixed by a zero byte.
  • If the command has been successfully executed, the result string is read.
  • Next, the command info string is read.
  • A last byte is next sent to indicate if command execution was successful (0) or not (1).
  • close() closes the session by sending the Commands.Cmd.EXIT command to the server.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • ClientSession

      public ClientSession(Context context, String username, String password) throws IOException
      Constructor, specifying login data.
      Parameters:
      context - database context
      username - user name
      password - password (plain text)
      Throws:
      IOException - I/O exception
    • ClientSession

      public ClientSession(Context context, String username, String password, OutputStream output) throws IOException
      Constructor, specifying login data and an output stream.
      Parameters:
      context - database context
      username - user name
      password - password (plain text)
      output - client output; if set to null, results will be returned as strings
      Throws:
      IOException - I/O exception
    • ClientSession

      public ClientSession(String host, int port, String username, String password) throws IOException
      Constructor, specifying the server host:port combination and login data.
      Parameters:
      host - server name
      port - server port
      username - user name
      password - password (plain text)
      Throws:
      IOException - I/O exception
    • ClientSession

      public ClientSession(String host, int port, String username, String password, OutputStream output) throws IOException
      Constructor, specifying the server host:port combination, login data and an output stream.
      Parameters:
      host - server name
      port - server port
      username - user name
      password - password (plain text)
      output - client output; if set to null, results will be returned as strings
      Throws:
      IOException - I/O exception
  • Method Details