102{
103 ListedByteStringToByteStringMap map;
104 Connection::splitConnectionString(_connString, _connlen, map);
105
106 ByteString strDatabase = map["DATABASE"];
107 ByteString strUser = map["USER"];
108 ByteString strPassword = map["PASSWORD"];
109 ByteString strMode = map["MODE"];
110
111 ub4 nOperationMode = OCI_DEFAULT;
112 if (!strMode.isEmpty()) {
113 if (!strMode.compareNoCase("SYSDBA"))
114 nOperationMode = OCI_SYSDBA;
115 else if (!strMode.compareNoCase("SYSOPER"))
116 nOperationMode = OCI_SYSOPER;
117 else {
119 return false;
120 }
121 }
122
123 if (strUser.isEmpty()) {
125 return false;
126 }
127
128 sword status = OCI_SUCCESS;
129
130
132 status = ::OCIEnvCreate(
134 OCI_ENV_NO_MUTEX | OCI_THREADED | OCI_OBJECT,
135 (void*)0, 0, 0, 0,
136 (size_t)0, (void**)0
137 );
138 if (status != OCI_SUCCESS) {
140 goto __on_error;
141 }
142 }
143
146 if (status != OCI_SUCCESS) {
148 goto __on_error;
149 }
150 }
151
153 if (status != OCI_SUCCESS) {
155 goto __on_error;
156 }
157
159 if (status != OCI_SUCCESS) {
161 goto __on_error;
162 }
163
165 if (status != OCI_SUCCESS) {
167 goto __on_error;
168 }
169
171 if (status != OCI_SUCCESS) {
173 goto __on_error;
174 }
175
177 if (status != OCI_SUCCESS) {
179 goto __on_error;
180 }
181
182 status = ::OCIServerAttach(
185 strDatabase.isEmpty()?
NULL : (text*)strDatabase.data(),
186 strDatabase.isEmpty()? 0 : strDatabase.length(),
187 OCI_DEFAULT
188 );
189 if (status != OCI_SUCCESS) {
191 goto __on_error;
192 }
193
194#if defined(__DCL_DEBUG) && __TRACE_THIS
197 (OraText*)
buf,
sizeof(
buf), OCI_NLS_CHARACTER_SET);
198 if (status == OCI_SUCCESS) {
200 }
201 else {
203 }
205 (OraText*)
buf,
sizeof(
buf), OCI_NLS_LANGUAGE);
206 if (status == OCI_SUCCESS) {
208 }
209 else {
211 }
213 (OraText*)
buf,
sizeof(
buf), OCI_NLS_ABLANGUAGE);
214 if (status == OCI_SUCCESS) {
216 }
217 else {
219 }
221 (OraText*)
buf,
sizeof(
buf), OCI_NLS_TERRITORY);
222 if (status == OCI_SUCCESS) {
224 }
225 else {
227 }
228#endif
229
231
232 status = ::OCIAttrSet(
234 OCI_HTYPE_SVCCTX,
236 (ub4)0,
237 OCI_ATTR_SERVER,
239 );
240 if (status != OCI_SUCCESS) {
242 goto __on_error;
243 }
244
245 status = ::OCIAttrSet(
247 OCI_HTYPE_SESSION,
248 (void*)strUser.data(),
249 strUser.length(),
250 OCI_ATTR_USERNAME,
252 );
253 if (status != OCI_SUCCESS) {
255 goto __on_error;
256 }
257
258 status = ::OCIAttrSet(
260 OCI_HTYPE_SESSION,
261 (void*)strPassword.data(),
262 strPassword.length(),
263 OCI_ATTR_PASSWORD,
265 );
266 if (status != OCI_SUCCESS) {
268 goto __on_error;
269 }
270
271 status = ::OCISessionBegin(
275 OCI_CRED_RDBMS,
276 nOperationMode
277 );
278 if (status != OCI_SUCCESS) {
280 goto __on_error;
281 }
282
284 status = ::OCIAttrSet(
286 OCI_HTYPE_SVCCTX,
288 (ub4)0,
289 OCI_ATTR_SERVER,
291 );
292 if (status != OCI_SUCCESS) {
294 goto __on_error;
295 }
296
297 status = ::OCIAttrSet(
299 OCI_HTYPE_SVCCTX,
301 0,
302 OCI_ATTR_SESSION,
304 );
305 if (status != OCI_SUCCESS) {
307 goto __on_error;
308 }
309
310 status = ::OCIAttrSet(
312 OCI_HTYPE_SVCCTX,
314 0,
315 OCI_ATTR_TRANS,
317 );
318 if (status != OCI_SUCCESS) {
320 goto __on_error;
321 }
322
323 return true;
324
325__on_error:
327 return false;
328}
#define __DCL_TRACE1_N(fmt, arg)
sword OCIHandleAlloc(void **ppHandle, ub4 nHandleType, size_t xtramem_sz=0, void **ppvUserMem=NULL)
@ eInvalidConnectionString