Package org.h2.engine

Class SessionRemote

java.lang.Object
org.h2.engine.Session
org.h2.engine.SessionRemote
All Implemented Interfaces:
AutoCloseable, CastDataProvider, org.h2.store.DataHandler

public final class SessionRemote extends Session implements org.h2.store.DataHandler
The client side part of a session when using the server mode. This object communicates with a Session on the server side.
  • Field Details

  • Constructor Details

  • Method Details

    • getClusterServers

      public ArrayList<String> getClusterServers()
      Description copied from class: Session
      Get the list of the cluster servers for this session.
      Specified by:
      getClusterServers in class Session
      Returns:
      A list of "ip:port" strings for the cluster servers in this session.
    • hasPendingTransaction

      public boolean hasPendingTransaction()
      Description copied from class: Session
      Check whether this session has a pending transaction.
      Specified by:
      hasPendingTransaction in class Session
      Returns:
      true if it has
    • cancel

      public void cancel()
      Description copied from class: Session
      Cancel the current or next command (called when closing a connection).
      Specified by:
      cancel in class Session
    • cancelStatement

      public void cancelStatement(int id)
      Cancel the statement with the given id.
      Parameters:
      id - the statement id
    • getClientVersion

      public int getClientVersion()
      Returns the TCP protocol version of remote connection.
      Returns:
      the TCP protocol version
    • getAutoCommit

      public boolean getAutoCommit()
      Description copied from class: Session
      Check if this session is in auto-commit mode.
      Specified by:
      getAutoCommit in class Session
      Returns:
      true if the session is in auto-commit mode
    • setAutoCommit

      public void setAutoCommit(boolean autoCommit)
      Description copied from class: Session
      Set the auto-commit mode. This call doesn't commit the current transaction.
      Specified by:
      setAutoCommit in class Session
      Parameters:
      autoCommit - the new value
    • setAutoCommitFromServer

      public void setAutoCommitFromServer(boolean autoCommit)
    • autoCommitIfCluster

      public void autoCommitIfCluster()
      Calls COMMIT if the session is in cluster mode.
    • connectEmbeddedOrServer

      public Session connectEmbeddedOrServer(boolean openNew)
      Open a new (remote or embedded) session.
      Parameters:
      openNew - whether to open a new session in any case
      Returns:
      the session
    • removeServer

      public void removeServer(IOException e, int i, int count)
      Remove a server from the list of cluster nodes and disables the cluster mode.
      Parameters:
      e - the exception (used for debugging)
      i - the index of the server to remove
      count - the retry count index
    • prepareCommand

      public org.h2.command.CommandInterface prepareCommand(String sql, int fetchSize)
      Description copied from class: Session
      Parse a command and prepare it for execution.
      Specified by:
      prepareCommand in class Session
      Parameters:
      sql - the SQL statement
      fetchSize - the number of rows to fetch in one step
      Returns:
      the prepared command
    • checkClosed

      public void checkClosed()
      Check if this session is closed and throws an exception if so.
      Throws:
      org.h2.message.DbException - if the session is closed
    • close

      public void close()
      Description copied from class: Session
      Roll back pending transactions and close the session.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class Session
    • getTrace

      public org.h2.message.Trace getTrace()
      Description copied from class: Session
      Get the trace object
      Specified by:
      getTrace in class Session
      Returns:
      the trace object
    • getNextId

      public int getNextId()
    • getCurrentId

      public int getCurrentId()
    • done

      public void done(org.h2.value.Transfer transfer) throws IOException
      Called to flush the output after data has been sent to the server and just before receiving data. This method also reads the status code from the server and throws any exception the server sent.
      Parameters:
      transfer - the transfer object
      Throws:
      org.h2.message.DbException - if the server sent an exception
      IOException - if there is a communication problem between client and server
    • readException

      public static org.h2.message.DbException readException(org.h2.value.Transfer transfer) throws IOException
      Reads an exception.
      Parameters:
      transfer - the transfer object
      Returns:
      the exception
      Throws:
      IOException - on I/O exception
    • readSQLException

      public static SQLException readSQLException(org.h2.value.Transfer transfer) throws IOException
      Reads an exception as SQL exception.
      Parameters:
      transfer - the transfer object
      Returns:
      the exception
      Throws:
      IOException - on I/O exception
    • isClustered

      public boolean isClustered()
      Returns true if the connection was opened in cluster mode.
      Returns:
      true if it is
    • isClosed

      public boolean isClosed()
      Description copied from class: Session
      Check if close was called.
      Specified by:
      isClosed in class Session
      Returns:
      if the session has been closed
    • traceOperation

      public void traceOperation(String operation, int id)
      Write the operation to the trace system if debug trace is enabled.
      Parameters:
      operation - the operation performed
      id - the id of the operation
    • checkPowerOff

      public void checkPowerOff()
      Description copied from interface: org.h2.store.DataHandler
      Check if the simulated power failure occurred. This call will decrement the countdown.
      Specified by:
      checkPowerOff in interface org.h2.store.DataHandler
    • checkWritingAllowed

      public void checkWritingAllowed()
      Description copied from interface: org.h2.store.DataHandler
      Check if writing is allowed.
      Specified by:
      checkWritingAllowed in interface org.h2.store.DataHandler
    • getDatabasePath

      public String getDatabasePath()
      Description copied from interface: org.h2.store.DataHandler
      Get the database path.
      Specified by:
      getDatabasePath in interface org.h2.store.DataHandler
      Returns:
      the database path
    • getMaxLengthInplaceLob

      public int getMaxLengthInplaceLob()
      Description copied from interface: org.h2.store.DataHandler
      Get the maximum length of a in-place large object
      Specified by:
      getMaxLengthInplaceLob in interface org.h2.store.DataHandler
      Returns:
      the maximum size
    • openFile

      public org.h2.store.FileStore openFile(String name, String mode, boolean mustExist)
      Description copied from interface: org.h2.store.DataHandler
      Open a file at the given location.
      Specified by:
      openFile in interface org.h2.store.DataHandler
      Parameters:
      name - the file name
      mode - the mode
      mustExist - whether the file must already exist
      Returns:
      the file
    • getDataHandler

      public org.h2.store.DataHandler getDataHandler()
      Description copied from class: Session
      Get the data handler object.
      Specified by:
      getDataHandler in class Session
      Returns:
      the data handler
    • getLobSyncObject

      public Object getLobSyncObject()
      Description copied from interface: org.h2.store.DataHandler
      Get the synchronization object for lob operations.
      Specified by:
      getLobSyncObject in interface org.h2.store.DataHandler
      Returns:
      the synchronization object
    • getLobFileListCache

      public org.h2.util.SmallLRUCache<String,String[]> getLobFileListCache()
      Description copied from interface: org.h2.store.DataHandler
      Get the lob file list cache if it is used.
      Specified by:
      getLobFileListCache in interface org.h2.store.DataHandler
      Returns:
      the cache or null
    • getLastReconnect

      public int getLastReconnect()
    • getTempFileDeleter

      public org.h2.util.TempFileDeleter getTempFileDeleter()
      Description copied from interface: org.h2.store.DataHandler
      Get the temp file deleter mechanism.
      Specified by:
      getTempFileDeleter in interface org.h2.store.DataHandler
      Returns:
      the temp file deleter
    • getLobStorage

      public org.h2.store.LobStorageFrontend getLobStorage()
      Description copied from interface: org.h2.store.DataHandler
      Get the lob storage mechanism to use.
      Specified by:
      getLobStorage in interface org.h2.store.DataHandler
      Returns:
      the lob storage mechanism
    • readLob

      public int readLob(long lobId, byte[] hmac, long offset, byte[] buff, int off, int length)
      Description copied from interface: org.h2.store.DataHandler
      Read from a lob.
      Specified by:
      readLob in interface org.h2.store.DataHandler
      Parameters:
      lobId - the lob id
      hmac - the message authentication code
      offset - the offset within the lob
      buff - the target buffer
      off - the offset within the target buffer
      length - the number of bytes to read
      Returns:
      the number of bytes read
    • getJavaObjectSerializer

      public JavaObjectSerializer getJavaObjectSerializer()
      Description copied from interface: CastDataProvider
      Returns the custom Java object serializer, or null.
      Specified by:
      getJavaObjectSerializer in interface CastDataProvider
      Returns:
      the custom Java object serializer, or null
    • addTemporaryLob

      public org.h2.value.ValueLob addTemporaryLob(org.h2.value.ValueLob v)
      Description copied from class: Session
      Add a temporary LOB, which is closed when the session commits.
      Specified by:
      addTemporaryLob in class Session
      Parameters:
      v - the value
      Returns:
      the specified value
    • getCompareMode

      public org.h2.value.CompareMode getCompareMode()
      Description copied from interface: org.h2.store.DataHandler
      Return compare mode.
      Specified by:
      getCompareMode in interface org.h2.store.DataHandler
      Returns:
      Compare mode.
    • isRemote

      public boolean isRemote()
      Description copied from class: Session
      Check if this session is remote or embedded.
      Specified by:
      isRemote in class Session
      Returns:
      true if this session is remote
    • getCurrentSchemaName

      public String getCurrentSchemaName()
      Description copied from class: Session
      Get current schema.
      Specified by:
      getCurrentSchemaName in class Session
      Returns:
      the current schema name
    • setCurrentSchemaName

      public void setCurrentSchemaName(String schema)
      Description copied from class: Session
      Set current schema.
      Specified by:
      setCurrentSchemaName in class Session
      Parameters:
      schema - the schema name
    • setNetworkConnectionInfo

      public void setNetworkConnectionInfo(org.h2.util.NetworkConnectionInfo networkConnectionInfo)
      Description copied from class: Session
      Sets the network connection information if possible.
      Specified by:
      setNetworkConnectionInfo in class Session
      Parameters:
      networkConnectionInfo - the network connection information
    • getIsolationLevel

      public IsolationLevel getIsolationLevel()
      Description copied from class: Session
      Returns the isolation level.
      Specified by:
      getIsolationLevel in class Session
      Returns:
      the isolation level
    • setIsolationLevel

      public void setIsolationLevel(IsolationLevel isolationLevel)
      Description copied from class: Session
      Sets the isolation level.
      Specified by:
      setIsolationLevel in class Session
      Parameters:
      isolationLevel - the isolation level to set
    • getStaticSettings

      public Session.StaticSettings getStaticSettings()
      Description copied from class: Session
      Returns static settings. These settings cannot be changed during lifecycle of session.
      Specified by:
      getStaticSettings in class Session
      Returns:
      static settings
    • getDynamicSettings

      public Session.DynamicSettings getDynamicSettings()
      Description copied from class: Session
      Returns dynamic settings. These settings can be changed during lifecycle of session.
      Specified by:
      getDynamicSettings in class Session
      Returns:
      dynamic settings
    • currentTimestamp

      public org.h2.value.ValueTimestampTimeZone currentTimestamp()
      Description copied from interface: CastDataProvider
      Returns the current timestamp with maximum resolution. The value must be the same within a transaction or within execution of a command.
      Specified by:
      currentTimestamp in interface CastDataProvider
      Returns:
      the current timestamp for CURRENT_TIMESTAMP(9)
    • currentTimeZone

      public org.h2.util.TimeZoneProvider currentTimeZone()
      Description copied from interface: CastDataProvider
      Returns the current time zone.
      Specified by:
      currentTimeZone in interface CastDataProvider
      Returns:
      the current time zone
    • getMode

      public Mode getMode()
      Description copied from interface: CastDataProvider
      Returns the database mode.
      Specified by:
      getMode in interface CastDataProvider
      Returns:
      the database mode
    • getDatabaseMeta

      public org.h2.jdbc.meta.DatabaseMeta getDatabaseMeta()
      Description copied from class: Session
      Returns database meta information.
      Specified by:
      getDatabaseMeta in class Session
      Returns:
      database meta information
    • isOldInformationSchema

      public boolean isOldInformationSchema()
      Description copied from class: Session
      Returns whether INFORMATION_SCHEMA contains old-style tables.
      Specified by:
      isOldInformationSchema in class Session
      Returns:
      whether INFORMATION_SCHEMA contains old-style tables
    • zeroBasedEnums

      public boolean zeroBasedEnums()
      Description copied from interface: CastDataProvider
      Returns are ENUM values 0-based.
      Specified by:
      zeroBasedEnums in interface CastDataProvider
      Returns:
      are ENUM values 0-based