|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the documentation of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 //! [0] |
|
43 -no-sql-<driver> ... Disable SQL <driver> entirely. |
|
44 -qt-sql-<driver> ... Enable a SQL <driver> in the Qt Library, by default |
|
45 none are turned on. |
|
46 -plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to |
|
47 at run time. |
|
48 |
|
49 Possible values for <driver>: |
|
50 [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ] |
|
51 //! [0] |
|
52 |
|
53 |
|
54 //! [1] |
|
55 create procedure qtestproc (OUT param1 INT, OUT param2 INT) |
|
56 BEGIN |
|
57 set param1 = 42; |
|
58 set param2 = 43; |
|
59 END |
|
60 //! [1] |
|
61 |
|
62 |
|
63 //! [2] |
|
64 QSqlQuery q; |
|
65 q.exec("call qtestproc (@outval1, @outval2)"); |
|
66 q.exec("select @outval1, @outval2"); |
|
67 q.next(); |
|
68 qDebug() << q.value(0) << q.value(1); // outputs "42" and "43" |
|
69 //! [2] |
|
70 |
|
71 |
|
72 //! [3] |
|
73 cd $QTDIR/src/plugins/sqldrivers/mysql |
|
74 qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro |
|
75 make |
|
76 //! [3] |
|
77 |
|
78 |
|
79 //! [4] |
|
80 cd $QTDIR/src/plugins/sqldrivers/mysql |
|
81 make install |
|
82 //! [4] |
|
83 |
|
84 |
|
85 //! [5] |
|
86 cd %QTDIR%\src\plugins\sqldrivers\mysql |
|
87 qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\MySQL Server <version>\lib\opt\libmysql.lib" mysql.pro |
|
88 nmake |
|
89 //! [5] |
|
90 |
|
91 |
|
92 //! [6] |
|
93 cd $QTDIR/src/plugins/sqldrivers/oci |
|
94 qmake "INCLUDEPATH+=$ORACLE_HOME/rdbms/public $ORACLE_HOME/rdbms/demo" "LIBS+=-L$ORACLE_HOME/lib -lclntsh -lwtc9" oci.pro |
|
95 make |
|
96 //! [6] |
|
97 |
|
98 |
|
99 //! [7] |
|
100 cd $QTDIR/src/plugins/sqldrivers/oci |
|
101 qmake "INCLUDEPATH+=/usr/include/oracle/10.1.0.3/client/" "LIBS+=-L/usr/lib/oracle/10.1.0.3/client/lib -lclntsh" oci.pro |
|
102 make |
|
103 //! [7] |
|
104 |
|
105 |
|
106 //! [8] |
|
107 set INCLUDE=%INCLUDE%;c:\oracle\oci\include |
|
108 set LIB=%LIB%;c:\oracle\oci\lib\msvc |
|
109 cd %QTDIR%\src\plugins\sqldrivers\oci |
|
110 qmake oci.pro |
|
111 nmake |
|
112 //! [8] |
|
113 |
|
114 |
|
115 //! [9] |
|
116 set PATH=%PATH%;c:\oracle\bin |
|
117 //! [9] |
|
118 |
|
119 |
|
120 //! [10] |
|
121 \\ STORED_PROC uses the return statement or returns multiple result sets |
|
122 QSqlQuery query; |
|
123 query.setForwardOnly(true); |
|
124 query.exec("{call STORED_PROC}"); |
|
125 //! [10] |
|
126 |
|
127 |
|
128 //! [11] |
|
129 cd $QTDIR/src/plugins/sqldrivers/odbc |
|
130 qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc" |
|
131 make |
|
132 //! [11] |
|
133 |
|
134 |
|
135 //! [12] |
|
136 cd %QTDIR%\src\plugins\sqldrivers\odbc |
|
137 qmake odbc.pro |
|
138 nmake |
|
139 //! [12] |
|
140 |
|
141 |
|
142 //! [13] |
|
143 cd $QTDIR/src/plugins/sqldrivers/psql |
|
144 qmake "INCLUDEPATH+=/usr/include/pgsql" "LIBS+=-L/usr/lib -lpq" psql.pro |
|
145 make |
|
146 //! [13] |
|
147 |
|
148 |
|
149 //! [14] |
|
150 cd $QTDIR/src/plugins/sqldrivers/psql |
|
151 make install |
|
152 //! [14] |
|
153 |
|
154 |
|
155 //! [15] |
|
156 cd %QTDIR%\src\plugins\sqldrivers\psql |
|
157 qmake "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro |
|
158 nmake |
|
159 //! [15] |
|
160 |
|
161 |
|
162 //! [16] |
|
163 cd $QTDIR/src/plugins/sqldrivers/tds |
|
164 qmake "INCLUDEPATH=$SYBASE/include" "LIBS=-L$SYBASE/lib -lsybdb" |
|
165 make |
|
166 //! [16] |
|
167 |
|
168 |
|
169 //! [17] |
|
170 cd %QTDIR%\src\plugins\sqldrivers\tds |
|
171 qmake "LIBS+=NTWDBLIB.LIB" tds.pro |
|
172 nmake |
|
173 //! [17] |
|
174 |
|
175 |
|
176 //! [18] |
|
177 cd $QTDIR/src/plugins/sqldrivers/db2 |
|
178 qmake "INCLUDEPATH+=$DB2DIR/include" "LIBS+=-L$DB2DIR/lib -ldb2" |
|
179 make |
|
180 //! [18] |
|
181 |
|
182 |
|
183 //! [19] |
|
184 cd $QTDIR/src/plugins/sqldrivers/db2 |
|
185 make install |
|
186 //! [19] |
|
187 |
|
188 |
|
189 //! [20] |
|
190 cd %QTDIR%\src\plugins\sqldrivers\db2 |
|
191 qmake "INCLUDEPATH+=<DB2 home>/sqllib/include" "LIBS+=<DB2 home>/sqllib/lib/db2cli.lib" |
|
192 nmake |
|
193 //! [20] |
|
194 |
|
195 |
|
196 //! [21] |
|
197 cd $QTDIR/src/plugins/sqldrivers/sqlite |
|
198 qmake "INCLUDEPATH+=$SQLITE/include" "LIBS+=-L$SQLITE/lib -lsqlite" |
|
199 make |
|
200 //! [21] |
|
201 |
|
202 |
|
203 //! [22] |
|
204 cd $QTDIR/src/plugins/sqldrivers/sqlite |
|
205 make install |
|
206 //! [22] |
|
207 |
|
208 |
|
209 //! [23] |
|
210 cd %QTDIR%\src\plugins\sqldrivers\sqlite |
|
211 qmake "INCLUDEPATH+=C:\SQLITE\INCLUDE" "LIBS+=C:\SQLITE\LIB\SQLITE3.LIB" sqlite.pro |
|
212 nmake |
|
213 //! [23] |
|
214 |
|
215 |
|
216 //! [24] |
|
217 db.setHostName("MyServer"); |
|
218 db.setDatabaseName("C:\\test.gdb"); |
|
219 //! [24] |
|
220 |
|
221 |
|
222 //! [25] |
|
223 // connect to database using the Latin-1 character set |
|
224 db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1"); |
|
225 db.open(); |
|
226 //! [25] |
|
227 |
|
228 |
|
229 //! [26] |
|
230 QSqlQuery q; |
|
231 q.exec("execute procedure my_procedure"); |
|
232 q.next(); |
|
233 qDebug() << q.value(0); // outputs the first RETURN/OUT value |
|
234 //! [26] |
|
235 |
|
236 |
|
237 //! [27] |
|
238 cd $QTDIR/src/plugins/sqldrivers/ibase |
|
239 qmake "INCLUDEPATH+=/opt/interbase/include" "LIBS+=-L/opt/interbase/lib" ibase.pro |
|
240 make |
|
241 //! [27] |
|
242 |
|
243 |
|
244 //! [28] |
|
245 cd $QTDIR/src/plugins/sqldrivers/ibase |
|
246 qmake "INCLUDEPATH+=/opt/interbase/include" "LIBS+=-L/opt/interbase/lib -lfbclient" ibase.pro |
|
247 make |
|
248 //! [28] |
|
249 |
|
250 |
|
251 //! [29] |
|
252 cd %QTDIR%\src\plugins\sqldrivers\ibase |
|
253 qmake "INCLUDEPATH+=C:\interbase\include" ibase.pro |
|
254 nmake |
|
255 //! [29] |
|
256 |
|
257 |
|
258 //! [30] |
|
259 cd %QTDIR%\src\plugins\sqldrivers\ibase |
|
260 qmake "INCLUDEPATH+=C:\interbase\include" "LIBS+=-lfbclient" ibase.pro |
|
261 nmake |
|
262 //! [30] |
|
263 |
|
264 |
|
265 //! [31] |
|
266 QSqlDatabase: QMYSQL driver not loaded |
|
267 QSqlDatabase: available drivers: QMYSQL |
|
268 //! [31] |
|
269 |
|
270 //! [32] |
|
271 configure -I /usr/include/oracle/10.1.0.3/client -L /usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10 |
|
272 make |
|
273 //! [32] |
|
274 |
|
275 //! [33] |
|
276 cd $QTDIR/src/plugins/sqldrivers/oci |
|
277 qmake "INCLUDEPATH+=/usr/include/oracle/10.1.0.3/client" "LIBS+=-L/usr/lib/oracle/10.1.0.3/client/lib -Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10" oci.pro |
|
278 make |
|
279 //! [33] |
|
280 |