# Poco::Data::ODBC

# class SessionImpl

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

## Description

Implements SessionImpl interface

## Inheritance

Direct Base Classes: Poco::Data::AbstractSessionImpl < SessionImpl >

All Base Classes: Poco::Data::AbstractSessionImpl < SessionImpl >

## Member Summary

Member Functions: addFeatures, autoBind, autoCommit, autoExtract, begin, canTransact, close, commit, connectorName, createStatementImpl, dataTypeInfo, dbEncoding, dbc, getConnectionTimeout, getCursorUse, getDBEncoding, getMaxFieldSize, getMultiActiveResultset, getQueryTimeout, getTransactionIsolation, hasTransactionIsolation, isAutoBind, isAutoCommit, isAutoExtract, isConnected, isTransaction, isTransactionIsolation, maxStatementLength, open, queryTimeout, reset, rollback, setConnectionTimeout, setCursorUse, setDBEncoding, setMaxFieldSize, setMultiActiveResultset, setQueryTimeout, setTransactionIsolation

## Enumerations

### CursorUse

ODBC_CURSOR_USE_ALWAYS = Poco::Data::SessionImpl::CURSOR_USE_ALWAYS

ODBC_CURSOR_USE_IF_NEEDED = Poco::Data::SessionImpl::CURSOR_USE_IF_NEEDED

ODBC_CURSOR_USE_NEVER = Poco::Data::SessionImpl::CURSOR_USE_NEVER

### TransactionCapability

ODBC_TXN_CAPABILITY_UNKNOWN = - 1

ODBC_TXN_CAPABILITY_FALSE = 0

ODBC_TXN_CAPABILITY_TRUE = 1

## Constructors

### SessionImpl

SessionImpl(
const std::string & connect,
std::size_t loginTimeout,
std::size_t maxFieldSize = ODBC_MAX_FIELD_SIZE,
bool autoBind = true,
bool autoExtract = true
);

Creates the SessionImpl. Opens a connection to the database. Throws NotConnectedException if connection was not succesful.

### SessionImpl

SessionImpl(
const std::string & connect,
Poco::Any maxFieldSize = ODBC_MAX_FIELD_SIZE,
bool enforceCapability = false,
bool autoBind = true,
bool autoExtract = true
);

Creates the SessionImpl. Opens a connection to the database.

## Destructor

### ~SessionImpl

~SessionImpl() override;

Destroys the SessionImpl.

## Member Functions

### addFeatures

void addFeatures();

Adds the ODBC session features and properties.

### autoBind

void autoBind(
const std::string & param35,
bool val
);

Sets automatic binding for the session.

### autoCommit

void autoCommit(
const std::string & param34,
bool val
);

Sets autocommit property for the session.

### autoExtract

void autoExtract(
const std::string & param36,
bool val
);

Sets automatic extraction for the session.

### begin

void begin() override;

Starts a transaction

### canTransact

bool canTransact() const override;

Returns true if connection is transaction-capable.

### close

void close() override;

Closes the connection

### commit

void commit() override;

Commits and ends a transaction

### connectorName

const std::string & connectorName() const override;

Returns the name of the connector.

### createStatementImpl

Poco::SharedPtr < Poco::Data::StatementImpl > createStatementImpl() override;

Returns an ODBC StatementImpl

### dataTypeInfo

Poco::Any dataTypeInfo(
const std::string & rName = ""
) const;

Returns the data types information.

### dbEncoding

const std::string & dbEncoding() const;

Returns the database encoding.

### dbc

const ConnectionHandle & dbc() const;

Returns the connection handle.

### getConnectionTimeout

std::size_t getConnectionTimeout() const override;

Returns the session connection timeout value.

### getCursorUse

Poco::Any getCursorUse(
const std::string & param40
) const;

Returns the use of cursors.

### getDBEncoding

Poco::Any getDBEncoding(
const std::string & param42
) const;

Returns the database encoding.

### getMaxFieldSize

Poco::Any getMaxFieldSize(
const std::string & rName = ""
) const;

Returns the max field size (the default used when column size is unknown).

### getMultiActiveResultset

bool getMultiActiveResultset(
const std::string & param44
) const;

Returns the multiple active resultset capability, if available. Returns false, if feature is not available.

### getQueryTimeout

Poco::Any getQueryTimeout(
const std::string & param38
) const;

Returns the timeout (in seconds) for queries, or -1 if no timeout has been set.

### getTransactionIsolation

Poco::UInt32 getTransactionIsolation() const override;

Returns the transaction isolation level.

### hasTransactionIsolation

bool hasTransactionIsolation(
Poco::UInt32
) const override;

Returns true iff the transaction isolation level corresponding to the supplied bitmask is supported.

### isAutoBind

bool isAutoBind(
const std::string & name = ""
) const;

Returns true if binding is automatic for this session.

### isAutoCommit

bool isAutoCommit(
const std::string & name = ""
) const;

Returns autocommit property value.

### isAutoExtract

bool isAutoExtract(
const std::string & name = ""
) const;

Returns true if extraction is automatic for this session.

### isConnected

bool isConnected() const override;

Returns true if session is connected

### isTransaction

bool isTransaction() const override;

Returns true iff a transaction is in progress.

### isTransactionIsolation

bool isTransactionIsolation(
Poco::UInt32
) const override;

Returns true iff the transaction isolation level corresponds to the supplied bitmask.

### maxStatementLength

int maxStatementLength() const;

Returns maximum length of SQL statement allowed by driver.

### open

void open(
const std::string & connect = ""
) override;

Opens a connection to the Database

### queryTimeout

int queryTimeout() const;

Returns the timeout (in seconds) for queries, or -1 if no timeout has been set.

### reset

void reset() override;

Do nothing

### rollback

void rollback() override;

Aborts a transaction

### setConnectionTimeout

void setConnectionTimeout(
std::size_t timeout
) override;

Sets the session connection timeout value.

### setCursorUse

void setCursorUse(
const std::string & param39,
const Poco::Any & value
);

Sets the use of cursors:

- SQL_CUR_USE_ODBC - always
- SQL_CUR_USE_IF_NEEDED - if needed
- SQL_CUR_USE_DRIVER - never

### setDBEncoding

void setDBEncoding(
const std::string & param41,
const Poco::Any & value
);

Sets the database encoding. Value must be of type std::string.

### setMaxFieldSize

void setMaxFieldSize(
const std::string & rName,
const Poco::Any & rValue
);

Sets the max field size (the default used when column size is unknown).

### setMultiActiveResultset

void setMultiActiveResultset(
const std::string & param43,
bool value
);

Sets the multiple active resultset capability, if available. Does nothing, if feature is not available.

### setQueryTimeout

void setQueryTimeout(
const std::string & param37,
const Poco::Any & value
);

Sets the timeout (in seconds) for queries. Value must be of type int.

### setTransactionIsolation

void setTransactionIsolation(
Poco::UInt32 ti
) override;

Sets the transaction isolation level.

## Variables

### ODBC_MAX_FIELD_SIZE

static const std::size_t ODBC_MAX_FIELD_SIZE = 1024u;