Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "ORealDriver.hxx"
21 : #include "odbc/ODriver.hxx"
22 : #include "odbc/OTools.hxx"
23 : #include "odbc/OFunctions.hxx"
24 : #include "diagnose_ex.h"
25 :
26 : namespace connectivity
27 : {
28 : // extern declaration of the function pointer
29 : extern T3SQLAllocHandle pODBC3SQLAllocHandle;
30 : extern T3SQLConnect pODBC3SQLConnect;
31 : extern T3SQLDriverConnect pODBC3SQLDriverConnect;
32 : extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
33 : extern T3SQLDataSources pODBC3SQLDataSources;
34 : extern T3SQLDrivers pODBC3SQLDrivers;
35 : extern T3SQLGetInfo pODBC3SQLGetInfo;
36 : extern T3SQLGetFunctions pODBC3SQLGetFunctions;
37 : extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
38 : extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
39 : extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
40 : extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
41 : extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
42 : extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
43 : extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
44 : //extern T3SQLSetDescField pODBC3SQLSetDescField;
45 : //extern T3SQLGetDescField pODBC3SQLGetDescField;
46 : //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
47 : //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
48 : extern T3SQLPrepare pODBC3SQLPrepare;
49 : extern T3SQLBindParameter pODBC3SQLBindParameter;
50 : //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
51 : extern T3SQLSetCursorName pODBC3SQLSetCursorName;
52 : extern T3SQLExecute pODBC3SQLExecute;
53 : extern T3SQLExecDirect pODBC3SQLExecDirect;
54 : //extern T3SQLNativeSql pODBC3SQLNativeSql;
55 : extern T3SQLDescribeParam pODBC3SQLDescribeParam;
56 : extern T3SQLNumParams pODBC3SQLNumParams;
57 : extern T3SQLParamData pODBC3SQLParamData;
58 : extern T3SQLPutData pODBC3SQLPutData;
59 : extern T3SQLRowCount pODBC3SQLRowCount;
60 : extern T3SQLNumResultCols pODBC3SQLNumResultCols;
61 : extern T3SQLDescribeCol pODBC3SQLDescribeCol;
62 : extern T3SQLColAttribute pODBC3SQLColAttribute;
63 : extern T3SQLBindCol pODBC3SQLBindCol;
64 : extern T3SQLFetch pODBC3SQLFetch;
65 : extern T3SQLFetchScroll pODBC3SQLFetchScroll;
66 : extern T3SQLGetData pODBC3SQLGetData;
67 : extern T3SQLSetPos pODBC3SQLSetPos;
68 : extern T3SQLBulkOperations pODBC3SQLBulkOperations;
69 : extern T3SQLMoreResults pODBC3SQLMoreResults;
70 : //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
71 : extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
72 : extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
73 : extern T3SQLColumns pODBC3SQLColumns;
74 : extern T3SQLForeignKeys pODBC3SQLForeignKeys;
75 : extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
76 : extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
77 : extern T3SQLProcedures pODBC3SQLProcedures;
78 : extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
79 : extern T3SQLStatistics pODBC3SQLStatistics;
80 : extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
81 : extern T3SQLTables pODBC3SQLTables;
82 : extern T3SQLFreeStmt pODBC3SQLFreeStmt;
83 : extern T3SQLCloseCursor pODBC3SQLCloseCursor;
84 : extern T3SQLCancel pODBC3SQLCancel;
85 : extern T3SQLEndTran pODBC3SQLEndTran;
86 : extern T3SQLDisconnect pODBC3SQLDisconnect;
87 : extern T3SQLFreeHandle pODBC3SQLFreeHandle;
88 : extern T3SQLGetCursorName pODBC3SQLGetCursorName;
89 : extern T3SQLNativeSql pODBC3SQLNativeSql;
90 :
91 :
92 : namespace odbc
93 : {
94 0 : class ORealObdcDriver : public ODBCDriver
95 : {
96 : protected:
97 : virtual oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const SAL_OVERRIDE;
98 : virtual SQLHANDLE EnvironmentHandle(OUString &_rPath) SAL_OVERRIDE;
99 : public:
100 0 : ORealObdcDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {}
101 : };
102 :
103 :
104 0 : oslGenericFunction ORealObdcDriver::getOdbcFunction(sal_Int32 _nIndex) const
105 : {
106 0 : oslGenericFunction pFunction = NULL;
107 0 : switch(_nIndex)
108 : {
109 : case ODBC3SQLAllocHandle:
110 0 : pFunction = (oslGenericFunction)pODBC3SQLAllocHandle;
111 0 : break;
112 : case ODBC3SQLConnect:
113 0 : pFunction = (oslGenericFunction)pODBC3SQLConnect;
114 0 : break;
115 : case ODBC3SQLDriverConnect:
116 0 : pFunction = (oslGenericFunction)pODBC3SQLDriverConnect;
117 0 : break;
118 : case ODBC3SQLBrowseConnect:
119 0 : pFunction = (oslGenericFunction)pODBC3SQLBrowseConnect;
120 0 : break;
121 : case ODBC3SQLDataSources:
122 0 : pFunction = (oslGenericFunction)pODBC3SQLDataSources;
123 0 : break;
124 : case ODBC3SQLDrivers:
125 0 : pFunction = (oslGenericFunction)pODBC3SQLDrivers;
126 0 : break;
127 : case ODBC3SQLGetInfo:
128 :
129 0 : pFunction = (oslGenericFunction)pODBC3SQLGetInfo;
130 0 : break;
131 : case ODBC3SQLGetFunctions:
132 :
133 0 : pFunction = (oslGenericFunction)pODBC3SQLGetFunctions;
134 0 : break;
135 : case ODBC3SQLGetTypeInfo:
136 :
137 0 : pFunction = (oslGenericFunction)pODBC3SQLGetTypeInfo;
138 0 : break;
139 : case ODBC3SQLSetConnectAttr:
140 :
141 0 : pFunction = (oslGenericFunction)pODBC3SQLSetConnectAttr;
142 0 : break;
143 : case ODBC3SQLGetConnectAttr:
144 :
145 0 : pFunction = (oslGenericFunction)pODBC3SQLGetConnectAttr;
146 0 : break;
147 : case ODBC3SQLSetEnvAttr:
148 :
149 0 : pFunction = (oslGenericFunction)pODBC3SQLSetEnvAttr;
150 0 : break;
151 : case ODBC3SQLGetEnvAttr:
152 :
153 0 : pFunction = (oslGenericFunction)pODBC3SQLGetEnvAttr;
154 0 : break;
155 : case ODBC3SQLSetStmtAttr:
156 :
157 0 : pFunction = (oslGenericFunction)pODBC3SQLSetStmtAttr;
158 0 : break;
159 : case ODBC3SQLGetStmtAttr:
160 :
161 0 : pFunction = (oslGenericFunction)pODBC3SQLGetStmtAttr;
162 0 : break;
163 : case ODBC3SQLPrepare:
164 :
165 0 : pFunction = (oslGenericFunction)pODBC3SQLPrepare;
166 0 : break;
167 : case ODBC3SQLBindParameter:
168 :
169 0 : pFunction = (oslGenericFunction)pODBC3SQLBindParameter;
170 0 : break;
171 : case ODBC3SQLSetCursorName:
172 :
173 0 : pFunction = (oslGenericFunction)pODBC3SQLSetCursorName;
174 0 : break;
175 : case ODBC3SQLExecute:
176 :
177 0 : pFunction = (oslGenericFunction)pODBC3SQLExecute;
178 0 : break;
179 : case ODBC3SQLExecDirect:
180 :
181 0 : pFunction = (oslGenericFunction)pODBC3SQLExecDirect;
182 0 : break;
183 : case ODBC3SQLDescribeParam:
184 :
185 0 : pFunction = (oslGenericFunction)pODBC3SQLDescribeParam;
186 0 : break;
187 : case ODBC3SQLNumParams:
188 :
189 0 : pFunction = (oslGenericFunction)pODBC3SQLNumParams;
190 0 : break;
191 : case ODBC3SQLParamData:
192 :
193 0 : pFunction = (oslGenericFunction)pODBC3SQLParamData;
194 0 : break;
195 : case ODBC3SQLPutData:
196 :
197 0 : pFunction = (oslGenericFunction)pODBC3SQLPutData;
198 0 : break;
199 : case ODBC3SQLRowCount:
200 :
201 0 : pFunction = (oslGenericFunction)pODBC3SQLRowCount;
202 0 : break;
203 : case ODBC3SQLNumResultCols:
204 :
205 0 : pFunction = (oslGenericFunction)pODBC3SQLNumResultCols;
206 0 : break;
207 : case ODBC3SQLDescribeCol:
208 :
209 0 : pFunction = (oslGenericFunction)pODBC3SQLDescribeCol;
210 0 : break;
211 : case ODBC3SQLColAttribute:
212 :
213 0 : pFunction = (oslGenericFunction)pODBC3SQLColAttribute;
214 0 : break;
215 : case ODBC3SQLBindCol:
216 :
217 0 : pFunction = (oslGenericFunction)pODBC3SQLBindCol;
218 0 : break;
219 : case ODBC3SQLFetch:
220 :
221 0 : pFunction = (oslGenericFunction)pODBC3SQLFetch;
222 0 : break;
223 : case ODBC3SQLFetchScroll:
224 :
225 0 : pFunction = (oslGenericFunction)pODBC3SQLFetchScroll;
226 0 : break;
227 : case ODBC3SQLGetData:
228 :
229 0 : pFunction = (oslGenericFunction)pODBC3SQLGetData;
230 0 : break;
231 : case ODBC3SQLSetPos:
232 :
233 0 : pFunction = (oslGenericFunction)pODBC3SQLSetPos;
234 0 : break;
235 : case ODBC3SQLBulkOperations:
236 :
237 0 : pFunction = (oslGenericFunction)pODBC3SQLBulkOperations;
238 0 : break;
239 : case ODBC3SQLMoreResults:
240 :
241 0 : pFunction = (oslGenericFunction)pODBC3SQLMoreResults;
242 0 : break;
243 : case ODBC3SQLGetDiagRec:
244 :
245 0 : pFunction = (oslGenericFunction)pODBC3SQLGetDiagRec;
246 0 : break;
247 : case ODBC3SQLColumnPrivileges:
248 :
249 0 : pFunction = (oslGenericFunction)pODBC3SQLColumnPrivileges;
250 0 : break;
251 : case ODBC3SQLColumns:
252 :
253 0 : pFunction = (oslGenericFunction)pODBC3SQLColumns;
254 0 : break;
255 : case ODBC3SQLForeignKeys:
256 :
257 0 : pFunction = (oslGenericFunction)pODBC3SQLForeignKeys;
258 0 : break;
259 : case ODBC3SQLPrimaryKeys:
260 :
261 0 : pFunction = (oslGenericFunction)pODBC3SQLPrimaryKeys;
262 0 : break;
263 : case ODBC3SQLProcedureColumns:
264 :
265 0 : pFunction = (oslGenericFunction)pODBC3SQLProcedureColumns;
266 0 : break;
267 : case ODBC3SQLProcedures:
268 :
269 0 : pFunction = (oslGenericFunction)pODBC3SQLProcedures;
270 0 : break;
271 : case ODBC3SQLSpecialColumns:
272 :
273 0 : pFunction = (oslGenericFunction)pODBC3SQLSpecialColumns;
274 0 : break;
275 : case ODBC3SQLStatistics:
276 :
277 0 : pFunction = (oslGenericFunction)pODBC3SQLStatistics;
278 0 : break;
279 : case ODBC3SQLTablePrivileges:
280 :
281 0 : pFunction = (oslGenericFunction)pODBC3SQLTablePrivileges;
282 0 : break;
283 : case ODBC3SQLTables:
284 :
285 0 : pFunction = (oslGenericFunction)pODBC3SQLTables;
286 0 : break;
287 : case ODBC3SQLFreeStmt:
288 :
289 0 : pFunction = (oslGenericFunction)pODBC3SQLFreeStmt;
290 0 : break;
291 : case ODBC3SQLCloseCursor:
292 :
293 0 : pFunction = (oslGenericFunction)pODBC3SQLCloseCursor;
294 0 : break;
295 : case ODBC3SQLCancel:
296 :
297 0 : pFunction = (oslGenericFunction)pODBC3SQLCancel;
298 0 : break;
299 : case ODBC3SQLEndTran:
300 :
301 0 : pFunction = (oslGenericFunction)pODBC3SQLEndTran;
302 0 : break;
303 : case ODBC3SQLDisconnect:
304 :
305 0 : pFunction = (oslGenericFunction)pODBC3SQLDisconnect;
306 0 : break;
307 : case ODBC3SQLFreeHandle:
308 :
309 0 : pFunction = (oslGenericFunction)pODBC3SQLFreeHandle;
310 0 : break;
311 : case ODBC3SQLGetCursorName:
312 :
313 0 : pFunction = (oslGenericFunction)pODBC3SQLGetCursorName;
314 0 : break;
315 : case ODBC3SQLNativeSql:
316 :
317 0 : pFunction = (oslGenericFunction)pODBC3SQLNativeSql;
318 0 : break;
319 : default:
320 : OSL_FAIL("Function unknown!");
321 : }
322 0 : return pFunction;
323 : }
324 :
325 :
326 0 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODBCDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
327 : {
328 0 : return *(new ORealObdcDriver(_rxFactory));
329 : }
330 :
331 : // ODBC Environment (common for all Connections):
332 0 : SQLHANDLE ORealObdcDriver::EnvironmentHandle(OUString &_rPath)
333 : {
334 : // Is (for this instance) already a Environment made?
335 0 : if (!m_pDriverHandle)
336 : {
337 0 : SQLHANDLE h = SQL_NULL_HANDLE;
338 : // allocate Environment
339 :
340 : // load ODBC-DLL now:
341 0 : if (!LoadLibrary_ODBC3(_rPath) || N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
342 0 : return SQL_NULL_HANDLE;
343 :
344 : // Save in global Structure
345 0 : m_pDriverHandle = h;
346 0 : SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION, reinterpret_cast<SQLPOINTER>(SQL_OV_ODBC3), SQL_IS_UINTEGER);
347 : OSL_UNUSED( nError );
348 : //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
349 : }
350 :
351 0 : return m_pDriverHandle;
352 : }
353 :
354 :
355 : }
356 : }
357 :
358 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|