Class ServerSession

java.lang.Object
com.codename1.db.sql.ServerSession
Direct Known Subclasses:
MySql, Oracle, Postgres, SqlServer

public abstract class ServerSession extends Object

An open session with a database server: Postgres, MySql, SqlServer or Oracle.

This is a base class, not a driver interface. Nothing looks an engine up by name: code that wants one names its class -- Postgres.connect(...), or its CONNECTOR field -- and an engine nothing names is stripped from the application.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Opens sessions for one engine.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Begins a read-write transaction at the server's default isolation.
    abstract void
    begin(boolean readOnly, TransactionIsolation isolation)
    Begins a transaction.
    abstract void
    Begins a read-only transaction at the server's default isolation.
    abstract void
    Closes the session; closing twice does nothing.
    abstract void
    Commits the transaction.
    abstract Dialect
    The SQL this session's server speaks.
    abstract int
    execute(String sql, Object[] params)
    Runs a statement that returns no rows.
    abstract boolean
    True once the session is closed or its connection was lost.
    abstract long
    The key the last INSERT generated, for an engine that reports one that way; 0 otherwise.
    abstract boolean
    True when beginning, committing and rolling back are protocol requests or session state of this client's own, rather than statements a caller could equally run.
    abstract List
    query(String sql, Object[] params)
    Runs a query: a list of Map rows keyed by column label, in column order.
    abstract void
    Rolls the transaction back.
    abstract void
    savepoint(String verb, String name)
    Runs a savepoint statement: verb is the dialect's word for set, roll back to or release, and name the savepoint.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ServerSession

      public ServerSession()
  • Method Details

    • dialect

      public abstract Dialect dialect()
      The SQL this session's server speaks.
    • execute

      public abstract int execute(String sql, Object[] params) throws IOException

      Runs a statement that returns no rows.

      Returns

      the number of rows it changed

      Throws:
      IOException
    • query

      public abstract List query(String sql, Object[] params) throws IOException
      Runs a query: a list of Map rows keyed by column label, in column order.
      Throws:
      IOException
    • ownsTransactionControl

      public abstract boolean ownsTransactionControl()
      True when beginning, committing and rolling back are protocol requests or session state of this client's own, rather than statements a caller could equally run.
    • begin

      public abstract void begin() throws IOException
      Begins a read-write transaction at the server's default isolation.
      Throws:
      IOException
    • beginReadOnly

      public abstract void beginReadOnly() throws IOException
      Begins a read-only transaction at the server's default isolation.
      Throws:
      IOException
    • begin

      public abstract void begin(boolean readOnly, TransactionIsolation isolation) throws IOException
      Begins a transaction.
      Throws:
      IOException
    • commit

      public abstract void commit() throws IOException
      Commits the transaction.
      Throws:
      IOException
    • rollback

      public abstract void rollback() throws IOException
      Rolls the transaction back.
      Throws:
      IOException
    • savepoint

      public abstract void savepoint(String verb, String name) throws IOException
      Runs a savepoint statement: verb is the dialect's word for set, roll back to or release, and name the savepoint.
      Throws:
      IOException
    • lastInsertId

      public abstract long lastInsertId()
      The key the last INSERT generated, for an engine that reports one that way; 0 otherwise.
    • close

      public abstract void close()
      Closes the session; closing twice does nothing.
    • isClosed

      public abstract boolean isClosed()
      True once the session is closed or its connection was lost.