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 .
23 #include "mysqlc_subcomponent.hxx"
24 #include "mysqlc_types.hxx"
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XUnoTunnel.hpp>
30 #include <com/sun/star/sdbc/ColumnSearch.hpp>
31 #include <com/sun/star/sdbc/ColumnValue.hpp>
32 #include <com/sun/star/sdbc/DataType.hpp>
33 #include <com/sun/star/sdbc/SQLWarning.hpp>
34 #include <com/sun/star/sdbc/XConnection.hpp>
35 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
36 #include <com/sun/star/util/XStringSubstitution.hpp>
38 #include <cppuhelper/compbase3.hxx>
39 #include <cppuhelper/weakref.hxx>
40 #include <rtl/string.hxx>
41 #include <rtl/ref.hxx>
52 namespace connectivity
54 class OMetaConnection
;
55 class ODatabaseMetaData
;
59 using ::com::sun::star::sdbc::SQLException
;
60 using ::com::sun::star::sdbc::SQLWarning
;
61 using ::com::sun::star::uno::RuntimeException
;
63 typedef ::cppu::WeakComponentImplHelper3
<css::sdbc::XConnection
, css::sdbc::XWarningsSupplier
,
64 css::lang::XServiceInfo
>
67 struct ConnectionSettings
69 rtl_TextEncoding encoding
;
70 OUString connectionURL
;
73 : encoding(RTL_TEXTENCODING_DONTKNOW
)
81 typedef OMetaConnection_BASE OConnection_BASE
;
83 typedef std::vector
<css::uno::WeakReferenceHelper
> OWeakRefArray
;
85 class OConnection final
: public OBase_Mutex
, public OConnection_BASE
89 ConnectionSettings m_settings
;
90 css::uno::Reference
<css::container::XNameAccess
> m_typeMap
;
91 css::uno::Reference
<css::util::XStringSubstitution
> m_xParameterSubstitution
;
95 css::uno::WeakReference
<css::sdbc::XDatabaseMetaData
> m_xMetaData
;
97 OWeakRefArray m_aStatements
; // vector containing a list
98 // of all the Statement objects
99 // for this Connection
101 rtl::Reference
<MysqlCDriver
> m_xDriver
; // Pointer to the owning driver object
103 MYSQL
* getMysqlConnection() { return &m_mysql
; }
105 /// @throws SQLException
106 /// @throws RuntimeException
107 sal_Int32
getMysqlVersion();
109 /// @throws SQLException
110 void construct(const OUString
& url
, const css::uno::Sequence
<css::beans::PropertyValue
>& info
);
112 OConnection(MysqlCDriver
& _rDriver
);
113 virtual ~OConnection() override
;
115 rtl_TextEncoding
getConnectionEncoding() const { return m_settings
.encoding
; }
118 virtual void SAL_CALL
disposing() override
;
121 virtual OUString SAL_CALL
getImplementationName() override
;
123 virtual sal_Bool SAL_CALL
supportsService(OUString
const& ServiceName
) override
;
125 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
128 css::uno::Reference
<css::sdbc::XStatement
> SAL_CALL
createStatement() override
;
130 css::uno::Reference
<css::sdbc::XPreparedStatement
>
131 SAL_CALL
prepareStatement(const OUString
& sql
) override
;
133 css::uno::Reference
<css::sdbc::XPreparedStatement
>
134 SAL_CALL
prepareCall(const OUString
& sql
) override
;
136 OUString SAL_CALL
nativeSQL(const OUString
& sql
) override
;
138 void SAL_CALL
setAutoCommit(sal_Bool autoCommit
) override
;
140 sal_Bool SAL_CALL
getAutoCommit() override
;
142 void SAL_CALL
commit() override
;
144 void SAL_CALL
rollback() override
;
146 sal_Bool SAL_CALL
isClosed() override
;
148 css::uno::Reference
<css::sdbc::XDatabaseMetaData
> SAL_CALL
getMetaData() override
;
150 void SAL_CALL
setReadOnly(sal_Bool readOnly
) override
;
152 sal_Bool SAL_CALL
isReadOnly() override
;
154 void SAL_CALL
setCatalog(const OUString
& catalog
) override
;
156 OUString SAL_CALL
getCatalog() override
;
158 void SAL_CALL
setTransactionIsolation(sal_Int32 level
) override
;
160 sal_Int32 SAL_CALL
getTransactionIsolation() override
;
162 css::uno::Reference
<css::container::XNameAccess
> SAL_CALL
getTypeMap() override
;
165 setTypeMap(const css::uno::Reference
<css::container::XNameAccess
>& typeMap
) override
;
167 void SAL_CALL
close() override
;
169 css::uno::Any SAL_CALL
getWarnings() override
;
170 void SAL_CALL
clearWarnings() override
;
173 //sal_Int32 sdbcColumnType(OUString typeName);
174 const ConnectionSettings
& getConnectionSettings() const { return m_settings
; }
175 OUString
transFormPreparedStatement(const OUString
& _sSQL
);
177 const MysqlCDriver
& getDriver() const { return *m_xDriver
; }
181 //inline OUString getPattern(OUString p) { return (p.getLength()) ? p : ASC2OU("%"); }
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */