Qt 4.8
qsql_db2.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSql module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QSQL_DB2_H
43 #define QSQL_DB2_H
44 
45 #ifdef QT_PLUGIN
46 #define Q_EXPORT_SQLDRIVER_DB2
47 #else
48 #define Q_EXPORT_SQLDRIVER_DB2 Q_SQL_EXPORT
49 #endif
50 
51 #include <QtSql/qsqlresult.h>
52 #include <QtSql/qsqldriver.h>
53 
55 
57 class QDB2Driver;
58 class QDB2DriverPrivate;
59 class QDB2ResultPrivate;
60 class QSqlRecord;
61 
62 class QDB2Result : public QSqlResult
63 {
64 public:
65  QDB2Result(const QDB2Driver* dr, const QDB2DriverPrivate* dp);
66  ~QDB2Result();
67  bool prepare(const QString& query);
68  bool exec();
69  QVariant handle() const;
70 
71 protected:
72  QVariant data(int field);
73  bool reset (const QString& query);
74  bool fetch(int i);
75  bool fetchNext();
76  bool fetchFirst();
77  bool fetchLast();
78  bool isNull(int i);
79  int size();
80  int numRowsAffected();
81  QSqlRecord record() const;
82  void virtual_hook(int id, void *data);
83  bool nextResult();
84 
85 private:
87 };
88 
90 {
91  Q_OBJECT
92 public:
93  explicit QDB2Driver(QObject* parent = 0);
94  QDB2Driver(Qt::HANDLE env, Qt::HANDLE con, QObject* parent = 0);
95  ~QDB2Driver();
96  bool hasFeature(DriverFeature) const;
97  void close();
98  QSqlRecord record(const QString& tableName) const;
99  QStringList tables(QSql::TableType type) const;
100  QSqlResult *createResult() const;
101  QSqlIndex primaryIndex(const QString& tablename) const;
102  bool beginTransaction();
103  bool commitTransaction();
104  bool rollbackTransaction();
105  QString formatValue(const QSqlField &field, bool trimStrings) const;
106  QVariant handle() const;
107  bool open(const QString& db,
108  const QString& user,
109  const QString& password,
110  const QString& host,
111  int port,
112  const QString& connOpts);
113  QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
114 
115 private:
116  bool setAutoCommit(bool autoCommit);
118 };
119 
121 
123 
124 #endif // QSQL_DB2_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QSqlIndex class provides functions to manipulate and describe database indexes.
Definition: qsqlindex.h:55
QDB2ResultPrivate * d
Definition: qsql_db2.h:86
bool reset(const QString &query)
Sets the result to use the SQL statement query for subsequent data retrieval.
Definition: qsql_db2.cpp:537
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
DriverFeature
This enum contains a list of features a driver might support.
Definition: qsqldriver.h:75
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
QDB2DriverPrivate * d
Definition: qsql_db2.h:117
QDB2Result(const QDB2Driver *dr, const QDB2DriverPrivate *dp)
Definition: qsql_db2.cpp:520
bool fetchLast()
Positions the result to the last record (last row) in the result.
Definition: qsql_db2.cpp:920
int numRowsAffected()
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
Definition: qsql_db2.cpp:1067
int size()
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
Definition: qsql_db2.cpp:1078
The QSqlRecord class encapsulates a database record.
Definition: qsqlrecord.h:58
bool isNull(int i)
Returns true if the field at position index in the current row is null; otherwise returns false...
Definition: qsql_db2.cpp:1057
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
Definition: qsqldriver.h:68
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
Definition: qsql_db2.cpp:1083
#define Q_EXPORT_SQLDRIVER_DB2
Definition: qsql_db2.h:48
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QVariant data(int field)
Returns the data for field index in the current row as a QVariant.
Definition: qsql_db2.cpp:951
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool nextResult()
Definition: qsql_db2.cpp:1090
bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
Definition: qsql_db2.cpp:573
TableType
Definition: qsql.h:74
bool exec()
Executes the query, returning true if successful; otherwise returns false.
Definition: qsql_db2.cpp:597
void * HANDLE
Definition: qnamespace.h:1671
bool fetch(int i)
Positions the result to an arbitrary (zero-based) row index.
Definition: qsql_db2.cpp:848
#define Q_OBJECT
Definition: qobjectdefs.h:157
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
bool fetchNext()
Positions the result to the next available record (row) in the result.
Definition: qsql_db2.cpp:882
bool fetchFirst()
Positions the result to the first record (row 0) in the result.
Definition: qsql_db2.cpp:899
void virtual_hook(int id, void *data)
Definition: qsql_db2.cpp:1120
The QSqlField class manipulates the fields in SQL database tables and views.
Definition: qsqlfield.h:56
QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
Definition: qsql_db2.cpp:513
#define QT_END_HEADER
Definition: qglobal.h:137
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases...
Definition: qsqlresult.h:63
IdentifierType
This enum contains a list of SQL identifier types.
Definition: qsqldriver.h:83
int open(const char *, int,...)