cid#1607171 Data race condition
[LibreOffice.git] / connectivity / source / inc / java / sql / Connection.hxx
blob444d44df51e7cb07c761e0d498f8b6cdfaec0df7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #pragma once
21 #include <java/lang/Object.hxx>
22 #include <TConnection.hxx>
23 #include <connectivity/CommonTools.hxx>
24 #include <AutoRetrievingBase.hxx>
25 #include <java/sql/ConnectionLog.hxx>
26 #include <java/GlobalRef.hxx>
28 #include <com/sun/star/beans/NamedValue.hpp>
30 namespace connectivity
32 class java_sql_Driver;
34 typedef OMetaConnection java_sql_Connection_BASE;
36 class java_sql_Connection : public java_sql_Connection_BASE,
37 public java_lang_Object,
38 public OAutoRetrievingBase
40 css::uno::Reference< css::uno::XComponentContext > m_xContext;
41 const java_sql_Driver* m_pDriver;
42 jobject m_pDriverobject;
43 jdbc::GlobalRef< jobject >
44 m_pDriverClassLoader;
46 jclass m_Driver_theClass;
47 java::sql::ConnectionLog
48 m_aLogger;
49 bool m_bIgnoreDriverPrivileges;
50 bool m_bIgnoreCurrency;
51 css::uno::Any m_aCatalogRestriction;
52 css::uno::Any m_aSchemaRestriction;
54 /** transform named parameter into unnamed one.
55 @param _sSQL
56 The SQL statement to transform.
57 @return
58 The new statement with unnamed parameters.
60 OUString transFormPreparedStatement(const OUString& _sSQL);
61 void loadDriverFromProperties(
62 const OUString& _sDriverClass,
63 const OUString& _sDriverClassPath,
64 const css::uno::Sequence< css::beans::NamedValue >& _rSystemProperties
66 /** load driver class path from system configuration.
67 @param _sDriverClass
68 The driver class name to look for in the configuration.
70 OUString impl_getJavaDriverClassPath_nothrow(const OUString& _sDriverClass);
72 protected:
73 // Static data for the class
74 static jclass theClass;
76 virtual ~java_sql_Connection() override;
78 public:
79 virtual jclass getMyClass() const override;
81 DECLARE_SERVICE_INFO();
82 // A ctor that is needed for returning the object
83 java_sql_Connection( const java_sql_Driver& _rDriver );
84 bool construct( const OUString& url,
85 const css::uno::Sequence< css::beans::PropertyValue >& info);
87 const css::uno::Sequence< css::beans::PropertyValue >&
88 getConnectionInfo() const { return m_aConnectionInfo; }
90 bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges;}
91 bool isIgnoreCurrencyEnabled() const { return m_bIgnoreCurrency; }
92 const css::uno::Any& getCatalogRestriction() const { return m_aCatalogRestriction; }
93 const css::uno::Any& getSchemaRestriction() const { return m_aSchemaRestriction; }
95 /** returns the instance used for logging events related to this connection
97 const java::sql::ConnectionLog& getLogger() const { return m_aLogger; }
99 /** returns the class loader which was used to load the driver class
101 Usually used in conjunction with a ContextClassLoaderScope instance.
103 const jdbc::GlobalRef< jobject >& getDriverClassLoader() const { return m_pDriverClassLoader; }
105 // OComponentHelper
106 virtual void SAL_CALL disposing() override;
108 // XConnection
109 virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override;
110 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override;
111 virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override;
112 virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override;
113 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) override;
114 virtual sal_Bool SAL_CALL getAutoCommit( ) override;
115 virtual void SAL_CALL commit( ) override;
116 virtual void SAL_CALL rollback( ) override;
117 virtual sal_Bool SAL_CALL isClosed( ) override;
118 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override;
119 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) override;
120 virtual sal_Bool SAL_CALL isReadOnly( ) override;
121 virtual void SAL_CALL setCatalog( const OUString& catalog ) override;
122 virtual OUString SAL_CALL getCatalog( ) override;
123 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) override;
124 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) override;
125 virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) override;
126 virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
127 // XCloseable
128 virtual void SAL_CALL close( ) override;
129 // XWarningsSupplier
130 virtual css::uno::Any SAL_CALL getWarnings( ) override;
131 virtual void SAL_CALL clearWarnings( ) override;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */