Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QDB2Driver Class Reference

#include <qsql_db2.h>

Inheritance diagram for QDB2Driver:
QSqlDriver QObject

Public Functions

bool beginTransaction ()
 This function is called to begin a transaction. More...
 
void close ()
 Derived classes must reimplement this pure virtual function in order to close the database connection. More...
 
bool commitTransaction ()
 This function is called to commit a transaction. More...
 
QSqlResultcreateResult () const
 Creates an empty SQL result on the database. More...
 
QString escapeIdentifier (const QString &identifier, IdentifierType type) const
 Returns the identifier escaped according to the database rules. More...
 
QString formatValue (const QSqlField &field, bool trimStrings) const
 Returns a string representation of the field value for the database. More...
 
QVariant handle () const
 Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no handle. More...
 
bool hasFeature (DriverFeature) const
 Returns true if the driver supports feature feature; otherwise returns false. More...
 
bool open (const QString &db, const QString &user, const QString &password, const QString &host, int port, const QString &connOpts)
 Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options. More...
 
QSqlIndex primaryIndex (const QString &tablename) const
 Returns the primary index for table tableName. More...
 
 QDB2Driver (QObject *parent=0)
 
 QDB2Driver (Qt::HANDLE env, Qt::HANDLE con, QObject *parent=0)
 
QSqlRecord record (const QString &tableName) const
 Returns a QSqlRecord populated with the names of the fields in table tableName. More...
 
bool rollbackTransaction ()
 This function is called to rollback a transaction. More...
 
QStringList tables (QSql::TableType type) const
 Returns a list of the names of the tables in the database. More...
 
 ~QDB2Driver ()
 
- Public Functions inherited from QSqlDriver
bool isIdentifierEscaped (const QString &identifier, IdentifierType type) const
 Returns whether identifier is escaped according to the database rules. More...
 
virtual bool isOpen () const
 Returns true if the database connection is open; otherwise returns false. More...
 
bool isOpenError () const
 Returns true if the there was an error opening the database connection; otherwise returns false. More...
 
QSqlError lastError () const
 Returns a QSqlError object which contains information about the last error that occurred on the database. More...
 
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy () const
 Returns the current default precision policy for the database connection. More...
 
 QSqlDriver (QObject *parent=0)
 Constructs a new driver with the given parent. More...
 
void setNumericalPrecisionPolicy (QSql::NumericalPrecisionPolicy precisionPolicy)
 Sets the default numerical precision policy used by queries created by this driver to precisionPolicy. More...
 
virtual QString sqlStatement (StatementType type, const QString &tableName, const QSqlRecord &rec, bool preparedStatement) const
 Returns a SQL statement of type type for the table tableName with the values from rec. More...
 
QString stripDelimiters (const QString &identifier, IdentifierType type) const
 Returns the identifier with the leading and trailing delimiters removed, identifier can either be a table name or field name, dependent on type. More...
 
QStringList subscribedToNotifications () const
 Returns a list of the names of the event notifications that are currently subscribed to. More...
 
bool subscribeToNotification (const QString &name)
 This function is called to subscribe to event notifications from the database. More...
 
bool unsubscribeFromNotification (const QString &name)
 This function is called to unsubscribe from event notifications from the database. More...
 
 ~QSqlDriver ()
 Destroys the object and frees any allocated resources. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Functions

bool setAutoCommit (bool autoCommit)
 

Properties

QDB2DriverPrivated
 

Additional Inherited Members

- Public Types inherited from QSqlDriver
enum  DriverFeature {
  Transactions, QuerySize, BLOB, Unicode,
  PreparedQueries, NamedPlaceholders, PositionalPlaceholders, LastInsertId,
  BatchOperations, SimpleLocking, LowPrecisionNumbers, EventNotifications,
  FinishQuery, MultipleResultSets
}
 This enum contains a list of features a driver might support. More...
 
enum  IdentifierType { FieldName, TableName }
 This enum contains a list of SQL identifier types. More...
 
enum  StatementType {
  WhereStatement, SelectStatement, UpdateStatement, InsertStatement,
  DeleteStatement
}
 This enum contains a list of SQL statement (or clause) types the driver can create. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QSqlDriver
void notification (const QString &name)
 This signal is emitted when the database posts an event notification that the driver subscribes to. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QSqlDriver
bool isIdentifierEscapedImplementation (const QString &identifier, IdentifierType type) const
 This slot returns whether identifier is escaped according to the database rules. More...
 
QString stripDelimitersImplementation (const QString &identifier, IdentifierType type) const
 This slot returns identifier with the leading and trailing delimiters removed, identifier can either be a tablename or field name, dependent on type. More...
 
QStringList subscribedToNotificationsImplementation () const
 Returns a list of the names of the event notifications that are currently subscribed to. More...
 
bool subscribeToNotificationImplementation (const QString &name)
 This slot is called to subscribe to event notifications from the database. More...
 
bool unsubscribeFromNotificationImplementation (const QString &name)
 This slot is called to unsubscribe from event notifications from the database. More...
 
- Protected Functions inherited from QSqlDriver
virtual void setLastError (const QSqlError &e)
 This function is used to set the value of the last error, error, that occurred on the database. More...
 
virtual void setOpen (bool o)
 This function sets the open state of the database to open. More...
 
virtual void setOpenError (bool e)
 This function sets the open error state of the database to error. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 89 of file qsql_db2.h.

Constructors and Destructors

◆ QDB2Driver() [1/2]

QDB2Driver::QDB2Driver ( QObject parent = 0)
explicit

Definition at line 1138 of file qsql_db2.cpp.

1139  : QSqlDriver(parent)
1140 {
1141  d = new QDB2DriverPrivate;
1142 }
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
QSqlDriver(QObject *parent=0)
Constructs a new driver with the given parent.
Definition: qsqldriver.cpp:112

◆ QDB2Driver() [2/2]

QDB2Driver::QDB2Driver ( Qt::HANDLE  env,
Qt::HANDLE  con,
QObject parent = 0 
)

Definition at line 1144 of file qsql_db2.cpp.

1145  : QSqlDriver(parent)
1146 {
1147  d = new QDB2DriverPrivate;
1148  d->hEnv = (SQLHANDLE)env;
1149  d->hDbc = (SQLHANDLE)con;
1150  if (env && con) {
1151  setOpen(true);
1152  setOpenError(false);
1153  }
1154 }
virtual void setOpen(bool o)
This function sets the open state of the database to open.
Definition: qsqldriver.cpp:283
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
Definition: qsqldriver.cpp:297
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
QSqlDriver(QObject *parent=0)
Constructs a new driver with the given parent.
Definition: qsqldriver.cpp:112
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
SQLHANDLE hEnv
Definition: qsql_db2.cpp:77

◆ ~QDB2Driver()

QDB2Driver::~QDB2Driver ( )

Definition at line 1156 of file qsql_db2.cpp.

1157 {
1158  close();
1159  delete d;
1160 }
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
Definition: qsql_db2.cpp:1265

Functions

◆ beginTransaction()

bool QDB2Driver::beginTransaction ( )
virtual

This function is called to begin a transaction.

If successful, return true, otherwise return false. The default implementation does nothing and returns false.

See also
commitTransaction(), rollbackTransaction()

Reimplemented from QSqlDriver.

Definition at line 1532 of file qsql_db2.cpp.

1533 {
1534  if (!isOpen()) {
1535  qWarning("QDB2Driver::beginTransaction: Database not open");
1536  return false;
1537  }
1538  return setAutoCommit(false);
1539 }
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
bool setAutoCommit(bool autoCommit)
Definition: qsql_db2.cpp:1575
Q_CORE_EXPORT void qWarning(const char *,...)

◆ close()

void QDB2Driver::close ( )
virtual

Derived classes must reimplement this pure virtual function in order to close the database connection.

Return true on success, false on failure.

See also
open(), setOpen()

Implements QSqlDriver.

Definition at line 1265 of file qsql_db2.cpp.

Referenced by open(), and ~QDB2Driver().

1266 {
1267  SQLRETURN r;
1268  if (d->hDbc) {
1269  // Open statements/descriptors handles are automatically cleaned up by SQLDisconnect
1270  if (isOpen()) {
1271  r = SQLDisconnect(d->hDbc);
1272  if (r != SQL_SUCCESS)
1273  qSqlWarning(QLatin1String("QDB2Driver::close: Unable to disconnect datasource"), d);
1274  }
1275  r = SQLFreeHandle(SQL_HANDLE_DBC, d->hDbc);
1276  if (r != SQL_SUCCESS)
1277  qSqlWarning(QLatin1String("QDB2Driver::close: Unable to free connection handle"), d);
1278  d->hDbc = 0;
1279  }
1280 
1281  if (d->hEnv) {
1282  r = SQLFreeHandle(SQL_HANDLE_ENV, d->hEnv);
1283  if (r != SQL_SUCCESS)
1284  qSqlWarning(QLatin1String("QDB2Driver::close: Unable to free environment handle"), d);
1285  d->hEnv = 0;
1286  }
1287  setOpen(false);
1288  setOpenError(false);
1289 }
virtual void setOpen(bool o)
This function sets the open state of the database to open.
Definition: qsqldriver.cpp:283
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
Definition: qsqldriver.cpp:297
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:155
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
SQLHANDLE hEnv
Definition: qsql_db2.cpp:77

◆ commitTransaction()

bool QDB2Driver::commitTransaction ( )
virtual

This function is called to commit a transaction.

If successful, return true, otherwise return false. The default implementation does nothing and returns false.

See also
beginTransaction(), rollbackTransaction()

Reimplemented from QSqlDriver.

Definition at line 1541 of file qsql_db2.cpp.

1542 {
1543  if (!isOpen()) {
1544  qWarning("QDB2Driver::commitTransaction: Database not open");
1545  return false;
1546  }
1547  SQLRETURN r = SQLEndTran(SQL_HANDLE_DBC,
1548  d->hDbc,
1549  SQL_COMMIT);
1550  if (r != SQL_SUCCESS) {
1551  setLastError(qMakeError(tr("Unable to commit transaction"),
1553  return false;
1554  }
1555  return setAutoCommit(true);
1556 }
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
bool setAutoCommit(bool autoCommit)
Definition: qsql_db2.cpp:1575
Q_CORE_EXPORT void qWarning(const char *,...)
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
Definition: qsqldriver.cpp:350

◆ createResult()

QSqlResult * QDB2Driver::createResult ( ) const
virtual

Creates an empty SQL result on the database.

Derived classes must reimplement this function and return a QSqlResult object appropriate for their database to the caller.

Implements QSqlDriver.

Definition at line 1291 of file qsql_db2.cpp.

1292 {
1293  return new QDB2Result(this, d);
1294 }
QDB2DriverPrivate * d
Definition: qsql_db2.h:117

◆ escapeIdentifier()

QString QDB2Driver::escapeIdentifier ( const QString identifier,
IdentifierType  type 
) const
virtual

Returns the identifier escaped according to the database rules.

identifier can either be a table name or field name, dependent on type.

The default implementation does nothing.

See also
isIdentifierEscaped()

Reimplemented from QSqlDriver.

Definition at line 1638 of file qsql_db2.cpp.

1639 {
1640  QString res = identifier;
1641  if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) {
1642  res.replace(QLatin1Char('"'), QLatin1String("\"\""));
1643  res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
1644  res.replace(QLatin1Char('.'), QLatin1String("\".\""));
1645  }
1646  return res;
1647 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QString & prepend(QChar c)
Definition: qstring.h:261
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString & append(QChar c)
Definition: qstring.cpp:1777
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ formatValue()

QString QDB2Driver::formatValue ( const QSqlField field,
bool  trimStrings 
) const
virtual

Returns a string representation of the field value for the database.

Use the other formatValue() overload instead.

This is used, for example, when constructing INSERT and UPDATE statements.

The default implementation returns the value formatted as a string according to the following rules:

  • If field is character data, the value is returned enclosed in single quotation marks, which is appropriate for many SQL databases. Any embedded single-quote characters are escaped (replaced with two single-quote characters). If trimStrings is true (the default is false), all trailing whitespace is trimmed from the field.

  • If field is date/time data, the value is formatted in ISO format and enclosed in single quotation marks. If the date/time data is invalid, "NULL" is returned.

  • If field is bytearray data, and the driver can edit binary fields, the value is formatted as a hexadecimal string.

  • For any other field type, toString() is called on its value and the result of this is returned.

See also
QVariant::toString()

Reimplemented from QSqlDriver.

Definition at line 1590 of file qsql_db2.cpp.

1591 {
1592  if (field.isNull())
1593  return QLatin1String("NULL");
1594 
1595  switch (field.type()) {
1596  case QVariant::DateTime: {
1597  // Use an escape sequence for the datetime fields
1598  if (field.value().toDateTime().isValid()) {
1599  QDate dt = field.value().toDateTime().date();
1600  QTime tm = field.value().toDateTime().time();
1601  // Dateformat has to be "yyyy-MM-dd hh:mm:ss", with leading zeroes if month or day < 10
1602  return QLatin1Char('\'') + QString::number(dt.year()) + QLatin1Char('-')
1603  + QString::number(dt.month()) + QLatin1Char('-')
1604  + QString::number(dt.day()) + QLatin1Char('-')
1605  + QString::number(tm.hour()) + QLatin1Char('.')
1606  + QString::number(tm.minute()).rightJustified(2, QLatin1Char('0'), true)
1607  + QLatin1Char('.')
1608  + QString::number(tm.second()).rightJustified(2, QLatin1Char('0'), true)
1609  + QLatin1Char('.')
1610  + QString::number(tm.msec() * 1000).rightJustified(6, QLatin1Char('0'), true)
1611  + QLatin1Char('\'');
1612  } else {
1613  return QLatin1String("NULL");
1614  }
1615  }
1616  case QVariant::ByteArray: {
1617  QByteArray ba = field.value().toByteArray();
1618  QString res = QString::fromLatin1("BLOB(X'");
1619  static const char hexchars[] = "0123456789abcdef";
1620  for (int i = 0; i < ba.size(); ++i) {
1621  uchar s = (uchar) ba[i];
1622  res += QLatin1Char(hexchars[s >> 4]);
1623  res += QLatin1Char(hexchars[s & 0x0f]);
1624  }
1625  res += QLatin1String("')");
1626  return res;
1627  }
1628  default:
1629  return QSqlDriver::formatValue(field, trimStrings);
1630  }
1631 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
QVariant value() const
Returns the value of the field as a QVariant.
Definition: qsqlfield.h:71
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int month() const
Returns the number corresponding to the month of this date, using the following convention: ...
Definition: qdatetime.cpp:382
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
Definition: qvariant.cpp:2349
int day() const
Returns the day of the month (1 to 31) of this date.
Definition: qdatetime.cpp:395
bool isValid() const
Returns true if both the date and the time are valid; otherwise returns false.
Definition: qdatetime.cpp:2346
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int msec() const
Returns the millisecond part (0 to 999) of the time.
Definition: qdatetime.cpp:1611
The QString class provides a Unicode character string.
Definition: qstring.h:83
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
unsigned char uchar
Definition: qglobal.h:994
The QTime class provides clock time functions.
Definition: qdatetime.h:148
int second() const
Returns the second part (0 to 59) of the time.
Definition: qdatetime.cpp:1600
int minute() const
Returns the minute part (0 to 59) of the time.
Definition: qdatetime.cpp:1589
QVariant::Type type() const
Returns the field&#39;s type as stored in the database.
Definition: qsqlfield.cpp:394
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
bool isNull() const
Returns true if the field&#39;s value is NULL; otherwise returns false.
Definition: qsqlfield.cpp:428
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
Definition: qsqldriver.cpp:597
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
int year() const
Returns the year of this date.
Definition: qdatetime.cpp:353
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
int hour() const
Returns the hour part (0 to 23) of the time.
Definition: qdatetime.cpp:1578

◆ handle()

QVariant QDB2Driver::handle ( ) const
virtual

Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no handle.

Warning
Use this with uttermost care and only if you know what you're doing.
The handle returned here can become a stale pointer if the connection is modified (for example, if you close the connection).
The handle can be NULL if the connection is not open yet.

The handle returned here is database-dependent, you should query the type name of the variant before accessing it.

This example retrieves the handle for a connection to sqlite:

QSqlDatabase db = ...;
QVariant v = db.driver()->handle();
if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*") == 0) {
// v.data() returns a pointer to the handle
sqlite3 *handle = *static_cast<sqlite3 **>(v.data());
if (handle != 0) { // check that it is not NULL
...
}
}

This snippet returns the handle for PostgreSQL or MySQL:

if (qstrcmp(v.typeName(), "PGconn*") == 0) {
PGconn *handle = *static_cast<PGconn **>(v.data());
if (handle != 0) ...
}
if (qstrcmp(v.typeName(), "MYSQL*") == 0) {
MYSQL *handle = *static_cast<MYSQL **>(v.data());
if (handle != 0) ...
}
See also
QSqlResult::handle()

Reimplemented from QSqlDriver.

Definition at line 1633 of file qsql_db2.cpp.

1634 {
1635  return QVariant(qRegisterMetaType<SQLHANDLE>("SQLHANDLE"), &d->hDbc);
1636 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78

◆ hasFeature()

bool QDB2Driver::hasFeature ( DriverFeature  feature) const
virtual

Returns true if the driver supports feature feature; otherwise returns false.

Note that some databases need to be open() before this can be determined.

See also
DriverFeature

Implements QSqlDriver.

Definition at line 1508 of file qsql_db2.cpp.

◆ open()

bool QDB2Driver::open ( const QString db,
const QString user,
const QString password,
const QString host,
int  port,
const QString options 
)
virtual

Derived classes must reimplement this pure virtual function to open a database connection on database db, using user name user, password password, host host, port port and connection options options.

The function must return true on success and false on failure.

See also
setOpen()

Implements QSqlDriver.

Definition at line 1162 of file qsql_db2.cpp.

1164 {
1165  if (isOpen())
1166  close();
1167  SQLRETURN r;
1168  r = SQLAllocHandle(SQL_HANDLE_ENV,
1169  SQL_NULL_HANDLE,
1170  &d->hEnv);
1171  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1172  qSqlWarning(QLatin1String("QDB2Driver::open: Unable to allocate environment"), d);
1173  setOpenError(true);
1174  return false;
1175  }
1176 
1177  r = SQLAllocHandle(SQL_HANDLE_DBC,
1178  d->hEnv,
1179  &d->hDbc);
1180  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1181  qSqlWarning(QLatin1String("QDB2Driver::open: Unable to allocate connection"), d);
1182  setOpenError(true);
1183  return false;
1184  }
1185 
1186  QString protocol;
1187  // Set connection attributes
1188  const QStringList opts(connOpts.split(QLatin1Char(';'), QString::SkipEmptyParts));
1189  for (int i = 0; i < opts.count(); ++i) {
1190  const QString tmp(opts.at(i));
1191  int idx;
1192  if ((idx = tmp.indexOf(QLatin1Char('='))) == -1) {
1193  qWarning("QDB2Driver::open: Illegal connect option value '%s'",
1194  tmp.toLocal8Bit().constData());
1195  continue;
1196  }
1197 
1198  const QString opt(tmp.left(idx));
1199  const QString val(tmp.mid(idx + 1).simplified());
1200 
1201  SQLUINTEGER v = 0;
1202  r = SQL_SUCCESS;
1203  if (opt == QLatin1String("SQL_ATTR_ACCESS_MODE")) {
1204  if (val == QLatin1String("SQL_MODE_READ_ONLY")) {
1205  v = SQL_MODE_READ_ONLY;
1206  } else if (val == QLatin1String("SQL_MODE_READ_WRITE")) {
1207  v = SQL_MODE_READ_WRITE;
1208  } else {
1209  qWarning("QDB2Driver::open: Unknown option value '%s'",
1210  tmp.toLocal8Bit().constData());
1211  continue;
1212  }
1213  r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_ACCESS_MODE, (SQLPOINTER) v, 0);
1214  } else if (opt == QLatin1String("SQL_ATTR_LOGIN_TIMEOUT")) {
1215  v = val.toUInt();
1216  r = SQLSetConnectAttr(d->hDbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) v, 0);
1217  } else if (opt.compare(QLatin1String("PROTOCOL"), Qt::CaseInsensitive) == 0) {
1218  protocol = tmp;
1219  }
1220  else {
1221  qWarning("QDB2Driver::open: Unknown connection attribute '%s'",
1222  tmp.toLocal8Bit().constData());
1223  }
1224  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
1225  qSqlWarning(QString::fromLatin1("QDB2Driver::open: "
1226  "Unable to set connection attribute '%1'").arg(opt), d);
1227  }
1228 
1229  if (protocol.isEmpty())
1230  protocol = QLatin1String("PROTOCOL=TCPIP");
1231 
1232  if (port < 0 )
1233  port = 50000;
1234 
1235  QString connQStr;
1236  connQStr = protocol + QLatin1String(";DATABASE=") + db + QLatin1String(";HOSTNAME=") + host
1237  + QLatin1String(";PORT=") + QString::number(port) + QLatin1String(";UID=") + user
1238  + QLatin1String(";PWD=") + password;
1239 
1240 
1241  SQLTCHAR connOut[SQL_MAX_OPTION_STRING_LENGTH];
1242  SQLSMALLINT cb;
1243 
1244  r = SQLDriverConnect(d->hDbc,
1245  NULL,
1246  qToTChar(connQStr),
1247  (SQLSMALLINT) connQStr.length(),
1248  connOut,
1249  SQL_MAX_OPTION_STRING_LENGTH,
1250  &cb,
1251  SQL_DRIVER_NOPROMPT);
1252  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1253  setLastError(qMakeError(tr("Unable to connect"),
1255  setOpenError(true);
1256  return false;
1257  }
1258 
1259  d->user = user;
1260  setOpen(true);
1261  setOpenError(false);
1262  return true;
1263 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
virtual void setOpen(bool o)
This function sets the open state of the database to open.
Definition: qsqldriver.cpp:283
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
Definition: qsqldriver.cpp:297
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QString class provides a Unicode character string.
Definition: qstring.h:83
static SQLTCHAR * qToTChar(const QString &str)
Definition: qsql_db2.cpp:117
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:155
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void close()
Derived classes must reimplement this pure virtual function in order to close the database connection...
Definition: qsql_db2.cpp:1265
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
Definition: qsqldriver.cpp:350
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
SQLHANDLE hEnv
Definition: qsql_db2.cpp:77

◆ primaryIndex()

QSqlIndex QDB2Driver::primaryIndex ( const QString tableName) const
virtual

Returns the primary index for table tableName.

Returns an empty QSqlIndex if the table doesn't have a primary index. The default implementation returns an empty index.

Reimplemented from QSqlDriver.

Definition at line 1440 of file qsql_db2.cpp.

1441 {
1442  QSqlIndex index(tablename);
1443  if (!isOpen())
1444  return index;
1445  QSqlRecord rec = record(tablename);
1446 
1447  SQLHANDLE hStmt;
1448  SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
1449  d->hDbc,
1450  &hStmt);
1451  if (r != SQL_SUCCESS) {
1452  qSqlWarning(QLatin1String("QDB2Driver::primaryIndex: Unable to list primary key"), d);
1453  return index;
1454  }
1455  QString catalog, schema, table;
1456  qSplitTableQualifier(tablename, &catalog, &schema, &table);
1457 
1459  catalog = stripDelimiters(catalog, QSqlDriver::TableName);
1460  else
1461  catalog = catalog.toUpper();
1462 
1464  schema = stripDelimiters(schema, QSqlDriver::TableName);
1465  else
1466  schema = schema.toUpper();
1467 
1469  table = stripDelimiters(table, QSqlDriver::TableName);
1470  else
1471  table = table.toUpper();
1472 
1473  r = SQLSetStmtAttr(hStmt,
1474  SQL_ATTR_CURSOR_TYPE,
1475  (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
1476  SQL_IS_UINTEGER);
1477 
1478  r = SQLPrimaryKeys(hStmt,
1479  NULL,
1480  0,
1481  qToTChar(schema),
1482  schema.length(),
1483  qToTChar(table),
1484  table.length());
1485  r = SQLFetchScroll(hStmt,
1486  SQL_FETCH_NEXT,
1487  0);
1488 
1489  bool isNull;
1490  QString cName, idxName;
1491  // Store all fields in a StringList because the driver can't detail fields in this FETCH loop
1492  while (r == SQL_SUCCESS) {
1493  cName = qGetStringData(hStmt, 3, -1, isNull); // column name
1494  idxName = qGetStringData(hStmt, 5, -1, isNull); // pk index name
1495  index.append(rec.field(cName));
1496  index.setName(idxName);
1497  r = SQLFetchScroll(hStmt,
1498  SQL_FETCH_NEXT,
1499  0);
1500  }
1501  r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1502  if (r!= SQL_SUCCESS)
1503  qSqlWarning(QLatin1String("QDB2Driver: Unable to free statement handle ")
1504  + QString::number(r), d);
1505  return index;
1506 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
The QSqlIndex class provides functions to manipulate and describe database indexes.
Definition: qsqlindex.h:55
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
The QString class provides a Unicode character string.
Definition: qstring.h:83
static SQLTCHAR * qToTChar(const QString &str)
Definition: qsql_db2.cpp:117
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
Definition: qsqldriver.cpp:429
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:155
QSqlField field(int i) const
Returns the field at position index.
Definition: qsqlrecord.cpp:289
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool &isNull)
Definition: qsql_db2.cpp:324
quint16 index
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
Definition: qsqldriver.cpp:455
QSqlRecord record(const QString &tableName) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
Definition: qsql_db2.cpp:1296
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
static void qSplitTableQualifier(const QString &qualifier, QString *catalog, QString *schema, QString *table)
Definition: qsql_db2.cpp:420

◆ record()

QSqlRecord QDB2Driver::record ( const QString tableName) const
virtual

Returns a QSqlRecord populated with the names of the fields in table tableName.

Use query.

If no such table exists, an empty record is returned. The default implementation returns an empty record.

record() instead.

Reimplemented from QSqlDriver.

Definition at line 1296 of file qsql_db2.cpp.

Referenced by primaryIndex().

1297 {
1298  QSqlRecord fil;
1299  if (!isOpen())
1300  return fil;
1301 
1302  SQLHANDLE hStmt;
1303  QString catalog, schema, table;
1304  qSplitTableQualifier(tableName, &catalog, &schema, &table);
1305  if (schema.isEmpty())
1306  schema = d->user;
1307 
1309  catalog = stripDelimiters(catalog, QSqlDriver::TableName);
1310  else
1311  catalog = catalog.toUpper();
1312 
1314  schema = stripDelimiters(schema, QSqlDriver::TableName);
1315  else
1316  schema = schema.toUpper();
1317 
1319  table = stripDelimiters(table, QSqlDriver::TableName);
1320  else
1321  table = table.toUpper();
1322 
1323  SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
1324  d->hDbc,
1325  &hStmt);
1326  if (r != SQL_SUCCESS) {
1327  qSqlWarning(QLatin1String("QDB2Driver::record: Unable to allocate handle"), d);
1328  return fil;
1329  }
1330 
1331  r = SQLSetStmtAttr(hStmt,
1332  SQL_ATTR_CURSOR_TYPE,
1333  (SQLPOINTER) SQL_CURSOR_FORWARD_ONLY,
1334  SQL_IS_UINTEGER);
1335 
1336 
1337  //Aside: szSchemaName and szTableName parameters of SQLColumns
1338  //are case sensitive search patterns, so no escaping is used.
1339  r = SQLColumns(hStmt,
1340  NULL,
1341  0,
1342  qToTChar(schema),
1343  schema.length(),
1344  qToTChar(table),
1345  table.length(),
1346  NULL,
1347  0);
1348 
1349  if (r != SQL_SUCCESS)
1350  qSqlWarning(QLatin1String("QDB2Driver::record: Unable to execute column list"), d);
1351  r = SQLFetchScroll(hStmt,
1352  SQL_FETCH_NEXT,
1353  0);
1354  while (r == SQL_SUCCESS) {
1355  fil.append(qMakeFieldInfo(hStmt));
1356  r = SQLFetchScroll(hStmt,
1357  SQL_FETCH_NEXT,
1358  0);
1359  }
1360 
1361  r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1362  if (r != SQL_SUCCESS)
1363  qSqlWarning(QLatin1String("QDB2Driver: Unable to free statement handle ")
1364  + QString::number(r), d);
1365 
1366  return fil;
1367 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
The QString class provides a Unicode character string.
Definition: qstring.h:83
static SQLTCHAR * qToTChar(const QString &str)
Definition: qsql_db2.cpp:117
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
Definition: qsqldriver.cpp:429
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:155
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate *d, int i)
Definition: qsql_db2.cpp:234
if(void) toggleToolbarShown
void append(const QSqlField &field)
Append a copy of field field to the end of the record.
Definition: qsqlrecord.cpp:312
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
Definition: qsqldriver.cpp:455
static void qSplitTableQualifier(const QString &qualifier, QString *catalog, QString *schema, QString *table)
Definition: qsql_db2.cpp:420

◆ rollbackTransaction()

bool QDB2Driver::rollbackTransaction ( )
virtual

This function is called to rollback a transaction.

If successful, return true, otherwise return false. The default implementation does nothing and returns false.

See also
beginTransaction(), commitTransaction()

Reimplemented from QSqlDriver.

Definition at line 1558 of file qsql_db2.cpp.

1559 {
1560  if (!isOpen()) {
1561  qWarning("QDB2Driver::rollbackTransaction: Database not open");
1562  return false;
1563  }
1564  SQLRETURN r = SQLEndTran(SQL_HANDLE_DBC,
1565  d->hDbc,
1566  SQL_ROLLBACK);
1567  if (r != SQL_SUCCESS) {
1568  setLastError(qMakeError(tr("Unable to rollback transaction"),
1570  return false;
1571  }
1572  return setAutoCommit(true);
1573 }
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
bool setAutoCommit(bool autoCommit)
Definition: qsql_db2.cpp:1575
Q_CORE_EXPORT void qWarning(const char *,...)
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
Definition: qsqldriver.cpp:350

◆ setAutoCommit()

bool QDB2Driver::setAutoCommit ( bool  autoCommit)
private

Definition at line 1575 of file qsql_db2.cpp.

Referenced by beginTransaction(), commitTransaction(), and rollbackTransaction().

1576 {
1577  SQLUINTEGER ac = autoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF;
1578  SQLRETURN r = SQLSetConnectAttr(d->hDbc,
1579  SQL_ATTR_AUTOCOMMIT,
1580  (SQLPOINTER)ac,
1581  sizeof(ac));
1582  if (r != SQL_SUCCESS) {
1583  setLastError(qMakeError(tr("Unable to set autocommit"),
1585  return false;
1586  }
1587  return true;
1588 }
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const QDB2DriverPrivate *p)
Definition: qsql_db2.cpp:167
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database...
Definition: qsqldriver.cpp:350

◆ tables()

QStringList QDB2Driver::tables ( QSql::TableType  tableType) const
virtual

Returns a list of the names of the tables in the database.

The default implementation returns an empty list.

The tableType argument describes what types of tables should be returned. Due to binary compatibility, the string contains the value of the enum QSql::TableTypes as text. An empty string should be treated as QSql::Tables for backward compatibility.

Reimplemented from QSqlDriver.

Definition at line 1369 of file qsql_db2.cpp.

1370 {
1371  QStringList tl;
1372  if (!isOpen())
1373  return tl;
1374 
1375  SQLHANDLE hStmt;
1376 
1377  SQLRETURN r = SQLAllocHandle(SQL_HANDLE_STMT,
1378  d->hDbc,
1379  &hStmt);
1380  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
1381  qSqlWarning(QLatin1String("QDB2Driver::tables: Unable to allocate handle"), d);
1382  return tl;
1383  }
1384  r = SQLSetStmtAttr(hStmt,
1385  SQL_ATTR_CURSOR_TYPE,
1386  (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY,
1387  SQL_IS_UINTEGER);
1388 
1389  QString tableType;
1390  if (type & QSql::Tables)
1391  tableType += QLatin1String("TABLE,");
1392  if (type & QSql::Views)
1393  tableType += QLatin1String("VIEW,");
1394  if (type & QSql::SystemTables)
1395  tableType += QLatin1String("SYSTEM TABLE,");
1396  if (tableType.isEmpty())
1397  return tl;
1398  tableType.chop(1);
1399 
1400  r = SQLTables(hStmt,
1401  NULL,
1402  0,
1403  NULL,
1404  0,
1405  NULL,
1406  0,
1407  qToTChar(tableType),
1408  tableType.length());
1409 
1410  if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO)
1411  qSqlWarning(QLatin1String("QDB2Driver::tables: Unable to execute table list"), d);
1412  r = SQLFetchScroll(hStmt,
1413  SQL_FETCH_NEXT,
1414  0);
1415  while (r == SQL_SUCCESS) {
1416  bool isNull;
1417  QString fieldVal = qGetStringData(hStmt, 2, -1, isNull);
1418  QString userVal = qGetStringData(hStmt, 1, -1, isNull);
1419  QString user = d->user;
1421  user = stripDelimiters(user, QSqlDriver::TableName);
1422  else
1423  user = user.toUpper();
1424 
1425  if (userVal != user)
1426  fieldVal = userVal + QLatin1Char('.') + fieldVal;
1427  tl.append(fieldVal);
1428  r = SQLFetchScroll(hStmt,
1429  SQL_FETCH_NEXT,
1430  0);
1431  }
1432 
1433  r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
1434  if (r != SQL_SUCCESS)
1435  qSqlWarning(QLatin1String("QDB2Driver::tables: Unable to free statement handle ")
1436  + QString::number(r), d);
1437  return tl;
1438 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
int type
Definition: qmetatype.cpp:239
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString toUpper() const Q_REQUIRED_RESULT
Returns an uppercase copy of the string.
Definition: qstring.cpp:5483
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
Definition: qsqldriver.cpp:182
The QString class provides a Unicode character string.
Definition: qstring.h:83
static SQLTCHAR * qToTChar(const QString &str)
Definition: qsql_db2.cpp:117
bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
Definition: qsqldriver.cpp:429
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static void qSqlWarning(const QString &message, const QDB2DriverPrivate *d)
Definition: qsql_db2.cpp:155
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool &isNull)
Definition: qsql_db2.cpp:324
SQLHANDLE hDbc
Definition: qsql_db2.cpp:78
QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
Definition: qsqldriver.cpp:455
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300

Properties

◆ d

QDB2DriverPrivate* QDB2Driver::d
private

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