1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "odbc/OTools.hxx"
30 #include "odbc/OConnection.hxx"
31 #include "odbc/ODatabaseMetaData.hxx"
32 #include "odbc/OFunctions.hxx"
33 #include "odbc/ODriver.hxx"
34 #include "odbc/OStatement.hxx"
35 #include "odbc/OPreparedStatement.hxx"
36 #include <com/sun/star/sdbc/ColumnValue.hpp>
37 #include <com/sun/star/sdbc/XRow.hpp>
38 #include <com/sun/star/lang/DisposedException.hpp>
39 #include <connectivity/dbcharset.hxx>
40 #include <connectivity/FValue.hxx>
41 #include <comphelper/extract.hxx>
42 #include "diagnose_ex.h"
43 #include <connectivity/dbexception.hxx>
47 using namespace connectivity::odbc
;
48 using namespace connectivity
;
49 using namespace dbtools
;
51 //------------------------------------------------------------------------------
52 using namespace com::sun::star::uno
;
53 using namespace com::sun::star::lang
;
54 using namespace com::sun::star::beans
;
55 using namespace com::sun::star::sdbc
;
56 // --------------------------------------------------------------------------------
57 OConnection::OConnection(const SQLHANDLE _pDriverHandle
,ODBCDriver
* _pDriver
)
58 : OSubComponent
<OConnection
, OConnection_BASE
>((::cppu::OWeakObject
*)_pDriver
, this)
60 ,m_pDriverHandleCopy(_pDriverHandle
)
63 ,m_bUseCatalog(sal_False
)
64 ,m_bUseOldDateFormat(sal_False
)
65 ,m_bParameterSubstitution(sal_False
)
66 ,m_bIgnoreDriverPrivileges(sal_False
)
67 ,m_bPreventGetVersionColumns(sal_False
)
68 ,m_bReadOnly(sal_True
)
72 //-----------------------------------------------------------------------------
73 OConnection::~OConnection()
78 if ( SQL_NULL_HANDLE
!= m_aConnectionHandle
)
82 rc
= N3SQLDisconnect( m_aConnectionHandle
);
83 OSL_ENSURE( rc
== SQL_SUCCESS
|| rc
== SQL_SUCCESS_WITH_INFO
, "Failure from SQLDisconnect" );
85 rc
= N3SQLFreeHandle( SQL_HANDLE_DBC
, m_aConnectionHandle
);
86 OSL_ENSURE( rc
== SQL_SUCCESS
, "Failure from SQLFreeHandle for connection");
89 m_aConnectionHandle
= SQL_NULL_HANDLE
;
95 //-----------------------------------------------------------------------------
96 void SAL_CALL
OConnection::release() throw()
100 // -----------------------------------------------------------------------------
101 oslGenericFunction
OConnection::getOdbcFunction(sal_Int32 _nIndex
) const
103 OSL_ENSURE(m_pDriver
,"OConnection::getOdbcFunction: m_pDriver is null!");
104 return m_pDriver
->getOdbcFunction(_nIndex
);
106 //-----------------------------------------------------------------------------
107 SQLRETURN
OConnection::OpenConnection(const ::rtl::OUString
& aConnectStr
,sal_Int32 nTimeOut
, sal_Bool bSilent
)
109 ::osl::MutexGuard
aGuard( m_aMutex
);
111 if (m_aConnectionHandle
== SQL_NULL_HANDLE
)
114 SQLRETURN nSQLRETURN
= 0;
115 SDB_ODBC_CHAR szConnStrOut
[4096];
116 SDB_ODBC_CHAR szConnStrIn
[2048];
117 SQLSMALLINT cbConnStrOut
;
118 memset(szConnStrOut
,'\0',4096);
119 memset(szConnStrIn
,'\0',2048);
120 ::rtl::OString
aConStr(::rtl::OUStringToOString(aConnectStr
,getTextEncoding()));
121 memcpy(szConnStrIn
, (SDB_ODBC_CHAR
*) aConStr
.getStr(), ::std::min
<sal_Int32
>((sal_Int32
)2048,aConStr
.getLength()));
124 N3SQLSetConnectAttr(m_aConnectionHandle
,SQL_ATTR_LOGIN_TIMEOUT
,(SQLPOINTER
)(sal_IntPtr
)nTimeOut
,SQL_IS_UINTEGER
);
128 OSL_UNUSED( bSilent
);
129 nSQLRETURN
= N3SQLDriverConnect(m_aConnectionHandle
,
132 (SQLSMALLINT
) ::std::min((sal_Int32
)2048,aConStr
.getLength()),
134 (SQLSMALLINT
) (sizeof(szConnStrOut
)/sizeof(SDB_ODBC_CHAR
)) -1,
136 SQL_DRIVER_NOPROMPT
);
137 if (nSQLRETURN
== SQL_ERROR
|| nSQLRETURN
== SQL_NO_DATA
|| SQL_SUCCESS_WITH_INFO
== nSQLRETURN
)
141 SQLUSMALLINT nSilent
= bSilent
? SQL_DRIVER_NOPROMPT
: SQL_DRIVER_COMPLETE
;
142 nSQLRETURN
= N3SQLDriverConnect(m_aConnectionHandle
,
145 (SQLSMALLINT
) ::std::min
<sal_Int32
>((sal_Int32
)2048,aConStr
.getLength()),
147 (SQLSMALLINT
) sizeof szConnStrOut
,
150 if (nSQLRETURN
== SQL_ERROR
|| nSQLRETURN
== SQL_NO_DATA
)
153 m_bClosed
= sal_False
;
159 ::rtl::OUString aVal
;
160 OTools::GetInfo(this,m_aConnectionHandle
,SQL_DATA_SOURCE_READ_ONLY
,aVal
,*this,getTextEncoding());
161 m_bReadOnly
= !aVal
.compareToAscii("Y");
165 m_bReadOnly
= sal_True
;
169 ::rtl::OUString sVersion
;
170 OTools::GetInfo(this,m_aConnectionHandle
,SQL_DRIVER_ODBC_VER
,sVersion
,*this,getTextEncoding());
171 m_bUseOldDateFormat
= sVersion
== ::rtl::OUString("02.50") || sVersion
== ::rtl::OUString("02.00");
178 // autocoomit is always default
181 N3SQLSetConnectAttr(m_aConnectionHandle
,SQL_ATTR_AUTOCOMMIT
,(SQLPOINTER
)SQL_AUTOCOMMIT_ON
,SQL_IS_INTEGER
);
185 //-----------------------------------------------------------------------------
186 SQLRETURN
OConnection::Construct(const ::rtl::OUString
& url
,const Sequence
< PropertyValue
>& info
) throw(SQLException
)
188 m_aConnectionHandle
= SQL_NULL_HANDLE
;
190 setConnectionInfo(info
);
192 N3SQLAllocHandle(SQL_HANDLE_DBC
,m_pDriverHandleCopy
,&m_aConnectionHandle
);
193 if(m_aConnectionHandle
== SQL_NULL_HANDLE
)
194 throw SQLException();
196 sal_Int32 nLen
= url
.indexOf(':');
197 nLen
= url
.indexOf(':',nLen
+1);
198 ::rtl::OUString
aDSN("DSN="), aUID
, aPWD
, aSysDrvSettings
;
199 aDSN
+= url
.copy(nLen
+1);
201 const char* pUser
= "user";
202 const char* pTimeout
= "Timeout";
203 const char* pSilent
= "Silent";
204 const char* pPwd
= "password";
205 const char* pUseCatalog
= "UseCatalog";
206 const char* pSysDrv
= "SystemDriverSettings";
207 const char* pCharSet
= "CharSet";
208 const char* pParaName
= "ParameterNameSubstitution";
209 const char* pPrivName
= "IgnoreDriverPrivileges";
210 const char* pVerColName
= "PreventGetVersionColumns"; // #i60273#
211 const char* pRetrieving
= "IsAutoRetrievingEnabled";
212 const char* pRetriStmt
= "AutoRetrievingStatement";
214 sal_Int32 nTimeout
= 20;
215 sal_Bool bSilent
= sal_True
;
216 const PropertyValue
*pBegin
= info
.getConstArray();
217 const PropertyValue
*pEnd
= pBegin
+ info
.getLength();
218 for(;pBegin
!= pEnd
;++pBegin
)
220 if(!pBegin
->Name
.compareToAscii(pTimeout
))
221 OSL_VERIFY( pBegin
->Value
>>= nTimeout
);
222 else if(!pBegin
->Name
.compareToAscii(pSilent
))
223 OSL_VERIFY( pBegin
->Value
>>= bSilent
);
224 else if(!pBegin
->Name
.compareToAscii(pPrivName
))
225 OSL_VERIFY( pBegin
->Value
>>= m_bIgnoreDriverPrivileges
);
226 else if(!pBegin
->Name
.compareToAscii(pVerColName
))
227 OSL_VERIFY( pBegin
->Value
>>= m_bPreventGetVersionColumns
);
228 else if(!pBegin
->Name
.compareToAscii(pParaName
))
229 OSL_VERIFY( pBegin
->Value
>>= m_bParameterSubstitution
);
230 else if(!pBegin
->Name
.compareToAscii(pRetrieving
))
232 sal_Bool bAutoRetrievingEnabled
= sal_False
;
233 OSL_VERIFY( pBegin
->Value
>>= bAutoRetrievingEnabled
);
234 enableAutoRetrievingEnabled(bAutoRetrievingEnabled
);
236 else if(!pBegin
->Name
.compareToAscii(pRetriStmt
))
238 ::rtl::OUString sGeneratedValueStatement
;
239 OSL_VERIFY( pBegin
->Value
>>= sGeneratedValueStatement
);
240 setAutoRetrievingStatement(sGeneratedValueStatement
);
242 else if(!pBegin
->Name
.compareToAscii(pUser
))
244 OSL_VERIFY( pBegin
->Value
>>= aUID
);
245 aDSN
= aDSN
+ ::rtl::OUString(";UID=") + aUID
;
247 else if(!pBegin
->Name
.compareToAscii(pPwd
))
249 OSL_VERIFY( pBegin
->Value
>>= aPWD
);
250 aDSN
= aDSN
+ ::rtl::OUString(";PWD=") + aPWD
;
252 else if(!pBegin
->Name
.compareToAscii(pUseCatalog
))
254 OSL_VERIFY( pBegin
->Value
>>= m_bUseCatalog
);
256 else if(!pBegin
->Name
.compareToAscii(pSysDrv
))
258 OSL_VERIFY( pBegin
->Value
>>= aSysDrvSettings
);
259 aDSN
+= ::rtl::OUString(";");
260 aDSN
+= aSysDrvSettings
;
262 else if(0 == pBegin
->Name
.compareToAscii(pCharSet
))
264 ::rtl::OUString sIanaName
;
265 OSL_VERIFY( pBegin
->Value
>>= sIanaName
);
267 ::dbtools::OCharsetMap aLookupIanaName
;
268 ::dbtools::OCharsetMap::const_iterator aLookup
= aLookupIanaName
.find(sIanaName
, ::dbtools::OCharsetMap::IANA());
269 if (aLookup
!= aLookupIanaName
.end())
270 m_nTextEncoding
= (*aLookup
).getEncoding();
272 m_nTextEncoding
= RTL_TEXTENCODING_DONTKNOW
;
273 if(m_nTextEncoding
== RTL_TEXTENCODING_DONTKNOW
)
274 m_nTextEncoding
= osl_getThreadTextEncoding();
279 SQLRETURN nSQLRETURN
= OpenConnection(aDSN
,nTimeout
, bSilent
);
280 if (nSQLRETURN
== SQL_ERROR
|| nSQLRETURN
== SQL_NO_DATA
)
282 OTools::ThrowException(this,nSQLRETURN
,m_aConnectionHandle
,SQL_HANDLE_DBC
,*this,sal_False
);
287 // --------------------------------------------------------------------------------
288 IMPLEMENT_SERVICE_INFO(OConnection
, "com.sun.star.sdbc.drivers.odbc.OConnection", "com.sun.star.sdbc.Connection")
290 // --------------------------------------------------------------------------------
291 Reference
< XStatement
> SAL_CALL
OConnection::createStatement( ) throw(SQLException
, RuntimeException
)
293 ::osl::MutexGuard
aGuard( m_aMutex
);
294 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
296 Reference
< XStatement
> xReturn
= new OStatement(this);
297 m_aStatements
.push_back(WeakReferenceHelper(xReturn
));
300 // --------------------------------------------------------------------------------
301 Reference
< XPreparedStatement
> SAL_CALL
OConnection::prepareStatement( const ::rtl::OUString
& sql
) throw(SQLException
, RuntimeException
)
303 ::osl::MutexGuard
aGuard( m_aMutex
);
304 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
306 Reference
< XPreparedStatement
> xReturn
= new OPreparedStatement(this,sql
);
307 m_aStatements
.push_back(WeakReferenceHelper(xReturn
));
310 // --------------------------------------------------------------------------------
311 Reference
< XPreparedStatement
> SAL_CALL
OConnection::prepareCall( const ::rtl::OUString
& /*sql*/ ) throw(SQLException
, RuntimeException
)
313 ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
316 // --------------------------------------------------------------------------------
317 ::rtl::OUString SAL_CALL
OConnection::nativeSQL( const ::rtl::OUString
& sql
) throw(SQLException
, RuntimeException
)
319 ::osl::MutexGuard
aGuard( m_aMutex
);
321 ::rtl::OString
aSql(::rtl::OUStringToOString(sql
.getStr(),getTextEncoding()));
324 OTools::ThrowException(this,N3SQLNativeSql(m_aConnectionHandle
,(SDB_ODBC_CHAR
*)aSql
.getStr(),aSql
.getLength(),(SDB_ODBC_CHAR
*)pOut
,sizeof pOut
- 1,&nOutLen
),m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
325 return ::rtl::OUString(pOut
,nOutLen
,getTextEncoding());
327 // --------------------------------------------------------------------------------
328 void SAL_CALL
OConnection::setAutoCommit( sal_Bool autoCommit
) throw(SQLException
, RuntimeException
)
330 ::osl::MutexGuard
aGuard( m_aMutex
);
331 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
334 OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle
,
336 (SQLPOINTER
)((autoCommit
) ? SQL_AUTOCOMMIT_ON
: SQL_AUTOCOMMIT_OFF
) ,SQL_IS_INTEGER
),
337 m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
339 // --------------------------------------------------------------------------------
340 sal_Bool SAL_CALL
OConnection::getAutoCommit( ) throw(SQLException
, RuntimeException
)
342 ::osl::MutexGuard
aGuard( m_aMutex
);
343 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
346 sal_uInt32 nOption
= 0;
347 OTools::ThrowException(this,N3SQLGetConnectAttr(m_aConnectionHandle
,
348 SQL_ATTR_AUTOCOMMIT
, &nOption
,0,0),m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
349 return nOption
== SQL_AUTOCOMMIT_ON
;
351 // --------------------------------------------------------------------------------
352 void SAL_CALL
OConnection::commit( ) throw(SQLException
, RuntimeException
)
354 ::osl::MutexGuard
aGuard( m_aMutex
);
355 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
358 OTools::ThrowException(this,N3SQLEndTran(SQL_HANDLE_DBC
,m_aConnectionHandle
,SQL_COMMIT
),m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
360 // --------------------------------------------------------------------------------
361 void SAL_CALL
OConnection::rollback( ) throw(SQLException
, RuntimeException
)
363 ::osl::MutexGuard
aGuard( m_aMutex
);
364 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
367 OTools::ThrowException(this,N3SQLEndTran(SQL_HANDLE_DBC
,m_aConnectionHandle
,SQL_ROLLBACK
),m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
369 // --------------------------------------------------------------------------------
370 sal_Bool SAL_CALL
OConnection::isClosed( ) throw(SQLException
, RuntimeException
)
372 ::osl::MutexGuard
aGuard( m_aMutex
);
374 return OConnection_BASE::rBHelper
.bDisposed
;
376 // --------------------------------------------------------------------------------
377 Reference
< XDatabaseMetaData
> SAL_CALL
OConnection::getMetaData( ) throw(SQLException
, RuntimeException
)
379 ::osl::MutexGuard
aGuard( m_aMutex
);
380 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
382 Reference
< XDatabaseMetaData
> xMetaData
= m_xMetaData
;
385 xMetaData
= new ODatabaseMetaData(m_aConnectionHandle
,this);
386 m_xMetaData
= xMetaData
;
391 // --------------------------------------------------------------------------------
392 void SAL_CALL
OConnection::setReadOnly( sal_Bool readOnly
) throw(SQLException
, RuntimeException
)
394 ::osl::MutexGuard
aGuard( m_aMutex
);
395 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
398 OTools::ThrowException(this,
399 N3SQLSetConnectAttr(m_aConnectionHandle
,SQL_ATTR_ACCESS_MODE
,reinterpret_cast< SQLPOINTER
>( readOnly
),SQL_IS_INTEGER
),
400 m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
402 // --------------------------------------------------------------------------------
403 sal_Bool SAL_CALL
OConnection::isReadOnly() throw(SQLException
, RuntimeException
)
405 // const member which will initialized only once
408 // --------------------------------------------------------------------------------
409 void SAL_CALL
OConnection::setCatalog( const ::rtl::OUString
& catalog
) throw(SQLException
, RuntimeException
)
411 ::osl::MutexGuard
aGuard( m_aMutex
);
412 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
415 ::rtl::OString
aCat(::rtl::OUStringToOString(catalog
.getStr(),getTextEncoding()));
416 OTools::ThrowException(this,
417 N3SQLSetConnectAttr(m_aConnectionHandle
,SQL_ATTR_CURRENT_CATALOG
,(SDB_ODBC_CHAR
*)aCat
.getStr(),SQL_NTS
),
418 m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
420 // --------------------------------------------------------------------------------
421 ::rtl::OUString SAL_CALL
OConnection::getCatalog( ) throw(SQLException
, RuntimeException
)
423 ::osl::MutexGuard
aGuard( m_aMutex
);
424 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
429 OTools::ThrowException(this,
430 N3SQLGetConnectAttr(m_aConnectionHandle
,SQL_ATTR_CURRENT_CATALOG
,(SDB_ODBC_CHAR
*)pCat
,(sizeof pCat
)-1,&nValueLen
),
431 m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
433 return ::rtl::OUString(pCat
,nValueLen
,getTextEncoding());
435 // --------------------------------------------------------------------------------
436 void SAL_CALL
OConnection::setTransactionIsolation( sal_Int32 level
) throw(SQLException
, RuntimeException
)
438 ::osl::MutexGuard
aGuard( m_aMutex
);
439 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
442 OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle
,
443 SQL_ATTR_TXN_ISOLATION
,
444 (SQLPOINTER
)(sal_IntPtr
)level
,SQL_IS_INTEGER
),
445 m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
447 // --------------------------------------------------------------------------------
448 sal_Int32 SAL_CALL
OConnection::getTransactionIsolation( ) throw(SQLException
, RuntimeException
)
450 ::osl::MutexGuard
aGuard( m_aMutex
);
451 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
455 SQLINTEGER nValueLen
;
456 OTools::ThrowException(this,
457 N3SQLGetConnectAttr(m_aConnectionHandle
,SQL_ATTR_TXN_ISOLATION
,&nTxn
,sizeof nTxn
,&nValueLen
),
458 m_aConnectionHandle
,SQL_HANDLE_DBC
,*this);
461 // --------------------------------------------------------------------------------
462 Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
OConnection::getTypeMap( ) throw(SQLException
, RuntimeException
)
464 ::osl::MutexGuard
aGuard( m_aMutex
);
465 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
470 // --------------------------------------------------------------------------------
471 void SAL_CALL
OConnection::setTypeMap( const Reference
< ::com::sun::star::container::XNameAccess
>& /*typeMap*/ ) throw(SQLException
, RuntimeException
)
473 ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
475 // --------------------------------------------------------------------------------
477 void SAL_CALL
OConnection::close( ) throw(SQLException
, RuntimeException
)
480 ::osl::MutexGuard
aGuard( m_aMutex
);
481 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
486 // --------------------------------------------------------------------------------
488 Any SAL_CALL
OConnection::getWarnings( ) throw(SQLException
, RuntimeException
)
492 // --------------------------------------------------------------------------------
493 void SAL_CALL
OConnection::clearWarnings( ) throw(SQLException
, RuntimeException
)
496 //------------------------------------------------------------------------------
497 void OConnection::disposing()
499 ::osl::MutexGuard
aGuard(m_aMutex
);
501 OConnection_BASE::disposing();
503 for (::std::map
< SQLHANDLE
,OConnection
*>::iterator aConIter
= m_aConnections
.begin();aConIter
!= m_aConnections
.end();++aConIter
)
504 aConIter
->second
->dispose();
506 ::std::map
< SQLHANDLE
,OConnection
*>().swap(m_aConnections
);
509 N3SQLDisconnect(m_aConnectionHandle
);
510 m_bClosed
= sal_True
;
514 // -----------------------------------------------------------------------------
515 OConnection
* OConnection::cloneConnection()
517 return new OConnection(m_pDriverHandleCopy
,m_pDriver
);
519 // -----------------------------------------------------------------------------
520 SQLHANDLE
OConnection::createStatementHandle()
522 OConnection
* pConnectionTemp
= this;
523 sal_Bool bNew
= sal_False
;
526 sal_Int32 nMaxStatements
= getMetaData()->getMaxStatements();
527 if(nMaxStatements
&& nMaxStatements
<= m_nStatementCount
)
529 OConnection
* pConnection
= cloneConnection();
530 pConnection
->acquire();
531 pConnection
->Construct(m_sURL
,getConnectionInfo());
532 pConnectionTemp
= pConnection
;
540 SQLHANDLE aStatementHandle
= SQL_NULL_HANDLE
;
541 SQLRETURN nRetcode
= N3SQLAllocHandle(SQL_HANDLE_STMT
,pConnectionTemp
->getConnection(),&aStatementHandle
);
542 OSL_UNUSED( nRetcode
);
545 m_aConnections
.insert(::std::map
< SQLHANDLE
,OConnection
*>::value_type(aStatementHandle
,pConnectionTemp
));
547 return aStatementHandle
;
550 // -----------------------------------------------------------------------------
551 void OConnection::freeStatementHandle(SQLHANDLE
& _pHandle
)
553 ::std::map
< SQLHANDLE
,OConnection
*>::iterator aFind
= m_aConnections
.find(_pHandle
);
555 N3SQLFreeStmt(_pHandle
,SQL_RESET_PARAMS
);
556 N3SQLFreeStmt(_pHandle
,SQL_UNBIND
);
557 N3SQLFreeStmt(_pHandle
,SQL_CLOSE
);
558 N3SQLFreeHandle(SQL_HANDLE_STMT
,_pHandle
);
560 _pHandle
= SQL_NULL_HANDLE
;
562 if(aFind
!= m_aConnections
.end())
564 aFind
->second
->dispose();
565 m_aConnections
.erase(aFind
);
569 // -----------------------------------------------------------------------------
573 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */