ConnectString Class Reference
[Public API]

Class for parsing parameters from connect string. More...

#include <connectstring.h>

List of all members.


Public Member Functions

 ConnectString (const char *pStr)
 Constructor.
std::string dbname () const
 Get name of database.
std::string getParam (const char *pParam) const
 Get value of custom parameter.
int getParamCount () const
 Get number of parsed params.
std::string host () const
 Get hostname of rdbms.
std::string password () const
 Get password.
std::string port () const
 Get TCP/IP port.
std::string username () const
 Get username.

Detailed Description

Class for parsing parameters from connect string.

Connect string contains name=value pairs that describes how to connect to database.

Standard names:

  • user: name of user that connects to database
  • password: password for user that connects to database
  • dbname: database, dsn or database file name
  • host: IP or host name where to connect to
  • port: TCP port where to connect to
  • odbcparams: ODBC connection string

Spaces in names and values can be escaped using SQL syntax, for example:

dbname='C:\\Program Files\\myApp\\database.sqt3'
dbname=mydb pass=O''Connor

Driver notes

ODBC

ODBC drivers accepts following parameters:

  • odbcparams
  • dbname
  • unicode

Driver searches for dbname first and if found passes all its contents as DSN=<value> to SQLConnect. If not found, then driver searches for odbcparams and passes its contents to SQLConnect. If odbcparams is not found then driver passes full connect string to SQLConnect.

You can control how driver should send queries to database using unicode setting. Default behaviour is to try to convert queries to unicode and call SQLExecDirectW with unicode string. If conversion cannot be performed then query is passed unmodified to SQLExecDirect. Source encoding of query is determined from DbConnection::mConvSpecs::mDbCharset.

If unicode is set to 0, then driver does not try to convert query to unicode but passes it directly to SQLExecDirect. If unicode is set to 1, then driver tries to convert query to unicode and if failed then handleError with DBA_DB_ERROR code is called (in case when driver is used by SQLArchive this causes DatabaseException to be thrown).

If driver retrieve unicode data from database then it tries to convert it to encoding specified in DbResult::mConvSpecs::mDbCharset. If this is not set to dba::ConvSpec::UTF8 then and OS does not support requested conversion, then handleError with DBA_DB_ERROR code is called (in case when driver is used by SQLArchive this causes DatabaseException to be thrown).

If driver retrieve non-unicode data from database then it returns it to getString unmodified.

Examples of use:

dbname=mydsn
odbcparams="DSN=mydsn" unicode=0
FILEDSN=myfiledsn

PostgreSQL

PostgresSQL database driver accepts all parameters that libpq supports, because connect string is directly passed to driver PGConnect routine. Common parameters that you should use to connect to database:

  • dbname
  • password
  • user
  • host
  • port

See postgres documentation for meaning of those parameters.

Sqlite3

Sqlite3 driver accepts dbname parameter and treats it as full path to database file name. If "dbname" is not found then connect string contents is iterpreted as database file name.


Constructor & Destructor Documentation

ConnectString const char *  pStr  ) 
 

Constructor.

Parameters:
pStr connect string.

Member Function Documentation

std::string dbname  )  const
 

Get name of database.

Returns:
value of dbname keyword

std::string getParam const char *  pParam  )  const
 

Get value of custom parameter.

Parameters:
pParam parameter name
Returns:
parameter value or empty string if not found

std::string host  )  const
 

Get hostname of rdbms.

Returns:
value of dbname keyword

std::string password  )  const
 

Get password.

Returns:
value of pass keyword

std::string port  )  const
 

Get TCP/IP port.

Returns:
value of dbname keyword

std::string username  )  const
 

Get username.

Returns:
value of user keyword

The documentation for this class was generated from the following file:

Documentation
Quick start
Examples
Search

API Documentation
Class hierarchy
Member index
API Reference
Store filters
Store table macros
Back

Generated by doxygen at Sun Nov 9 02:08:17 2008