1*caf5cd79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*caf5cd79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*caf5cd79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*caf5cd79SAndrew Rist * distributed with this work for additional information 6*caf5cd79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*caf5cd79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*caf5cd79SAndrew Rist * "License"); you may not use this file except in compliance 9*caf5cd79SAndrew Rist * with the License. You may obtain a copy of the License at 10*caf5cd79SAndrew Rist * 11*caf5cd79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*caf5cd79SAndrew Rist * 13*caf5cd79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*caf5cd79SAndrew Rist * software distributed under the License is distributed on an 15*caf5cd79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*caf5cd79SAndrew Rist * KIND, either express or implied. See the License for the 17*caf5cd79SAndrew Rist * specific language governing permissions and limitations 18*caf5cd79SAndrew Rist * under the License. 19*caf5cd79SAndrew Rist * 20*caf5cd79SAndrew Rist *************************************************************/ 21*caf5cd79SAndrew Rist 22*caf5cd79SAndrew Rist 23cdf0e10cSrcweir #ifndef _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ 24cdf0e10cSrcweir #define _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "java/lang/Object.hxx" 27cdf0e10cSrcweir #include "TConnection.hxx" 28cdf0e10cSrcweir #include "connectivity/CommonTools.hxx" 29cdf0e10cSrcweir #include "OSubComponent.hxx" 30cdf0e10cSrcweir #include <cppuhelper/weakref.hxx> 31cdf0e10cSrcweir #include "AutoRetrievingBase.hxx" 32cdf0e10cSrcweir #include "java/sql/ConnectionLog.hxx" 33cdf0e10cSrcweir #include "java/LocalRef.hxx" 34cdf0e10cSrcweir #include "java/GlobalRef.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace connectivity 39cdf0e10cSrcweir { 40cdf0e10cSrcweir class java_sql_Driver; 41cdf0e10cSrcweir 42cdf0e10cSrcweir typedef OMetaConnection java_sql_Connection_BASE; 43cdf0e10cSrcweir 44cdf0e10cSrcweir class java_sql_Connection : public java_sql_Connection_BASE, 45cdf0e10cSrcweir public java_lang_Object, 46cdf0e10cSrcweir public OSubComponent<java_sql_Connection, java_sql_Connection_BASE>, 47cdf0e10cSrcweir public OAutoRetrievingBase 48cdf0e10cSrcweir { 49cdf0e10cSrcweir friend class OSubComponent<java_sql_Connection, java_sql_Connection_BASE>; 50cdf0e10cSrcweir const java_sql_Driver* m_pDriver; 51cdf0e10cSrcweir jobject m_pDriverobject; 52cdf0e10cSrcweir jdbc::GlobalRef< jobject > 53cdf0e10cSrcweir m_pDriverClassLoader; 54cdf0e10cSrcweir 55cdf0e10cSrcweir jclass m_Driver_theClass; 56cdf0e10cSrcweir java::sql::ConnectionLog 57cdf0e10cSrcweir m_aLogger; 58cdf0e10cSrcweir sal_Bool m_bParameterSubstitution; 59cdf0e10cSrcweir sal_Bool m_bIgnoreDriverPrivileges; 60cdf0e10cSrcweir sal_Bool m_bIgnoreCurrency; 61cdf0e10cSrcweir ::com::sun::star::uno::Any m_aCatalogRestriction; 62cdf0e10cSrcweir ::com::sun::star::uno::Any m_aSchemaRestriction; 63cdf0e10cSrcweir 64cdf0e10cSrcweir /** transform named parameter into unnamed one. 65cdf0e10cSrcweir @param _sSQL 66cdf0e10cSrcweir The SQL statement to transform. 67cdf0e10cSrcweir @return 68cdf0e10cSrcweir The new statement witgh unnamed parameters. 69cdf0e10cSrcweir */ 70cdf0e10cSrcweir ::rtl::OUString transFormPreparedStatement(const ::rtl::OUString& _sSQL); 71cdf0e10cSrcweir void loadDriverFromProperties( 72cdf0e10cSrcweir const ::rtl::OUString& _sDriverClass, 73cdf0e10cSrcweir const ::rtl::OUString& _sDriverClassPath, 74cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rSystemProperties 75cdf0e10cSrcweir ); 76cdf0e10cSrcweir /** load driver class path from system configuration. 77cdf0e10cSrcweir @param _sDriverClass 78cdf0e10cSrcweir The driver class name to look for in the configuration. 79cdf0e10cSrcweir */ 80cdf0e10cSrcweir ::rtl::OUString impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass); 81cdf0e10cSrcweir 82cdf0e10cSrcweir protected: 83cdf0e10cSrcweir // statische Daten fuer die Klasse 84cdf0e10cSrcweir static jclass theClass; 85cdf0e10cSrcweir 86cdf0e10cSrcweir virtual ~java_sql_Connection(); 87cdf0e10cSrcweir 88cdf0e10cSrcweir public: 89cdf0e10cSrcweir virtual jclass getMyClass() const; 90cdf0e10cSrcweir 91cdf0e10cSrcweir DECLARE_SERVICE_INFO(); 92cdf0e10cSrcweir // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: 93cdf0e10cSrcweir java_sql_Connection( const java_sql_Driver& _rDriver ); 94cdf0e10cSrcweir sal_Bool construct( const ::rtl::OUString& url, 95cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info); 96cdf0e10cSrcweir 97cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& getConnectionInfo() const98cdf0e10cSrcweir getConnectionInfo() const { return m_aConnectionInfo; } 99cdf0e10cSrcweir isIgnoreDriverPrivilegesEnabled() const100cdf0e10cSrcweir inline sal_Bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges;} isIgnoreCurrencyEnabled() const101cdf0e10cSrcweir inline sal_Bool isIgnoreCurrencyEnabled() const { return m_bIgnoreCurrency; } getCatalogRestriction() const102cdf0e10cSrcweir inline const ::com::sun::star::uno::Any& getCatalogRestriction() const { return m_aCatalogRestriction; } getSchemaRestriction() const103cdf0e10cSrcweir inline const ::com::sun::star::uno::Any& getSchemaRestriction() const { return m_aSchemaRestriction; } 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** returns the instance used for logging events related to this connection 106cdf0e10cSrcweir */ getLogger() const107cdf0e10cSrcweir const java::sql::ConnectionLog& getLogger() const { return m_aLogger; } 108cdf0e10cSrcweir 109cdf0e10cSrcweir /** returns the class loader which was used to load the driver class 110cdf0e10cSrcweir 111cdf0e10cSrcweir Usually used in conjunction with a ContextClassLoaderScope instance. 112cdf0e10cSrcweir */ getDriverClassLoader() const113cdf0e10cSrcweir const jdbc::GlobalRef< jobject >& getDriverClassLoader() const { return m_pDriverClassLoader; } 114cdf0e10cSrcweir 115cdf0e10cSrcweir // OComponentHelper 116cdf0e10cSrcweir virtual void SAL_CALL disposing(void); 117cdf0e10cSrcweir // XInterface 118cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 119cdf0e10cSrcweir 120cdf0e10cSrcweir // XConnection 121cdf0e10cSrcweir 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); 122cdf0e10cSrcweir 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); 123cdf0e10cSrcweir 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); 124cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 125cdf0e10cSrcweir virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 126cdf0e10cSrcweir virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 128cdf0e10cSrcweir virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 129cdf0e10cSrcweir virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 130cdf0e10cSrcweir 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); 131cdf0e10cSrcweir virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 132cdf0e10cSrcweir virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 133cdf0e10cSrcweir virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 134cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 135cdf0e10cSrcweir virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 136cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 137cdf0e10cSrcweir 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); 138cdf0e10cSrcweir 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); 139cdf0e10cSrcweir // XCloseable 140cdf0e10cSrcweir virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 141cdf0e10cSrcweir // XWarningsSupplier 142cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 143cdf0e10cSrcweir virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 144cdf0e10cSrcweir }; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir #endif // _CONNECTIVITY_JAVA_SQL_CONNECTION_HXX_ 147cdf0e10cSrcweir 148