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 "TConnection.hxx"
30 #include <cppuhelper/typeprovider.hxx>
31 #include <comphelper/types.hxx>
32 #include <comphelper/officeresourcebundle.hxx>
33 #include <connectivity/dbexception.hxx>
35 using namespace connectivity
;
36 using namespace com::sun::star::uno
;
37 using namespace com::sun::star::lang
;
38 using namespace com::sun::star::sdbc
;
39 using namespace com::sun::star::beans
;
40 using namespace ::osl
;
42 //------------------------------------------------------------------------------
43 OMetaConnection::OMetaConnection()
44 : OMetaConnection_BASE(m_aMutex
)
45 , m_nTextEncoding(RTL_TEXTENCODING_MS_1252
)
48 //------------------------------------------------------------------------------
49 void OMetaConnection::disposing()
51 ::osl::MutexGuard
aGuard(m_aMutex
);
52 m_xMetaData
= WeakReference
< XDatabaseMetaData
>();
53 for (OWeakRefArray::iterator i
= m_aStatements
.begin(); m_aStatements
.end() != i
; ++i
)
57 Reference
< XInterface
> xStatement( i
->get() );
58 ::comphelper::disposeComponent( xStatement
);
60 catch (const DisposedException
&)
64 m_aStatements
.clear();
67 sal_Int64 SAL_CALL
OMetaConnection::getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw (::com::sun::star::uno::RuntimeException
)
69 return (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
70 ? reinterpret_cast< sal_Int64
>( this )
73 // -----------------------------------------------------------------------------
74 Sequence
< sal_Int8
> OMetaConnection::getUnoTunnelImplementationId()
76 static ::cppu::OImplementationId
* pId
= 0;
79 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
82 static ::cppu::OImplementationId aId
;
86 return pId
->getImplementationId();
88 // -----------------------------------------------------------------------------
89 ::dbtools::OPropertyMap
& OMetaConnection::getPropMap()
91 static ::dbtools::OPropertyMap s_aPropertyNameMap
;
92 return s_aPropertyNameMap
;
94 // -----------------------------------------------------------------------------
95 void OMetaConnection::throwGenericSQLException( sal_uInt16 _nErrorResourceId
,const Reference
< XInterface
>& _xContext
)
97 ::rtl::OUString sErrorMessage
;
98 if ( _nErrorResourceId
)
99 sErrorMessage
= m_aResources
.getResourceString( _nErrorResourceId
);
100 Reference
< XInterface
> xContext
= _xContext
;
101 if ( !xContext
.is() )
103 ::dbtools::throwGenericSQLException( sErrorMessage
, xContext
);
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */