# Poco::Data

# class SessionImpl

Library: Data
Package: DataCore
Header: Poco/Data/SessionImpl.h

## Description

Interface for Session functionality that subclasses must extend. SessionImpl objects are noncopyable.

## Inheritance

Direct Base Classes: Poco::RefCountedObject

All Base Classes: Poco::RefCountedObject

Known Derived Classes: AbstractSessionImpl, PooledSessionImpl

## Member Summary

Member Functions: begin, canTransact, close, commit, connectionString, connectorName, createStatementImpl, dbmsName, getConnectionTimeout, getFeature, getLoginTimeout, getProperty, getTransactionIsolation, hasFeature, hasProperty, hasTransactionIsolation, isAutocommit, isConnected, isGood, isTransaction, isTransactionIsolation, open, operator =, reconnect, reset, rollback, setConnectionString, setConnectionTimeout, setDBMSName, setFeature, setLoginTimeout, setProperty, setTransactionIsolation, shouldParse, uri

Inherited Functions: duplicate, referenceCount, release

## Types Aliases

### Ptr

using Ptr = Poco::AutoPtr < SessionImpl >;

## Constructors

### SessionImpl

SessionImpl() = delete;

### SessionImpl

SessionImpl(
const SessionImpl & param137
) = delete;

### SessionImpl

SessionImpl(
const std::string & connectionString,
std::size_t loginTimeout = LOGIN_TIMEOUT_DEFAULT
);

Creates the SessionImpl.

## Destructor

### ~SessionImpl

~SessionImpl() override;

Destroys the SessionImpl.

## Member Functions

### begin

virtual void begin() = 0;

Starts a transaction.

### canTransact

virtual bool canTransact() const = 0;

Returns true if session has transaction capabilities.

### close

virtual void close() = 0;

Closes the connection.

### commit

virtual void commit() = 0;

Commits and ends a transaction.

### connectionString

const std::string & connectionString() const;

Returns the connection string.

### connectorName

virtual const std::string & connectorName() const = 0;

Returns the name of the connector.

### createStatementImpl

virtual Poco::SharedPtr < StatementImpl > createStatementImpl() = 0;

Creates a StatementImpl.

### dbmsName

const std::string & dbmsName() const;

Returns the DBMS name. The name must be set by the implementation. Defaults to "unknown".

### getConnectionTimeout

virtual std::size_t getConnectionTimeout() const = 0;

Returns the session connection timeout value.

### getFeature

virtual bool getFeature(
const std::string & name
) const = 0;

Look up the state of a feature.

Features are a generic extension mechanism for session implementations. and are defined by the underlying SessionImpl instance.

Throws a NotSupportedException if the requested feature is not supported by the underlying implementation.

### getLoginTimeout

std::size_t getLoginTimeout() const;

Returns the session login timeout value.

### getProperty

virtual Poco::Any getProperty(
const std::string & name
) const = 0;

Look up the value of a property.

Properties are a generic extension mechanism for session implementations. and are defined by the underlying SessionImpl instance.

Throws a NotSupportedException if the requested property is not supported by the underlying implementation.

### getTransactionIsolation

virtual Poco::UInt32 getTransactionIsolation() const = 0;

Returns the transaction isolation level.

### hasFeature

virtual bool hasFeature(
const std::string & name
) const = 0;

Returns true if session has the named feature.

### hasProperty

virtual bool hasProperty(
const std::string & name
) const = 0;

Returns true if session has the named feature.

### hasTransactionIsolation

virtual bool hasTransactionIsolation(
Poco::UInt32
) const = 0;

Returns true if and only if the transaction isolation level corresponding to the supplied bitmask is supported.

### isAutocommit

bool isAutocommit() const;

Returns true if autocommit is on, false otherwise.

### isConnected

virtual bool isConnected() const = 0;

Returns true if session is connected, false otherwise.

### isGood

virtual bool isGood() const;

Returns true if session is good and can be used, false otherwise.

The default implementation returns result of isConnected().

### isTransaction

virtual bool isTransaction() const = 0;

Returns true if and only if a transaction is in progress, false otherwise.

### isTransactionIsolation

virtual bool isTransactionIsolation(
Poco::UInt32
) const = 0;

Returns true if and only if the transaction isolation level corresponds to the supplied bitmask.

### open

virtual void open(
const std::string & connectionString = ""
) = 0;

Opens the session using the supplied string. Can also be used with default empty string to reconnect a disconnected session. If the connection is not established within requested timeout (specified in seconds), a ConnectionFailedException is thrown. Zero timout means indefinite

### operator =

SessionImpl & operator = (
const SessionImpl & param138
) = delete;

### reconnect

void reconnect();

Closes the connection and opens it again.

### reset

virtual void reset() = 0;

Reset connection with dababase and clears session state, but without disconnecting

### rollback

virtual void rollback() = 0;

Aborts a transaction.

### setConnectionTimeout

virtual void setConnectionTimeout(
std::size_t timeout
) = 0;

Sets the session connection timeout value.

### setFeature

virtual void setFeature(
const std::string & name,
bool state
) = 0;

Set the state of a feature.

Features are a generic extension mechanism for session implementations. and are defined by the underlying SessionImpl instance.

Throws a NotSupportedException if the requested feature is not supported by the underlying implementation.

### setLoginTimeout

void setLoginTimeout(
std::size_t timeout
);

Sets the session login timeout value.

### setProperty

virtual void setProperty(
const std::string & name,
const Poco::Any & value
) = 0;

Set the value of a property.

Properties are a generic extension mechanism for session implementations. and are defined by the underlying SessionImpl instance.

Throws a NotSupportedException if the requested property is not supported by the underlying implementation.

### setTransactionIsolation

virtual void setTransactionIsolation(
Poco::UInt32
) = 0;

Sets the transaction isolation level.

### shouldParse

bool shouldParse() const;

Returns true if SQL parser is enabled, false otherwise.

### uri

static std::string uri(
const std::string & connector,
const std::string & connectionString
);

Returns formatted URI.

### uri

std::string uri() const;

Returns the URI for this session.

### setConnectionString

void setConnectionString(
const std::string & connectionString
);

Sets the connection string. Should only be called on disconnected sessions. Throws InvalidAccessException when called on a connected session.

### setDBMSName

void setDBMSName(
const std::string & name
);

Sets the DBMS name.

## Variables

### CONNECTION_TIMEOUT_DEFAULT

static const std::size_t CONNECTION_TIMEOUT_DEFAULT = CONNECTION_TIMEOUT_INFINITE;

Default connection/login timeout in seconds.

### CONNECTION_TIMEOUT_INFINITE

static const std::size_t CONNECTION_TIMEOUT_INFINITE = 0;

Infinite connection/login timeout.

### CURSOR_USE_ALWAYS

static const int CURSOR_USE_ALWAYS = 0;

### CURSOR_USE_IF_NEEDED

static const int CURSOR_USE_IF_NEEDED = 1;

### CURSOR_USE_NEVER

static const int CURSOR_USE_NEVER = 2;

### LOGIN_TIMEOUT_DEFAULT

static const std::size_t LOGIN_TIMEOUT_DEFAULT = 60;

Default connection/login timeout in seconds.

### LOGIN_TIMEOUT_INFINITE

static const std::size_t LOGIN_TIMEOUT_INFINITE = 0;

Infinite connection/login timeout.