class toConnection

Represent a database connection in TOra. More...

Definition#include <toconnection.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Members


Detailed Description

Represent a database connection in TOra. Observe that this can mean several actual connections to the database as queries that ae expected to run a long time are sometimes executed in their own connection to make sure the interface doesn't lock up for a long time.

exception (class)

exception

Class that could be used to throw exceptions in connection errors. Must use if you want to indicate error offset.

objectName (struct)

objectName

Contain information about a tablename.

connectionImpl (class)

connectionImpl

This class is an abstract baseclass to actually implement the comunication with the database. (See also toQuery::queryImpl and toConnectionProvider)

 toConnection (const QCString &provider,const QString &user,const QString &password, const QString &host,const QString &database,const QString &mode=QString::null, bool cache=true)

toConnection

Create a new connection.

Parameters:
providerWhich database provider to use for this connection. (See to toDatabaseConnection)
userUser to connect to the database with.
passwordPassword to connect with.
hostHost to connect to the database with.
databaseDatabase to connect to.
modeMode to connect to the database with.
cacheEnable object cache for this connection.

 toConnection (const toConnection &conn)

toConnection

Create a copy of a connection. Will not cache objects, so objects will never be available in a subconnection.

Parameters:
connConnection to copy.

 ~toConnection ()

~toConnection

[virtual]

Destroy connection.

bool  closeWidgets (void)

closeWidgets

Try to close all the widgets associated with this connection.

Returns: True if all widgets agreed to close.

const QStringuser ()

user

[const]

Get username of connection.

const QStringpassword ()

password

[const]

Get password of connection.

void  setPassword (const QString &pwd)

setPassword

Change password of connection.

const QStringhost ()

host

[const]

Get host of connection.

const QStringdatabase ()

database

[const]

Get database of connection.

const QStringmode ()

mode

[const]

Get mode of connection.

const QCStringversion ()

version

[const]

Get version of connection.

const QCStringprovider ()

provider

[const]

Get provider of connection.

QString  description (bool version=true)

description

[const virtual]

Get a description of this connection.

void  setNeedCommit (bool needCommit=true)

setNeedCommit

Set if this connection needs to be commited.

bool  needCommit (void)

needCommit

[const]

Get information about if the connection has uncommited data.

Returns: Whether uncommited data is available.

void  commit (void)

commit

[virtual]

Commit connection. This will also close all extra connections except one.

void  rollback (void)

rollback

[virtual]

Rollback connection. This will also close all extra connections except one.

void  parse (const QString &sql)

parse

Parse a query on an actual connection and report any syntax problems encountered. Defaults to not implemented.

Parameters:
connConnection to execute on.
sqlSQL to parse

void  parse (const toSQL &sql)

parse

Parse a query on an actual connection and report any syntax problems encountered. Defaults to not implemented.

Parameters:
connConnection to execute on.
sqlSQL to parse

void  execute (const toSQL &sql, toQList &params)

execute

Execute a statement without caring about the result.

Parameters:
sqlSQL to execute
paramsParameters to pass to query.

void  execute (const QString &sql, toQList &params)

execute

Execute a statement without caring about the result.

Parameters:
sqlSQL to execute
paramsParameters to pass to query.

void  execute (const toSQL &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

execute

Execute a statement without caring about the result.

Parameters:
sqlSQL to execute
arg1Parameters to pass to query.

void  execute (const QString &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

execute

Execute a statement without caring about the result.

Parameters:
sqlSQL to execute
arg1Parameters to pass to query.

void  allExecute (const toSQL &sql, toQList &params)

allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:
sqlSQL to execute
paramsParameters to pass to query.

void  allExecute (const QString &sql, toQList &params)

allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:
sqlSQL to execute
paramsParameters to pass to query.

void  allExecute (const toSQL &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:
sqlSQL to execute
arg1Parameters to pass to query.

void  allExecute (const QString &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:
sqlSQL to execute
arg1Parameters to pass to query.

void  addWidget (QObject *widget)

addWidget

Add a object that uses this connection. This is needed to ensure that all widgets that make use of a connection are destroyed when the connection is closed. Usually tool windows need to call this function.

Parameters:
widgetThe widget to add to the connection.

void  delWidget (QObject *widget)

delWidget

Remove a widget from this connection. Should be called by the destructor of the widget that has called addWidget.

Parameters:
widgetWidget to remove from the widget list.

See also: addWidget

void  addInit (const QString &sql)

addInit

Add a statement to be run uppon making new connections.

Parameters:
sqlStatement to run.

void  delInit (const QString &sql)

delInit

Remove a statement that was added using addInit.

QString  quote (const QString &name)

quote

Return a string representation to address an object.

Parameters:
nameThe name to be quoted.

Returns: String addressing table.

QString  unQuote (const QString &name)

unQuote

Perform the opposite of quote.

Parameters:
nameThe name to be un-quoted.

Returns: String addressing table.

std::list<objectName> & objects (bool block)

objects

Get the objects available for the current user. Do not modify the returned list.

Parameters:
blockIndicate wether or not to block until cached objects are available.

Returns: A list of object available for the current user. The list is sorted in owner and name order.

void  addIfNotExists (objectName &object)

addIfNotExists

Add a new object to the objectlist if it doesn't exist already.

Parameters:
objectThe object to add

std::map<QString,objectName> & synonyms (bool block)

synonyms

Get the synonyms available for objects. Do not modify the returned list.

Parameters:
blockIndicate wether or not to block until cached objects are available.

Returns: A list of synonyms to objects available for the current user.

toQDescListcolumns (const objectName &table,bool nocache=false)

columns

Get a list of the available columns for a table. This function caches the responses and should be fairly fast after the first call. Do not modify the returned list.

Parameters:
tableThe table to describe.
nocacheDon't use cached values even if they are available.

Returns: A list of the columns for a table.

void  rereadCache (void)

rereadCache

Reread the object and column cache.

const objectName & realName (const QString &object,bool block)

realName

Get the real object name of an object.

Parameters:
objectObject name
blockBlock if not done caching object.

const objectName & realName (const QString &object,QString &synonym,bool block)

realName

Get the real object name of a synonym.

Parameters:
objectObject name
synonymFilled with the synonym used to access the object returned or empty.
blockBlock if not done caching object.

bool  cacheAvailable (bool synonyms,bool block=false,bool need=true)

cacheAvailable

Check if cache is available or not.

Parameters:
synonymsIf synonyms are needed or not.
blockBlock until cache is done.
trueTrue if you need the cache, or just checking.

Returns: True if cache is available.

void  cancelAll (void)

cancelAll

Try to stop all running queries.

bool  loadDiskCache (void)

loadDiskCache

load disk cache

void  writeDiskCache (void)

writeDiskCache

write disk cache

std::list<QString>  running (void)

running

Get a list of currently running SQL.

void  logMessage (QString text)

logMessage

friend class toQuery

toQuery