Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public abstract class ServerSession
- Object
- ServerSession
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 types
class ServerSession.Connector | Opens sessions for one engine. |
Constructors
public ServerSession() |
Methods
Inherited methods
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 IOExceptionRuns a statement that returns no rows.
Returns
the number of rows it changed
Throws
query
public abstract List query(String sql, Object[] params)
throws IOExceptionRuns a query: a list of
Map rows keyed by column label, in column order.Throws
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 IOExceptionBegins a read-write transaction at the server’s default isolation.
Throws
beginReadOnly
public abstract void beginReadOnly()
throws IOExceptionBegins a read-only transaction at the server’s default isolation.
Throws
begin
public abstract void begin(boolean readOnly, TransactionIsolation isolation)
throws IOExceptionBegins a transaction.
Throws
commit
public abstract void commit()
throws IOExceptionCommits the transaction.
Throws
rollback
public abstract void rollback()
throws IOExceptionRolls the transaction back.
Throws
savepoint
public abstract void savepoint(String verb, String name)
throws IOExceptionRuns a savepoint statement:
verb is the dialect’s word for set, roll
back to or release, and name the savepoint.Throws
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.