Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : : #ifndef _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_
20 : : #define _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_
21 : :
22 : : #include "java/lang/Object.hxx"
23 : : #include "TConnection.hxx"
24 : : #include "connectivity/CommonTools.hxx"
25 : : #include "connectivity/OSubComponent.hxx"
26 : : #include <cppuhelper/weakref.hxx>
27 : : #include "AutoRetrievingBase.hxx"
28 : : #include "java/sql/ConnectionLog.hxx"
29 : : #include "java/LocalRef.hxx"
30 : : #include "java/GlobalRef.hxx"
31 : :
32 : : #include <com/sun/star/beans/NamedValue.hpp>
33 : :
34 : : namespace connectivity
35 : : {
36 : : class java_sql_Driver;
37 : :
38 : : typedef OMetaConnection java_sql_Connection_BASE;
39 : :
40 : : class java_sql_Connection : public java_sql_Connection_BASE,
41 : : public java_lang_Object,
42 : : public OSubComponent<java_sql_Connection, java_sql_Connection_BASE>,
43 : : public OAutoRetrievingBase
44 : : {
45 : : friend class OSubComponent<java_sql_Connection, java_sql_Connection_BASE>;
46 : : const java_sql_Driver* m_pDriver;
47 : : jobject m_pDriverobject;
48 : : jdbc::GlobalRef< jobject >
49 : : m_pDriverClassLoader;
50 : :
51 : : jclass m_Driver_theClass;
52 : : java::sql::ConnectionLog
53 : : m_aLogger;
54 : : sal_Bool m_bParameterSubstitution;
55 : : sal_Bool m_bIgnoreDriverPrivileges;
56 : : sal_Bool m_bIgnoreCurrency;
57 : : ::com::sun::star::uno::Any m_aCatalogRestriction;
58 : : ::com::sun::star::uno::Any m_aSchemaRestriction;
59 : :
60 : : /** transform named parameter into unnamed one.
61 : : @param _sSQL
62 : : The SQL statement to transform.
63 : : @return
64 : : The new statement witgh unnamed parameters.
65 : : */
66 : : ::rtl::OUString transFormPreparedStatement(const ::rtl::OUString& _sSQL);
67 : : void loadDriverFromProperties(
68 : : const ::rtl::OUString& _sDriverClass,
69 : : const ::rtl::OUString& _sDriverClassPath,
70 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rSystemProperties
71 : : );
72 : : /** load driver class path from system configuration.
73 : : @param _sDriverClass
74 : : The driver class name to look for in the configuration.
75 : : */
76 : : ::rtl::OUString impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass);
77 : :
78 : : protected:
79 : : // Static data for the class
80 : : static jclass theClass;
81 : :
82 : : virtual ~java_sql_Connection();
83 : :
84 : : public:
85 : : virtual jclass getMyClass() const;
86 : :
87 : : DECLARE_SERVICE_INFO();
88 : : // A ctor that is needed for returning the object
89 : : java_sql_Connection( const java_sql_Driver& _rDriver );
90 : : sal_Bool construct( const ::rtl::OUString& url,
91 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info);
92 : :
93 : : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
94 : 0 : getConnectionInfo() const { return m_aConnectionInfo; }
95 : :
96 : 0 : inline sal_Bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges;}
97 : 0 : inline sal_Bool isIgnoreCurrencyEnabled() const { return m_bIgnoreCurrency; }
98 : 0 : inline const ::com::sun::star::uno::Any& getCatalogRestriction() const { return m_aCatalogRestriction; }
99 : 0 : inline const ::com::sun::star::uno::Any& getSchemaRestriction() const { return m_aSchemaRestriction; }
100 : :
101 : : /** returns the instance used for logging events related to this connection
102 : : */
103 : 0 : const java::sql::ConnectionLog& getLogger() const { return m_aLogger; }
104 : :
105 : : /** returns the class loader which was used to load the driver class
106 : :
107 : : Usually used in conjunction with a ContextClassLoaderScope instance.
108 : : */
109 : 0 : const jdbc::GlobalRef< jobject >& getDriverClassLoader() const { return m_pDriverClassLoader; }
110 : :
111 : : // OComponentHelper
112 : : virtual void SAL_CALL disposing(void);
113 : : // XInterface
114 : : virtual void SAL_CALL release() throw();
115 : :
116 : : // XConnection
117 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
119 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
120 : : virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121 : : virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
122 : : virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123 : : virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124 : : virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125 : : virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
126 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
127 : : virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
128 : : virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
129 : : virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
130 : : virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
131 : : virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
132 : : virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
133 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
134 : : virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
135 : : // XCloseable
136 : : virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
137 : : // XWarningsSupplier
138 : : virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
139 : : virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
140 : : };
141 : : }
142 : : #endif // _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_
143 : :
144 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|