# Poco::Data::ODBC

# class ConnectionHandle

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

## Description

ODBC connection handle class

## Member Summary

Member Functions: connect, disconnect, getLoginTimeout, getTimeout, handle, isConnected, operator bool, operator const SQLHDBC &, pHandle, setLoginTimeout, setTimeout

## Constructors

### ConnectionHandle

ConnectionHandle(
const std::string & connectString = "",
SQLULEN loginTimeout = 0,
SQLULEN timeout = 0
);

Creates the ConnectionHandle.

NOTE: some drivers/DBMS do not distinguish between login and connection timeouts, and setting one timeout overwrites the other.

## Destructor

### ~ConnectionHandle

~ConnectionHandle();

Creates the ConnectionHandle.

## Member Functions

### connect

bool connect(
const std::string & connectString = "",
SQLULEN loginTimeout = 0,
SQLULEN timeout = 0
);

Connects the handle to the database.

### disconnect

bool disconnect();

Disconnects the handle from database.

### getLoginTimeout

int getLoginTimeout() const;

Returns the login timeout in seconds. Must be called before the connection attempt.

### getTimeout

int getTimeout() const;

Returns the connection timeout in seconds.

### handle

const SQLHDBC & handle() const;

Returns const reference to handle;

### isConnected

bool isConnected() const;

Returns true if connected.

### operator bool

operator bool();

Returns true if handles are not null. True value is not a guarantee that the connection is valid.

### operator const SQLHDBC &

operator const SQLHDBC & () const;

Const conversion operator into reference to native type.

### pHandle

const SQLHDBC * pHandle() const;

Returns const pointer to handle;

### setLoginTimeout

void setLoginTimeout(
SQLULEN timeout
);

Sets the login timeout in seconds. Must be called before the connection attempt.

### setTimeout

void setTimeout(
int timeout
);

Sets the connection timeout in seconds.

## Variables

### CANT_SET_ATTR_SQLSTATE

static const std::string CANT_SET_ATTR_SQLSTATE;

### GEN_ERR_SQLSTATE

static const std::string GEN_ERR_SQLSTATE;

### UNSUPPORTED_SQLSTATE

static const std::string UNSUPPORTED_SQLSTATE;