LibreOffice Module connectivity (master) 1
ORealDriver.cxx
Go to the documentation of this file.
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 <odbc/ODriver.hxx>
21#include <odbc/OTools.hxx>
22#include <odbc/OFunctions.hxx>
23
25{
26 namespace {
27
28 class ORealOdbcDriver : public ODBCDriver
29 {
30 protected:
31 virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const override;
32 virtual SQLHANDLE EnvironmentHandle(OUString &_rPath) override;
33 public:
34 explicit ORealOdbcDriver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext) : ODBCDriver(_rxContext) {}
35 };
36
37 }
38
39oslGenericFunction ORealOdbcDriver::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
40{
41 oslGenericFunction pFunction = nullptr;
42 switch(_nIndex)
43 {
45 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLAllocHandle);
46 break;
48 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLConnect);
49 break;
51 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDriverConnect);
52 break;
54 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBrowseConnect);
55 break;
57 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDataSources);
58 break;
60 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDrivers);
61 break;
63
64 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetInfo);
65 break;
67
68 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetFunctions);
69 break;
71
72 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetTypeInfo);
73 break;
75
76 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetConnectAttr);
77 break;
79
80 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetConnectAttr);
81 break;
83
84 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetEnvAttr);
85 break;
87
88 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetEnvAttr);
89 break;
91
92 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetStmtAttr);
93 break;
95
96 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetStmtAttr);
97 break;
99
100 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPrepare);
101 break;
103
104 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBindParameter);
105 break;
107
108 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetCursorName);
109 break;
111
112 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLExecute);
113 break;
115
116 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLExecDirect);
117 break;
119
120 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDescribeParam);
121 break;
123
124 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNumParams);
125 break;
127
128 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLParamData);
129 break;
131
132 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPutData);
133 break;
135
136 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLRowCount);
137 break;
139
140 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNumResultCols);
141 break;
143
144 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDescribeCol);
145 break;
147
148 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColAttribute);
149 break;
151
152 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBindCol);
153 break;
155
156 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFetch);
157 break;
159
160 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFetchScroll);
161 break;
163
164 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetData);
165 break;
167
168 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetPos);
169 break;
171
172 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBulkOperations);
173 break;
175
176 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLMoreResults);
177 break;
179
180 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetDiagRec);
181 break;
183
184 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColumnPrivileges);
185 break;
187
188 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColumns);
189 break;
191
192 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLForeignKeys);
193 break;
195
196 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPrimaryKeys);
197 break;
199
200 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLProcedureColumns);
201 break;
203
204 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLProcedures);
205 break;
207
208 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSpecialColumns);
209 break;
211
212 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLStatistics);
213 break;
215
216 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLTablePrivileges);
217 break;
219
220 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLTables);
221 break;
223
224 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFreeStmt);
225 break;
227
228 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLCloseCursor);
229 break;
231
232 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLCancel);
233 break;
235
236 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLEndTran);
237 break;
239
240 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDisconnect);
241 break;
243
244 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFreeHandle);
245 break;
247
248 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetCursorName);
249 break;
251
252 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNativeSql);
253 break;
254 default:
255 OSL_FAIL("Function unknown!");
256 }
257 return pFunction;
258}
259
260
261// ODBC Environment (common for all Connections):
262SQLHANDLE ORealOdbcDriver::EnvironmentHandle(OUString &_rPath)
263{
264 // Is (for this instance) already an Environment made?
265 if (!m_pDriverHandle)
266 {
267 SQLHANDLE h = SQL_NULL_HANDLE;
268 // allocate Environment
269
270 // load ODBC-DLL now:
271 if (!LoadLibrary_ODBC3(_rPath) || N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
272 return SQL_NULL_HANDLE;
273
274 // Save in global Structure
275 m_pDriverHandle = h;
276 N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION, reinterpret_cast<SQLPOINTER>(SQL_OV_ODBC3), SQL_IS_UINTEGER);
277 //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
278 }
279
280 return m_pDriverHandle;
281}
282
283}
284
285extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
287 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
288{
289 return cppu::acquire(new connectivity::odbc::ORealOdbcDriver(context));
290}
291/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define N3SQLAllocHandle(a, b, c)
Definition: OFunctions.hxx:36
#define N3SQLSetEnvAttr(a, b, c, d)
Definition: OFunctions.hxx:126
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * connectivity_odbc_ORealOdbcDriver_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
ODBC3SQLFunctionId
Definition: OTools.hxx:33
T3SQLSetEnvAttr pODBC3SQLSetEnvAttr
Definition: OFunctions.cxx:37
T3SQLCloseCursor pODBC3SQLCloseCursor
Definition: OFunctions.cxx:73
T3SQLRowCount pODBC3SQLRowCount
Definition: OFunctions.cxx:50
T3SQLAllocHandle pODBC3SQLAllocHandle
Definition: OFunctions.cxx:26
T3SQLDescribeCol pODBC3SQLDescribeCol
Definition: OFunctions.cxx:52
T3SQLColumnPrivileges pODBC3SQLColumnPrivileges
Definition: OFunctions.cxx:62
T3SQLBulkOperations pODBC3SQLBulkOperations
Definition: OFunctions.cxx:59
T3SQLParamData pODBC3SQLParamData
Definition: OFunctions.cxx:48
T3SQLPrepare pODBC3SQLPrepare
Definition: OFunctions.cxx:41
T3SQLSetConnectAttr pODBC3SQLSetConnectAttr
Definition: OFunctions.cxx:35
T3SQLExecDirect pODBC3SQLExecDirect
Definition: OFunctions.cxx:45
T3SQLForeignKeys pODBC3SQLForeignKeys
Definition: OFunctions.cxx:64
T3SQLGetEnvAttr pODBC3SQLGetEnvAttr
Definition: OFunctions.cxx:38
T3SQLConnect pODBC3SQLConnect
Definition: OFunctions.cxx:27
T3SQLEndTran pODBC3SQLEndTran
Definition: OFunctions.cxx:75
T3SQLSetStmtAttr pODBC3SQLSetStmtAttr
Definition: OFunctions.cxx:39
T3SQLColumns pODBC3SQLColumns
Definition: OFunctions.cxx:63
bool LoadLibrary_ODBC3(OUString &_rPath)
Definition: OFunctions.cxx:85
T3SQLPrimaryKeys pODBC3SQLPrimaryKeys
Definition: OFunctions.cxx:65
T3SQLGetFunctions pODBC3SQLGetFunctions
Definition: OFunctions.cxx:33
T3SQLNativeSql pODBC3SQLNativeSql
Definition: OFunctions.cxx:79
T3SQLProcedures pODBC3SQLProcedures
Definition: OFunctions.cxx:67
T3SQLNumResultCols pODBC3SQLNumResultCols
Definition: OFunctions.cxx:51
T3SQLGetInfo pODBC3SQLGetInfo
Definition: OFunctions.cxx:32
T3SQLColAttribute pODBC3SQLColAttribute
Definition: OFunctions.cxx:53
T3SQLNumParams pODBC3SQLNumParams
Definition: OFunctions.cxx:47
T3SQLBindCol pODBC3SQLBindCol
Definition: OFunctions.cxx:54
T3SQLPutData pODBC3SQLPutData
Definition: OFunctions.cxx:49
T3SQLBindParameter pODBC3SQLBindParameter
Definition: OFunctions.cxx:42
T3SQLStatistics pODBC3SQLStatistics
Definition: OFunctions.cxx:69
T3SQLMoreResults pODBC3SQLMoreResults
Definition: OFunctions.cxx:60
T3SQLProcedureColumns pODBC3SQLProcedureColumns
Definition: OFunctions.cxx:66
T3SQLCancel pODBC3SQLCancel
Definition: OFunctions.cxx:74
T3SQLSetPos pODBC3SQLSetPos
Definition: OFunctions.cxx:58
T3SQLFetch pODBC3SQLFetch
Definition: OFunctions.cxx:55
T3SQLExecute pODBC3SQLExecute
Definition: OFunctions.cxx:44
T3SQLFreeStmt pODBC3SQLFreeStmt
Definition: OFunctions.cxx:72
T3SQLBrowseConnect pODBC3SQLBrowseConnect
Definition: OFunctions.cxx:29
T3SQLGetDiagRec pODBC3SQLGetDiagRec
Definition: OFunctions.cxx:61
T3SQLGetConnectAttr pODBC3SQLGetConnectAttr
Definition: OFunctions.cxx:36
T3SQLDescribeParam pODBC3SQLDescribeParam
Definition: OFunctions.cxx:46
T3SQLGetCursorName pODBC3SQLGetCursorName
Definition: OFunctions.cxx:78
T3SQLSpecialColumns pODBC3SQLSpecialColumns
Definition: OFunctions.cxx:68
T3SQLFreeHandle pODBC3SQLFreeHandle
Definition: OFunctions.cxx:77
T3SQLSetCursorName pODBC3SQLSetCursorName
Definition: OFunctions.cxx:43
T3SQLGetStmtAttr pODBC3SQLGetStmtAttr
Definition: OFunctions.cxx:40
T3SQLGetData pODBC3SQLGetData
Definition: OFunctions.cxx:57
T3SQLDisconnect pODBC3SQLDisconnect
Definition: OFunctions.cxx:76
T3SQLDriverConnect pODBC3SQLDriverConnect
Definition: OFunctions.cxx:28
T3SQLTablePrivileges pODBC3SQLTablePrivileges
Definition: OFunctions.cxx:70
T3SQLGetTypeInfo pODBC3SQLGetTypeInfo
Definition: OFunctions.cxx:34
T3SQLFetchScroll pODBC3SQLFetchScroll
Definition: OFunctions.cxx:56
T3SQLDataSources pODBC3SQLDataSources
Definition: OFunctions.cxx:30
T3SQLTables pODBC3SQLTables
Definition: OFunctions.cxx:71
T3SQLDrivers pODBC3SQLDrivers
Definition: OFunctions.cxx:31
sal_Int32 h