# Poco::Data::PostgreSQL

# class SessionHandle

Library: Data/PostgreSQL
Package: PostgreSQL
Header: Poco/Data/PostgreSQL/SessionHandle.h

## Description

PostgreSQL connection(session) handle

## Member Summary

Member Functions: autoCommit, cancel, clientEncoding, commit, connect, connectionDefaultParameters, connectionParameters, connectionString, deallocatePreparedStatement, disconnect, hasTransactionIsolation, isAsynchronousCommit, isAutoCommit, isConnected, isTransaction, lastError, libpqVersion, mutex, operator PGconn *, parameterStatus, protocoVersion, reset, rollback, serverProcessID, serverVersion, setAsynchronousCommit, setTransactionIsolation, startTransaction, transactionIsolation

## Constructors

### SessionHandle

explicit SessionHandle();

Creates session handle

## Destructor

### ~SessionHandle

~SessionHandle();

Destroy handle, close connection

## Member Functions

### autoCommit

void autoCommit(
bool val
);

is the connection in auto commit mode?

### cancel

void cancel();

Attempts to cancel in-process statements

### clientEncoding

std::string clientEncoding() const;

returns the client encoding

### commit

void commit();

Commit transaction

### connect

void connect(
const std::string & aConnectionString
);

Connect to server

### connect

void connect(
const char * aConnectionString
);

### connect

void connect(
const char * aHost,
const char * aUser,
const char * aPassword,
const char * aDatabase,
unsigned short aPort,
unsigned int aConnectionTimeout
);

### connectionDefaultParameters

static SessionParametersMap connectionDefaultParameters();

returns the default parameters used on a connection

### connectionParameters

SessionParametersMap connectionParameters() const;

returns the parameters used on the connection

### connectionString

std::string connectionString() const;

returns the string used to connect

### deallocatePreparedStatement

void deallocatePreparedStatement(
const std::string & aPreparedStatementToDeAllocate
);

deallocates a previously prepared statement

### disconnect

void disconnect();

Close connection

### hasTransactionIsolation

static bool hasTransactionIsolation(
Poco::UInt32 aTI
);

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

### isAsynchronousCommit

bool isAsynchronousCommit() const;

is the connection in Asynchronous commit mode?

### isAutoCommit

bool isAutoCommit() const;

is the connection in auto commit mode?

### isConnected

bool isConnected() const;

is a connection established?

### isTransaction

bool isTransaction() const;

Returns true iff a transaction is a transaction is in progress, false otherwise.

### lastError

std::string lastError() const;

last error on the connection

### libpqVersion

int libpqVersion() const;

returns the version of libpq

### mutex

Poco::FastMutex & mutex();

Get the sessionHandle mutex to protect the connection pointer

### operator PGconn *

operator PGconn * ();

Get the PostgreSQL connection pointer

### parameterStatus

std::string parameterStatus(
const std::string & param
) const;

Returns the value configured on the server for the given parameter.

### protocoVersion

int protocoVersion() const;

the protocol version between the client and the server

### reset

bool reset();

reset the connection

### rollback

void rollback();

Rollback trabsaction

### serverProcessID

int serverProcessID() const;

the process ID of the remotee server process

### serverVersion

int serverVersion() const;

remote server version

### setAsynchronousCommit

void setAsynchronousCommit(
bool aShouldAsynchronousCommit = true
);

is the connection in Asynchronous commit mode?

### setTransactionIsolation

void setTransactionIsolation(
Poco::UInt32 aTI
);

Sets the transaction isolation level.

### startTransaction

void startTransaction();

Start transaction

### transactionIsolation

Poco::UInt32 transactionIsolation() const;

Returns the transaction isolation level.