BdbServerConnection (Oracle - Berkeley DB Client-Server API)
Date: 2018-05-29

com.sleepycat.client

## Class BdbServerConnection

- java.lang.Object
- - com.sleepycat.client.BdbServerConnection

- All Implemented Interfaces:
    java.lang.AutoCloseable

      public class BdbServerConnection
      extends java.lang.Object
      implements java.lang.AutoCloseable

  A connection with a specific BDB server.

  BdbServerConnection is not thread-safe. Objects created from a connection use the connection internally, therefore they are not thread-safe either. A connection together with all objects created from it should only be accessed from a single thread. For example, a connection, an environment handle opened from it and a database handle opened from the environment handle, all three objects should be accessed from the same thread. It is an error to access the environment handle and the database handle from different threads.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `BdbServerAdmin` | `adminService()` Return a `BdbServerAdmin` which can be used to perform administrative operations on the connected server.
    `void` | `close()` Close this connection.
    `static BdbServerConnection` | `connect(java.lang.String host, int port)` Open a new connection to the specified BDB server.
    `static BdbServerConnection` | `connectSsl(java.lang.String host, int port, SslConfig sslConfig, int timeout)` Open a new SSL connection to the specified BDB server.
    `java.nio.ByteOrder` | `getServerByteOrder()` Return the native byte order of the connected server.
    `default <V> V` | `handleRuntimeExceptions(com.sleepycat.client.RemoteServiceCallable<V> remote)`
    `SEnvironment` | `openEnvironment(java.lang.String home, SEnvironmentConfig config)` Open a remote environment and return an environment handle.
    `default <V> V` | `remoteCall(com.sleepycat.client.RemoteServiceCallable<V> remote)`
    `default <V> V` | `remoteCallWithIOException(com.sleepycat.client.RemoteServiceCallable<V> remote)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### connect

          public static BdbServerConnection connect(java.lang.String host,
                                                    int port)
                                             throws SDatabaseException

      Open a new connection to the specified BDB server.
      Parameters:
        `host` - the server's host URL
        `port` - the server's listening port
      Returns:
        a new connection
      Throws:
        `BdbConnectionException` - if an error occurred while connecting to the server
        `SDatabaseException` - if any error occurs

    - #### connectSsl

          public static BdbServerConnection connectSsl(java.lang.String host,
                                                       int port,
                                                       SslConfig sslConfig,
                                                       int timeout)
                                                throws SDatabaseException

      Open a new SSL connection to the specified BDB server.
      Parameters:
        `host` - the server's host URL
        `port` - the server's listening port
        `sslConfig` - the SSL configuration
        `timeout` - the timeout in milliseconds for each remote request, zero as an infinite timeout
      Returns:
        a new connection
      Throws:
        `BdbConnectionException` - if an error occurred while connecting to the server
        `SDatabaseException` - if any error occurs

    - #### adminService

          public BdbServerAdmin adminService()

      Return a `BdbServerAdmin` which can be used to perform administrative operations on the connected server.
      Returns:
        a BdbServerAdmin

    - #### getServerByteOrder

          public java.nio.ByteOrder getServerByteOrder()

      Return the native byte order of the connected server.
      Returns:
        the native byte order of the connected server

    - #### openEnvironment

          public SEnvironment openEnvironment(java.lang.String home,
                                              SEnvironmentConfig config)
                                       throws java.io.IOException,
                                              SDatabaseException

      Open a remote environment and return an environment handle.
      Parameters:
        `home` - the environment's home directory. The directory must specified as a relative path
        `config` - the environment attributes. If null, system default attributes are used
      Returns:
        an environment handle
      Throws:
        `java.io.IOException` - if the environment does not exist or cannot be accessed
        `SResourceInUseException` - if the environment is being recovered or deleted
        `SDatabaseException` - if any error occurs

    - #### close

          public void close()

      Close this connection.

      After closing this connection, all objects created from this connection must be discarded.

      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### remoteCallWithIOException

          public <V> V remoteCallWithIOException(com.sleepycat.client.RemoteServiceCallable<V> remote)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### remoteCall

          public <V> V remoteCall(com.sleepycat.client.RemoteServiceCallable<V> remote)

    - #### handleRuntimeExceptions

          public <V> V handleRuntimeExceptions(com.sleepycat.client.RemoteServiceCallable<V> remote)
                                        throws org.apache.thrift.TException

      Throws:
        `org.apache.thrift.TException`

Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.