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

  1. Object
  2. ServerSession

Known subtypesMySql, Oracle, Postgres, SqlServer

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.ConnectorOpens sessions for one engine.

Constructors

public ServerSession()

Methods

public abstract Dialect dialect()The SQL this session’s server speaks.
public abstract int execute(String sql, Object[] params) throws IOExceptionRuns a statement that returns no rows.
public abstract List query(String sql, Object[] params) throws IOExceptionRuns a query: a list of Map rows keyed by column label, in column order.
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.
public abstract void begin() throws IOExceptionBegins a read-write transaction at the server’s default isolation.
public abstract void beginReadOnly() throws IOExceptionBegins a read-only transaction at the server’s default isolation.
public abstract void begin(boolean readOnly, TransactionIsolation isolation) throws IOExceptionBegins a transaction.
public abstract void commit() throws IOExceptionCommits the transaction.
public abstract void rollback() throws IOExceptionRolls the transaction back.
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.
public abstract long lastInsertId()The key the last INSERT generated, for an engine that reports one that way; 0 otherwise.
public abstract void close()Closes the session; closing twice does nothing.
public abstract boolean isClosed()True once the session is closed or its connection was lost.

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 IOException
Runs a statement that returns no rows.

Returns

the number of rows it changed

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.

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.

beginReadOnly

public abstract void beginReadOnly() throws IOException
Begins a read-only transaction at the server’s default isolation.

begin

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

commit

public abstract void commit() throws IOException
Commits the transaction.

rollback

public abstract void rollback() throws IOException
Rolls the transaction back.

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.

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.