1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "SharedConnection.hxx"
21 #include <tools/debug.hxx>
22 #include <comphelper/uno3.hxx>
26 using namespace ::com::sun::star::uno
;
27 using namespace ::com::sun::star::lang
;
28 using namespace ::com::sun::star::sdbc
;
29 using namespace ::com::sun::star::container
;
30 using namespace connectivity
;
32 OSharedConnection::OSharedConnection(Reference
< XAggregation
>& _rxProxyConnection
)
33 : OSharedConnection_BASE(m_aMutex
)
35 setDelegation(_rxProxyConnection
,m_refCount
);
38 OSharedConnection::~OSharedConnection()
42 void SAL_CALL
OSharedConnection::disposing()
44 OSharedConnection_BASE::disposing();
45 OConnectionWrapper::disposing();
48 Reference
< XStatement
> SAL_CALL
OSharedConnection::createStatement( ) throw(SQLException
, RuntimeException
, std::exception
)
50 ::osl::MutexGuard
aGuard( m_aMutex
);
51 checkDisposed(rBHelper
.bDisposed
);
53 return m_xConnection
->createStatement();
56 Reference
< XPreparedStatement
> SAL_CALL
OSharedConnection::prepareStatement( const OUString
& sql
) throw(SQLException
, RuntimeException
, std::exception
)
58 ::osl::MutexGuard
aGuard( m_aMutex
);
59 checkDisposed(rBHelper
.bDisposed
);
61 return m_xConnection
->prepareStatement(sql
);
64 Reference
< XPreparedStatement
> SAL_CALL
OSharedConnection::prepareCall( const OUString
& sql
) throw(SQLException
, RuntimeException
, std::exception
)
66 ::osl::MutexGuard
aGuard( m_aMutex
);
67 checkDisposed(rBHelper
.bDisposed
);
69 return m_xConnection
->prepareCall(sql
);
72 OUString SAL_CALL
OSharedConnection::nativeSQL( const OUString
& sql
) throw(SQLException
, RuntimeException
, std::exception
)
74 ::osl::MutexGuard
aGuard( m_aMutex
);
75 checkDisposed(rBHelper
.bDisposed
);
77 return m_xConnection
->nativeSQL(sql
);
80 sal_Bool SAL_CALL
OSharedConnection::getAutoCommit( ) throw(SQLException
, RuntimeException
, std::exception
)
82 ::osl::MutexGuard
aGuard( m_aMutex
);
83 checkDisposed(rBHelper
.bDisposed
);
85 return m_xConnection
->getAutoCommit();
88 void SAL_CALL
OSharedConnection::commit( ) throw(SQLException
, RuntimeException
, std::exception
)
90 ::osl::MutexGuard
aGuard( m_aMutex
);
91 checkDisposed(rBHelper
.bDisposed
);
93 m_xConnection
->commit();
96 void SAL_CALL
OSharedConnection::rollback( ) throw(SQLException
, RuntimeException
, std::exception
)
98 ::osl::MutexGuard
aGuard( m_aMutex
);
99 checkDisposed(rBHelper
.bDisposed
);
101 m_xConnection
->rollback();
104 sal_Bool SAL_CALL
OSharedConnection::isClosed( ) throw(SQLException
, RuntimeException
, std::exception
)
106 ::osl::MutexGuard
aGuard( m_aMutex
);
107 if ( !m_xConnection
.is() )
110 return m_xConnection
->isClosed();
113 Reference
< XDatabaseMetaData
> SAL_CALL
OSharedConnection::getMetaData( ) throw(SQLException
, RuntimeException
, std::exception
)
115 ::osl::MutexGuard
aGuard( m_aMutex
);
116 checkDisposed(rBHelper
.bDisposed
);
119 return m_xConnection
->getMetaData();
122 sal_Bool SAL_CALL
OSharedConnection::isReadOnly( ) throw(SQLException
, RuntimeException
, std::exception
)
124 ::osl::MutexGuard
aGuard( m_aMutex
);
125 checkDisposed(rBHelper
.bDisposed
);
127 return m_xConnection
->isReadOnly();
130 OUString SAL_CALL
OSharedConnection::getCatalog( ) throw(SQLException
, RuntimeException
, std::exception
)
132 ::osl::MutexGuard
aGuard( m_aMutex
);
133 checkDisposed(rBHelper
.bDisposed
);
135 return m_xConnection
->getCatalog();
138 sal_Int32 SAL_CALL
OSharedConnection::getTransactionIsolation( ) throw(SQLException
, RuntimeException
, std::exception
)
140 ::osl::MutexGuard
aGuard( m_aMutex
);
141 checkDisposed(rBHelper
.bDisposed
);
143 return m_xConnection
->getTransactionIsolation();
146 Reference
< ::com::sun::star::container::XNameAccess
> SAL_CALL
OSharedConnection::getTypeMap( ) throw(SQLException
, RuntimeException
, std::exception
)
148 ::osl::MutexGuard
aGuard( m_aMutex
);
149 checkDisposed(rBHelper
.bDisposed
);
151 return m_xConnection
->getTypeMap();
154 IMPLEMENT_GET_IMPLEMENTATION_ID( OSharedConnection
)
156 } // namespace dbaccess
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */