diff options
Diffstat (limited to 'connectivity/source/inc/java')
32 files changed, 2686 insertions, 0 deletions
diff --git a/connectivity/source/inc/java/ContextClassLoader.hxx b/connectivity/source/inc/java/ContextClassLoader.hxx new file mode 100644 index 000000000..dea3fb58b --- /dev/null +++ b/connectivity/source/inc/java/ContextClassLoader.hxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_CONTEXTCLASSLOADER_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_CONTEXTCLASSLOADER_HXX + +#include <java/GlobalRef.hxx> + +namespace comphelper +{ + class EventLogger; +} + + +namespace connectivity::jdbc +{ + class ContextClassLoaderScope + { + public: + /** creates the instance. If isActive returns <FALSE/> afterwards, then an exception + happened in the JVM, which should be raised as UNO exception by the caller + + @param environment + the current JNI environment + @param newClassLoader + the new class loader to set at the current thread + @param _rLoggerForErrors + the logger which should be passed to java_lang_object::ThrowLoggedSQLException in case + an error occurs + @param _rxErrorContext + the context which should be passed to java_lang_object::ThrowLoggedSQLException in case + an error occurs + + */ + ContextClassLoaderScope( + JNIEnv& environment, + const GlobalRef< jobject >& newClassLoader, + const ::comphelper::EventLogger& _rLoggerForErrors, + const css::uno::Reference< css::uno::XInterface >& _rxErrorContext + ); + + ~ContextClassLoaderScope(); + + bool isActive() const + { + return ( m_currentThread.is() ) + && ( m_setContextClassLoaderMethod != nullptr ); + } + + private: + ContextClassLoaderScope(ContextClassLoaderScope const &) = delete; + ContextClassLoaderScope& operator =(ContextClassLoaderScope const &) = delete; + + JNIEnv& m_environment; + LocalRef< jobject > m_currentThread; + LocalRef< jobject > m_oldContextClassLoader; + jmethodID m_setContextClassLoaderMethod; + }; + + +} // namespace connectivity::jdbc + + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_CONTEXTCLASSLOADER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/GlobalRef.hxx b/connectivity/source/inc/java/GlobalRef.hxx new file mode 100644 index 000000000..80888cb48 --- /dev/null +++ b/connectivity/source/inc/java/GlobalRef.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_GLOBALREF_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_GLOBALREF_HXX + +#include <java/LocalRef.hxx> +#include <java/lang/Object.hxx> + + +namespace connectivity::jdbc +{ + /** helper class to hold a local ref to a JNI object + */ + template< typename T > + class GlobalRef + { + public: + GlobalRef() + :m_object( nullptr ) + { + } + + GlobalRef( const GlobalRef& _source ) + :m_object( nullptr ) + { + *this = _source; + } + + GlobalRef& operator=( const GlobalRef& _source ) + { + if ( &_source == this ) + return *this; + + SDBThreadAttach t; + set( t.env(), _source.get() ); + return *this; + } + + ~GlobalRef() COVERITY_NOEXCEPT_FALSE + { + reset(); + } + + void reset() + { + if ( m_object != nullptr ) + { + SDBThreadAttach t; + t.env().DeleteGlobalRef( m_object ); + m_object = nullptr; + } + } + + void set( JNIEnv& _environment, T _object ) + { + if ( m_object != nullptr ) + _environment.DeleteGlobalRef( m_object ); + m_object = _object; + if ( m_object ) + m_object = static_cast< T >( _environment.NewGlobalRef( m_object ) ); + } + + void set( LocalRef< T >& _object ) + { + set( _object.env(), _object.release() ); + } + + T get() const + { + return m_object; + } + + bool is() const + { + return m_object != nullptr; + } + + private: + T m_object; + }; + + +} // namespace connectivity::jdbc + + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_GLOBALREF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/LocalRef.hxx b/connectivity/source/inc/java/LocalRef.hxx new file mode 100644 index 000000000..5973405ac --- /dev/null +++ b/connectivity/source/inc/java/LocalRef.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LOCALREF_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LOCALREF_HXX + +#include <jni.h> + + +namespace connectivity::jdbc +{ + + /** helper class to hold a local ref to a JNI object + + Note that this class never actually calls NewLocalRef. It is assumed that all objects + passed are already acquired with a local ref (as it usually is the case if you obtain + the object from a JNI method). + */ + template< typename T > + class LocalRef final + { + public: + explicit LocalRef( JNIEnv& environment ) + :m_environment( environment ) + ,m_object( nullptr ) + { + } + + LocalRef( JNIEnv& environment, T object ) + :m_environment( environment ) + ,m_object( object ) + { + } + + ~LocalRef() + { + reset(); + } + + T release() + { + T t = m_object; + m_object = nullptr; + return t; + } + + void set( T object ) { reset(); m_object = object; } + + void reset() + { + if ( m_object != nullptr ) + { + m_environment.DeleteLocalRef( m_object ); + m_object = nullptr; + } + } + + JNIEnv& env() const { return m_environment; } + T get() const { return m_object; } + bool is() const { return m_object != nullptr; } + + private: + LocalRef(LocalRef const &) = delete; + LocalRef& operator =(LocalRef const &) = delete; + + JNIEnv& m_environment; + T m_object; + }; + + +} // namespace connectivity::jdbc + + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LOCALREF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/io/InputStream.hxx b/connectivity/source/inc/java/io/InputStream.hxx new file mode 100644 index 000000000..c05309e87 --- /dev/null +++ b/connectivity/source/inc/java/io/InputStream.hxx @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_IO_INPUTSTREAM_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_IO_INPUTSTREAM_HXX + +#include <java/lang/Object.hxx> +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/io/XInputStream.hpp> + +namespace connectivity +{ + + + //************ Class: java.io.InputStream + + class java_io_InputStream : public java_lang_Object, + public ::cppu::WeakImplHelper< css::io::XInputStream> + { + protected: + // static Data for the Class + static jclass theClass; + virtual ~java_io_InputStream() override; + public: + virtual jclass getMyClass() const override; + // a Constructor, that is needed for when Returning the Object is needed: + java_io_InputStream( JNIEnv * pEnv, jobject myObj ); + // XInputStream + virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) override; + virtual sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) override; + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) override; + virtual sal_Int32 SAL_CALL available( ) override; + virtual void SAL_CALL closeInput( ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_IO_INPUTSTREAM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/io/Reader.hxx b/connectivity/source/inc/java/io/Reader.hxx new file mode 100644 index 000000000..7a2cf0524 --- /dev/null +++ b/connectivity/source/inc/java/io/Reader.hxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_IO_READER_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_IO_READER_HXX + +#include <java/lang/Object.hxx> +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/io/XInputStream.hpp> +#include <optional> + +namespace connectivity +{ + + //************ Class: java.io.InputStream + + class java_io_Reader final : public java_lang_Object, + public ::cppu::WeakImplHelper< css::io::XInputStream> + { + // static Data for the Class + static jclass theClass; + virtual ~java_io_Reader() override; + std::optional<char> m_buf; + public: + virtual jclass getMyClass() const override; + // a Constructor, that is needed for when Returning the Object is needed: + java_io_Reader( JNIEnv * pEnv, jobject myObj ); + // XInputStream + virtual sal_Int32 SAL_CALL readBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) override; + virtual sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) override; + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) override; + virtual sal_Int32 SAL_CALL available( ) override; + virtual void SAL_CALL closeInput( ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_IO_READER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx new file mode 100644 index 000000000..27a7e0668 --- /dev/null +++ b/connectivity/source/inc/java/lang/Boolean.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_BOOLEAN_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_BOOLEAN_HXX + +#include <java/lang/Object.hxx> + +//************ Class: java.lang.Boolean + +namespace connectivity +{ + class java_lang_Boolean : public java_lang_Object + { + protected: + // static Data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_lang_Boolean() override; + // a Constructor, that is needed for when Returning the Object is needed: + java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + static jclass st_getMyClass(); + }; +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_BOOLEAN_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/lang/Class.hxx b/connectivity/source/inc/java/lang/Class.hxx new file mode 100644 index 000000000..bc68a01a5 --- /dev/null +++ b/connectivity/source/inc/java/lang/Class.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_CLASS_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_CLASS_HXX + +//************ Class: java.lang.Class + +#include <java/lang/Object.hxx> + +namespace connectivity +{ + class java_lang_Class : public java_lang_Object + { + protected: + // static Data for the Class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_lang_Class() override; + // a Constructor, that is needed for when Returning the Object is needed: + java_lang_Class( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + static java_lang_Class * forName( const OUString &_par0 ); + // return the jre object + jobject newInstanceObject(); + + }; +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_CLASS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/lang/Exception.hxx b/connectivity/source/inc/java/lang/Exception.hxx new file mode 100644 index 000000000..5e11e7890 --- /dev/null +++ b/connectivity/source/inc/java/lang/Exception.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_EXCEPTION_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_EXCEPTION_HXX + +#include <java/lang/Throwable.hxx> + +namespace connectivity +{ + + + //************ Class: java.lang.Exception + + class java_lang_Exception : public java_lang_Throwable{ + protected: + // statis Data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_lang_Exception() override; + // a Constructor, that is needed for when Returning the Object is needed: + java_lang_Exception( JNIEnv * pEnv, jobject myObj ) : java_lang_Throwable( pEnv, myObj ){} + + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_EXCEPTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/lang/Object.hxx b/connectivity/source/inc/java/lang/Object.hxx new file mode 100644 index 000000000..ba9414008 --- /dev/null +++ b/connectivity/source/inc/java/lang/Object.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_OBJECT_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_OBJECT_HXX + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <jvmaccess/virtualmachine.hxx> + +#ifdef HAVE_64BIT_POINTERS +#error "no 64 bit pointer" +#endif //HAVE_64BIT_POINTERS + +namespace comphelper +{ + class EventLogger; +} + +namespace connectivity +{ + class SDBThreadAttach + { + jvmaccess::VirtualMachine::AttachGuard m_aGuard; + SDBThreadAttach(SDBThreadAttach const &) = delete; + SDBThreadAttach& operator= (SDBThreadAttach const &) = delete; + public: + SDBThreadAttach(); + ~SDBThreadAttach(); + + JNIEnv* pEnv; + static void addRef(); + static void releaseRef(); + + public: + JNIEnv& env() const + { + // according to the documentation of jvmaccess::VirtualMachine::AttachGuard, our env is never + // NULL, so why bothering with pointer checks? + return *pEnv; + } + }; + + + class java_lang_Object + { + java_lang_Object& operator= (java_lang_Object const &) = delete; + java_lang_Object(java_lang_Object const &) = delete; + + protected: + // The Java handle to this class + jobject object; + + // Class definition + // New in SJ2: + static jclass theClass; // The class needs to be requested only once! + + virtual jclass getMyClass() const; + + public: + // Ctor that should be used for the derived classes + java_lang_Object( JNIEnv * pEnv, jobject myObj ); + + // The actual ctor + java_lang_Object(); + + virtual ~java_lang_Object() COVERITY_NOEXCEPT_FALSE; + + void saveRef( JNIEnv * pEnv, jobject myObj ); + jobject getJavaObject() const { return object; } + void clearObject(JNIEnv& rEnv); + void clearObject(); + + OUString toString() const; + + static void ThrowSQLException(JNIEnv * pEnv,const css::uno::Reference< css::uno::XInterface> & _rContext); + static void ThrowLoggedSQLException( + const ::comphelper::EventLogger& _rLogger, + JNIEnv* pEnvironment, + const css::uno::Reference< css::uno::XInterface >& _rxContext + ); + static void ThrowRuntimeException(JNIEnv * pEnv,const css::uno::Reference< css::uno::XInterface> & _rContext); + + static ::rtl::Reference< jvmaccess::VirtualMachine > getVM(const css::uno::Reference< css::uno::XComponentContext >& _rxContext=nullptr); + + static jclass findMyClass(const char* _pClassName); + void obtainMethodId_throwSQL(JNIEnv* _pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID) const; + void obtainMethodId_throwRuntime(JNIEnv* _pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID) const; + + bool callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const; + bool callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + jobject callResultSetMethod( JNIEnv& _rEnv, const char* _pMethodName, jmethodID& _inout_MethodID ) const; + sal_Int32 callIntMethod_ThrowSQL(const char* _pMethodName, jmethodID& _inout_MethodID) const; + sal_Int32 callIntMethod_ThrowRuntime(const char* _pMethodName, jmethodID& _inout_MethodID) const; + sal_Int32 callIntMethodWithIntArg_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + sal_Int32 callIntMethodWithIntArg_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + sal_Int32 callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const OUString& _nArgument ) const; + OUString callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const; + OUString callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const; + void callVoidMethod_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID) const; + void callVoidMethod_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID) const; + void callVoidMethodWithIntArg_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + void callVoidMethodWithIntArg_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const; + void callVoidMethodWithBoolArg_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const; + void callVoidMethodWithBoolArg_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const; + void callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID, const OUString& _nArgument ) const; + jobject callObjectMethod( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID ) const; + jobject callObjectMethodWithIntArg( JNIEnv * pEnv, const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const; + + template< typename T > + T callMethodWithIntArg(T (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) ,const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const + { + SDBThreadAttach t; + obtainMethodId_throwSQL(t.pEnv, _pMethodName,_pSignature, _inout_MethodID); + T out = (t.pEnv->*pCallMethod)( object, _inout_MethodID,_nArgument); + ThrowSQLException( t.pEnv, nullptr ); + return out; + } + + template< typename T > + void callVoidMethod_ThrowSQL(const char* _pMethodName, const char* _pSignature, jmethodID& _inout_MethodID,sal_Int32 _nArgument, const T& _aValue) const + { + SDBThreadAttach t; + obtainMethodId_throwSQL(t.pEnv, _pMethodName,_pSignature, _inout_MethodID); + t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument,_aValue); + ThrowSQLException( t.pEnv, nullptr ); + } + + + }; +} +#endif //_CONNECTIVITY_JAVA_LANG_OBJECT_HXX_ + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/lang/String.hxx b/connectivity/source/inc/java/lang/String.hxx new file mode 100644 index 000000000..25ba03d0d --- /dev/null +++ b/connectivity/source/inc/java/lang/String.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_STRING_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_STRING_HXX + +#include <java/lang/Object.hxx> + +namespace connectivity +{ + class java_lang_String : public java_lang_Object + { + protected: + // statis Data for the Class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_lang_String() override; + // a Constructor, that is needed for when Returning the Object is needed: + java_lang_String( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + operator OUString(); + + static jclass st_getMyClass(); + }; + +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_STRING_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/lang/Throwable.hxx b/connectivity/source/inc/java/lang/Throwable.hxx new file mode 100644 index 000000000..d24395286 --- /dev/null +++ b/connectivity/source/inc/java/lang/Throwable.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_THROWABLE_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_THROWABLE_HXX + +#include <java/lang/Object.hxx> + +namespace connectivity +{ + + //************ Class: java.lang.Throwable + + class java_lang_Throwable : public java_lang_Object + { + protected: + // static Data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_lang_Throwable() override; + // a Constructor, that is needed for when Returning the Object is needed: + java_lang_Throwable( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + OUString getMessage() const; + OUString getLocalizedMessage() const; + +#if OSL_DEBUG_LEVEL > 0 + void printStackTrace() const; +#endif + + static jclass st_getMyClass(); + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_LANG_THROWABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/math/BigDecimal.hxx b/connectivity/source/inc/java/math/BigDecimal.hxx new file mode 100644 index 000000000..e345aeed2 --- /dev/null +++ b/connectivity/source/inc/java/math/BigDecimal.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_MATH_BIGDECIMAL_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_MATH_BIGDECIMAL_HXX + +#include <java/lang/Object.hxx> + +//************ Class: java.lang.Boolean + +namespace connectivity +{ + class java_math_BigDecimal : public java_lang_Object + { + // static Data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_math_BigDecimal() override; + + java_math_BigDecimal( const OUString& _par0 ); + java_math_BigDecimal( const double& _par0 ); + }; +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_MATH_BIGDECIMAL_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/Array.hxx b/connectivity/source/inc/java/sql/Array.hxx new file mode 100644 index 000000000..8677daa47 --- /dev/null +++ b/connectivity/source/inc/java/sql/Array.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_ARRAY_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_ARRAY_HXX + +#include <java/lang/Object.hxx> +#include <com/sun/star/sdbc/XArray.hpp> +#include <cppuhelper/implbase.hxx> + +namespace connectivity +{ + + + //************ Class: java.sql.SQLWarning + + class java_sql_Array : public java_lang_Object, + public ::cppu::WeakImplHelper< css::sdbc::XArray> + { + protected: + // Static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_Array() override; + // A ctor that is needed for returning the object + java_sql_Array( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + + // XArray + virtual OUString SAL_CALL getBaseTypeName( ) override; + virtual sal_Int32 SAL_CALL getBaseType( ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL getArray( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + virtual css::uno::Sequence< css::uno::Any > SAL_CALL getArrayAtIndex( sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSetAtIndex( sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_ARRAY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/Blob.hxx b/connectivity/source/inc/java/sql/Blob.hxx new file mode 100644 index 000000000..605853f60 --- /dev/null +++ b/connectivity/source/inc/java/sql/Blob.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_BLOB_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_BLOB_HXX + +#include <java/lang/Object.hxx> +#include <com/sun/star/sdbc/XBlob.hpp> +#include <cppuhelper/implbase.hxx> + +namespace connectivity +{ + + + //************ Class: java.sql.SQLWarning + + class java_sql_Blob : public java_lang_Object, + public ::cppu::WeakImplHelper< css::sdbc::XBlob> + { + protected: + // Static data for the class + static jclass theClass; + virtual ~java_sql_Blob() override; + public: + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_Blob( JNIEnv * pEnv, jobject myObj ); + + // XBlob + virtual sal_Int64 SAL_CALL length( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int64 pos, sal_Int32 length ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( ) override; + virtual sal_Int64 SAL_CALL position( const css::uno::Sequence< sal_Int8 >& pattern, sal_Int64 start ) override; + virtual sal_Int64 SAL_CALL positionOfBlob( const css::uno::Reference< css::sdbc::XBlob >& pattern, sal_Int64 start ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_BLOB_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/CallableStatement.hxx b/connectivity/source/inc/java/sql/CallableStatement.hxx new file mode 100644 index 000000000..31cafdeed --- /dev/null +++ b/connectivity/source/inc/java/sql/CallableStatement.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CALLABLESTATEMENT_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CALLABLESTATEMENT_HXX + +#include <java/sql/PreparedStatement.hxx> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XOutParameters.hpp> + +namespace connectivity +{ + + + //************ Class: java.sql.CallableStatement + + + class java_sql_CallableStatement : public java_sql_PreparedStatement, + public css::sdbc::XRow, + public css::sdbc::XOutParameters + { + protected: + // Static data for the class + static jclass theClass; + virtual void createStatement(JNIEnv* _pEnv) override; + + virtual ~java_sql_CallableStatement() override; + public: + DECLARE_SERVICE_INFO(); + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_CallableStatement( JNIEnv * pEnv, java_sql_Connection& _rCon, const OUString& sql ); + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XRow + virtual sal_Bool SAL_CALL wasNull( ) override; + virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override; + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override; + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override; + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override; + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override; + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override; + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override; + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override; + virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override; + virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override; + virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override; + virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override; + // XOutParameters + virtual void SAL_CALL registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) override; + virtual void SAL_CALL registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CALLABLESTATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/Clob.hxx b/connectivity/source/inc/java/sql/Clob.hxx new file mode 100644 index 000000000..ecea073fa --- /dev/null +++ b/connectivity/source/inc/java/sql/Clob.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CLOB_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CLOB_HXX + +#include <java/lang/Object.hxx> +#include <com/sun/star/sdbc/XClob.hpp> +#include <cppuhelper/implbase.hxx> + +namespace connectivity +{ + + + //************ Class: java.sql.SQLWarning + + class java_sql_Clob : public java_lang_Object, + public ::cppu::WeakImplHelper< css::sdbc::XClob> + { + protected: + // Static data for the class + static jclass theClass; + virtual ~java_sql_Clob() override; + public: + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_Clob( JNIEnv * pEnv, jobject myObj ); + + // XClob + virtual sal_Int64 SAL_CALL length( ) override; + virtual OUString SAL_CALL getSubString( sal_Int64 pos, sal_Int32 length ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( ) override; + virtual sal_Int64 SAL_CALL position( const OUString& searchstr, sal_Int32 start ) override; + virtual sal_Int64 SAL_CALL positionOfClob( const css::uno::Reference< css::sdbc::XClob >& pattern, sal_Int64 start ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CLOB_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx new file mode 100644 index 000000000..cc453e6e8 --- /dev/null +++ b/connectivity/source/inc/java/sql/Connection.hxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTION_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTION_HXX + +#include <java/lang/Object.hxx> +#include <TConnection.hxx> +#include <connectivity/CommonTools.hxx> +#include <AutoRetrievingBase.hxx> +#include <java/sql/ConnectionLog.hxx> +#include <java/GlobalRef.hxx> + +#include <com/sun/star/beans/NamedValue.hpp> + +namespace connectivity +{ + class java_sql_Driver; + + typedef OMetaConnection java_sql_Connection_BASE; + + class java_sql_Connection : public java_sql_Connection_BASE, + public java_lang_Object, + public OAutoRetrievingBase + { + css::uno::Reference< css::uno::XComponentContext > m_xContext; + const java_sql_Driver* m_pDriver; + jobject m_pDriverobject; + jdbc::GlobalRef< jobject > + m_pDriverClassLoader; + + jclass m_Driver_theClass; + java::sql::ConnectionLog + m_aLogger; + bool m_bIgnoreDriverPrivileges; + bool m_bIgnoreCurrency; + css::uno::Any m_aCatalogRestriction; + css::uno::Any m_aSchemaRestriction; + + /** transform named parameter into unnamed one. + @param _sSQL + The SQL statement to transform. + @return + The new statement with unnamed parameters. + */ + OUString transFormPreparedStatement(const OUString& _sSQL); + void loadDriverFromProperties( + const OUString& _sDriverClass, + const OUString& _sDriverClassPath, + const css::uno::Sequence< css::beans::NamedValue >& _rSystemProperties + ); + /** load driver class path from system configuration. + @param _sDriverClass + The driver class name to look for in the configuration. + */ + OUString impl_getJavaDriverClassPath_nothrow(const OUString& _sDriverClass); + + protected: + // Static data for the class + static jclass theClass; + + virtual ~java_sql_Connection() override; + + public: + virtual jclass getMyClass() const override; + + DECLARE_SERVICE_INFO(); + // A ctor that is needed for returning the object + java_sql_Connection( const java_sql_Driver& _rDriver ); + bool construct( const OUString& url, + const css::uno::Sequence< css::beans::PropertyValue >& info); + + const css::uno::Sequence< css::beans::PropertyValue >& + getConnectionInfo() const { return m_aConnectionInfo; } + + bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges;} + bool isIgnoreCurrencyEnabled() const { return m_bIgnoreCurrency; } + const css::uno::Any& getCatalogRestriction() const { return m_aCatalogRestriction; } + const css::uno::Any& getSchemaRestriction() const { return m_aSchemaRestriction; } + + /** returns the instance used for logging events related to this connection + */ + const java::sql::ConnectionLog& getLogger() const { return m_aLogger; } + + /** returns the class loader which was used to load the driver class + + Usually used in conjunction with a ContextClassLoaderScope instance. + */ + const jdbc::GlobalRef< jobject >& getDriverClassLoader() const { return m_pDriverClassLoader; } + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // XConnection + virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement( ) override; + virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const OUString& sql ) override; + virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall( const OUString& sql ) override; + virtual OUString SAL_CALL nativeSQL( const OUString& sql ) override; + virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) override; + virtual sal_Bool SAL_CALL getAutoCommit( ) override; + virtual void SAL_CALL commit( ) override; + virtual void SAL_CALL rollback( ) override; + virtual sal_Bool SAL_CALL isClosed( ) override; + virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) override; + virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) override; + virtual sal_Bool SAL_CALL isReadOnly( ) override; + virtual void SAL_CALL setCatalog( const OUString& catalog ) override; + virtual OUString SAL_CALL getCatalog( ) override; + virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) override; + virtual sal_Int32 SAL_CALL getTransactionIsolation( ) override; + virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap( ) override; + virtual void SAL_CALL setTypeMap( const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + // XCloseable + virtual void SAL_CALL close( ) override; + // XWarningsSupplier + virtual css::uno::Any SAL_CALL getWarnings( ) override; + virtual void SAL_CALL clearWarnings( ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/ConnectionLog.hxx b/connectivity/source/inc/java/sql/ConnectionLog.hxx new file mode 100644 index 000000000..780b7f27e --- /dev/null +++ b/connectivity/source/inc/java/sql/ConnectionLog.hxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX + +#include <com/sun/star/logging/LogLevel.hpp> + +#include <rtl/ustring.hxx> + +// Strange enough, GCC requires the following forward declarations of the various +// convertLogArgToString flavors to be *before* the inclusion of comphelper/logging.hxx + +namespace com::sun::star::util +{ + struct Date; + struct Time; + struct DateTime; +} + + +namespace comphelper::log::convert +{ + + + // helpers for logging more data types than are defined in comphelper/logging.hxx + OUString convertLogArgToString( const css::util::Date& _rDate ); + OUString convertLogArgToString( const css::util::Time& _rTime ); + OUString convertLogArgToString( const css::util::DateTime& _rDateTime ); + + +} + + +#include <comphelper/logging.hxx> + +namespace connectivity +{ + namespace LogLevel = css::logging::LogLevel; +} + + +namespace connectivity::java::sql { + + typedef ::comphelper::EventLogger ConnectionLog_Base; + class ConnectionLog : public ConnectionLog_Base + { + public: + enum ObjectType + { + CONNECTION = 0, + STATEMENT, + RESULTSET, + + ObjectTypeCount = RESULTSET + 1 + }; + + private: + const sal_Int32 m_nObjectID; + + public: + /// will construct an instance of ObjectType CONNECTION + ConnectionLog( const ::comphelper::EventLogger & _rDriverLog ); + /// will create an instance with the same object ID / ObjectType as a given source instance + ConnectionLog( const ConnectionLog& _rSourceLog ); + /// will create an instance of arbitrary ObjectType + ConnectionLog( const ConnectionLog& _rSourceLog, ObjectType _eType ); + + sal_Int32 getObjectID() const { return m_nObjectID; } + + /// logs a given message, without any arguments, or source class/method names + void log( const sal_Int32 _nLogLevel, const OUString& rMessage ) + { + ConnectionLog_Base::log( _nLogLevel, rMessage, m_nObjectID ); + } + + template< typename ARGTYPE1 > + void log( const sal_Int32 _nLogLevel, const OUString& rMessage, ARGTYPE1 _argument1 ) const + { + ConnectionLog_Base::log( _nLogLevel, rMessage, m_nObjectID, _argument1 ); + } + + template< typename ARGTYPE1, typename ARGTYPE2 > + void log( const sal_Int32 _nLogLevel, const OUString& rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const + { + ConnectionLog_Base::log( _nLogLevel, rMessage, m_nObjectID, _argument1, _argument2 ); + } + + template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 > + void log( const sal_Int32 _nLogLevel, const OUString& rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const + { + ConnectionLog_Base::log( _nLogLevel, rMessage, m_nObjectID, _argument1, _argument2, _argument3 ); + } + + template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 > + void log( const sal_Int32 _nLogLevel, const OUString& rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const + { + ConnectionLog_Base::log( _nLogLevel, rMessage, m_nObjectID, _argument1, _argument2, _argument3, _argument4 ); + } + + template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 > + void log( const sal_Int32 _nLogLevel, const OUString& rMessage, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const + { + ConnectionLog_Base::log( _nLogLevel, rMessage, m_nObjectID, _argument1, _argument2, _argument3, _argument4, _argument5 ); + } + }; + + +} // namespace connectivity::java::sql + + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/DatabaseMetaData.hxx b/connectivity/source/inc/java/sql/DatabaseMetaData.hxx new file mode 100644 index 000000000..d87cd6c21 --- /dev/null +++ b/connectivity/source/inc/java/sql/DatabaseMetaData.hxx @@ -0,0 +1,218 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DATABASEMETADATA_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DATABASEMETADATA_HXX + +#include <java/lang/Object.hxx> +#include <TDatabaseMetaDataBase.hxx> + +#include <java/sql/ConnectionLog.hxx> + +namespace connectivity +{ + class java_sql_Connection; + + //************ Class: java.sql.DatabaseMetaDataDate + + + class java_sql_DatabaseMetaData : public ODatabaseMetaDataBase, + public java_lang_Object + { + java_sql_Connection* m_pConnection; + java::sql::ConnectionLog m_aLogger; + + // Static data for the class + static jclass theClass; + + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_DatabaseMetaData() override; + // A ctor that is needed for returning the object + java_sql_DatabaseMetaData( JNIEnv * pEnv, jobject myObj, java_sql_Connection& _rConnection ); + + private: + + virtual css::uno::Reference< css::sdbc::XResultSet > impl_getTypeInfo_throw() override; + // cached database information + virtual OUString impl_getIdentifierQuoteString_throw( ) override; + virtual bool impl_isCatalogAtStart_throw( ) override; + virtual OUString impl_getCatalogSeparator_throw( ) override; + virtual bool impl_supportsCatalogsInTableDefinitions_throw( ) override; + virtual bool impl_supportsSchemasInTableDefinitions_throw( ) override ; + virtual bool impl_supportsCatalogsInDataManipulation_throw( ) override; + virtual bool impl_supportsSchemasInDataManipulation_throw( ) override ; + virtual bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) override; + virtual bool impl_supportsAlterTableWithAddColumn_throw( ) override; + virtual bool impl_supportsAlterTableWithDropColumn_throw( ) override; + virtual sal_Int32 impl_getMaxStatements_throw( ) override; + virtual sal_Int32 impl_getMaxTablesInSelect_throw( ) override; + virtual bool impl_storesMixedCaseQuotedIdentifiers_throw( ) override; + + virtual sal_Bool SAL_CALL allProceduresAreCallable( ) override; + virtual sal_Bool SAL_CALL allTablesAreSelectable( ) override; + virtual OUString SAL_CALL getURL( ) override; + virtual OUString SAL_CALL getUserName( ) override; + virtual sal_Bool SAL_CALL isReadOnly( ) override; + virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) override; + virtual sal_Bool SAL_CALL nullsAreSortedLow( ) override; + virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) override; + virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) override; + virtual OUString SAL_CALL getDatabaseProductName( ) override; + virtual OUString SAL_CALL getDatabaseProductVersion( ) override; + virtual OUString SAL_CALL getDriverName( ) override; + virtual OUString SAL_CALL getDriverVersion( ) override; + virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) override; + virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) override; + virtual sal_Bool SAL_CALL usesLocalFiles( ) override; + virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) override; + virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) override; + virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) override; + virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) override; + virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) override; + virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) override; + virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) override; + virtual OUString SAL_CALL getSQLKeywords( ) override; + virtual OUString SAL_CALL getNumericFunctions( ) override; + virtual OUString SAL_CALL getStringFunctions( ) override; + virtual OUString SAL_CALL getSystemFunctions( ) override; + virtual OUString SAL_CALL getTimeDateFunctions( ) override; + virtual OUString SAL_CALL getSearchStringEscape( ) override; + virtual OUString SAL_CALL getExtraNameCharacters( ) override; + virtual sal_Bool SAL_CALL supportsColumnAliasing( ) override; + virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) override; + virtual sal_Bool SAL_CALL supportsTypeConversion( ) override; + virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) override; + virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) override; + virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) override; + virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) override; + virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) override; + virtual sal_Bool SAL_CALL supportsGroupBy( ) override; + virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) override; + virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) override; + virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) override; + virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) override; + virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) override; + virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) override; + virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) override; + virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) override; + virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) override; + virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) override; + virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) override; + virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) override; + virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) override; + virtual sal_Bool SAL_CALL supportsOuterJoins( ) override; + virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) override; + virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) override; + virtual OUString SAL_CALL getSchemaTerm( ) override; + virtual OUString SAL_CALL getProcedureTerm( ) override; + virtual OUString SAL_CALL getCatalogTerm( ) override; + virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) override; + virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) override; + virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) override; + virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) override; + virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) override; + virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) override; + virtual sal_Bool SAL_CALL supportsPositionedDelete( ) override; + virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) override; + virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) override; + virtual sal_Bool SAL_CALL supportsStoredProcedures( ) override; + virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) override; + virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) override; + virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) override; + virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) override; + virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) override; + virtual sal_Bool SAL_CALL supportsUnion( ) override; + virtual sal_Bool SAL_CALL supportsUnionAll( ) override; + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) override; + virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) override; + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) override; + virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) override; + virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) override; + virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) override; + virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) override; + virtual sal_Int32 SAL_CALL getMaxConnections( ) override; + virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) override; + virtual sal_Int32 SAL_CALL getMaxIndexLength( ) override; + virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) override; + virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) override; + virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) override; + virtual sal_Int32 SAL_CALL getMaxRowSize( ) override; + virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) override; + virtual sal_Int32 SAL_CALL getMaxStatementLength( ) override; + virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) override; + virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) override; + virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) override; + virtual sal_Bool SAL_CALL supportsTransactions( ) override; + virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) override; + virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) override; + virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) override; + virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) override; + virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedures( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedureColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern, const OUString& columnNamePattern ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTables( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const css::uno::Sequence< OUString >& types ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getSchemas( ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCatalogs( ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTableTypes( ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumns( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const css::uno::Any& catalog, const OUString& schema, const OUString& table, const OUString& columnNamePattern ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTablePrivileges( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope, sal_Bool nullable ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getVersionColumns( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getImportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getExportedKeys( const css::uno::Any& catalog, const OUString& schema, const OUString& table ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCrossReference( const css::uno::Any& primaryCatalog, const OUString& primarySchema, const OUString& primaryTable, const css::uno::Any& foreignCatalog, const OUString& foreignSchema, const OUString& foreignTable ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getIndexInfo( const css::uno::Any& catalog, const OUString& schema, const OUString& table, sal_Bool unique, sal_Bool approximate ) override; + virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) override; + virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) override; + virtual sal_Bool SAL_CALL supportsBatchUpdates( ) override; + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getUDTs( const css::uno::Any& catalog, const OUString& schemaPattern, const OUString& typeNamePattern, const css::uno::Sequence< sal_Int32 >& types ) override; + + private: + bool impl_callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ); + OUString impl_callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ); + sal_Int32 impl_callIntMethod_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID ); + sal_Int32 impl_callIntMethod_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID ); + bool impl_callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ); + css::uno::Reference< css::sdbc::XResultSet > + impl_callResultSetMethod( const char* _pMethodName, jmethodID& _inout_MethodID ); + css::uno::Reference< css::sdbc::XResultSet > + impl_callResultSetMethodWithStrings( const char* _pMethodName, jmethodID& _inout_MethodID, const css::uno::Any& _rCatalog, + const OUString& _rSchemaPattern, const OUString& _rLeastPattern, + const OUString* _pOptionalAdditionalString = nullptr); + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DATABASEMETADATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/Driver.hxx b/connectivity/source/inc/java/sql/Driver.hxx new file mode 100644 index 000000000..f50d9a3f5 --- /dev/null +++ b/connectivity/source/inc/java/sql/Driver.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DRIVER_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DRIVER_HXX + +#include <com/sun/star/sdbc/XDriver.hpp> +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <comphelper/logging.hxx> + +namespace connectivity +{ + /// @throws css::uno::Exception + css::uno::Reference< css::uno::XInterface > java_sql_Driver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory); + + class java_sql_Driver : public ::cppu::WeakImplHelper< css::sdbc::XDriver,css::lang::XServiceInfo> + { + css::uno::Reference<css::uno::XComponentContext> m_aContext; + ::comphelper::EventLogger m_aLogger; + + protected: + virtual ~java_sql_Driver() override; + + public: + java_sql_Driver(const css::uno::Reference< css::uno::XComponentContext >& _rxContext); + + /// @throws css::uno::RuntimeException + static OUString getImplementationName_Static( ); + /// @throws css::uno::RuntimeException + static css::uno::Sequence< OUString > getSupportedServiceNames_Static( ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XDriver + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL connect( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override ; + virtual sal_Bool SAL_CALL acceptsURL( const OUString& url ) override ; + virtual css::uno::Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const OUString& url, const css::uno::Sequence< css::beans::PropertyValue >& info ) override ; + virtual sal_Int32 SAL_CALL getMajorVersion( ) override ; + virtual sal_Int32 SAL_CALL getMinorVersion( ) override; + + const css::uno::Reference<css::uno::XComponentContext>& getContext() const { return m_aContext; } + const ::comphelper::EventLogger& getLogger() const { return m_aLogger; } + }; + +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DRIVER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx b/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx new file mode 100644 index 000000000..b0ab4efda --- /dev/null +++ b/connectivity/source/inc/java/sql/DriverPropertyInfo.hxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DRIVERPROPERTYINFO_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DRIVERPROPERTYINFO_HXX + +#include <java/lang/Object.hxx> + +namespace connectivity +{ + + +//************ Class: java.sql.DriverPropertyInfo + + class java_sql_DriverPropertyInfo : public java_lang_Object + { + protected: + // Static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_DriverPropertyInfo() override; + }; +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_DRIVERPROPERTYINFO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/JStatement.hxx b/connectivity/source/inc/java/sql/JStatement.hxx new file mode 100644 index 000000000..62cbe8154 --- /dev/null +++ b/connectivity/source/inc/java/sql/JStatement.hxx @@ -0,0 +1,236 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX + +#include <java/lang/Object.hxx> +#include <com/sun/star/sdbc/XStatement.hpp> +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#include <com/sun/star/sdbc/XMultipleResults.hpp> +#include <com/sun/star/sdbc/XBatchExecution.hpp> +#include <com/sun/star/sdbc/XCloseable.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/sdbc/XGeneratedResultSet.hpp> +#include <comphelper/proparrhlp.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <connectivity/CommonTools.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <java/sql/Connection.hxx> +#include <java/sql/ConnectionLog.hxx> + +namespace connectivity +{ + + typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement, + css::sdbc::XWarningsSupplier, + css::util::XCancellable, + css::sdbc::XCloseable, + css::sdbc::XGeneratedResultSet, + css::sdbc::XMultipleResults> java_sql_Statement_BASE; + + //************ Class: java.sql.Statement + + class java_sql_Statement_Base : public cppu::BaseMutex, + public java_sql_Statement_BASE, + public java_lang_Object, + public ::cppu::OPropertySetHelper, + public ::comphelper::OPropertyArrayUsageHelper<java_sql_Statement_Base> + + { + + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getQueryTimeOut(); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getMaxFieldSize(); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getMaxRows(); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getResultSetConcurrency(); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getResultSetType(); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getFetchDirection(); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getFetchSize(); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + OUString getCursorName(); + + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setQueryTimeOut(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setMaxFieldSize(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setMaxRows(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setResultSetConcurrency(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setResultSetType(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setFetchDirection(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setFetchSize(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setCursorName(const OUString &_par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setEscapeProcessing(bool _par0); + + protected: + css::uno::Reference< css::sdbc::XStatement> m_xGeneratedStatement; + rtl::Reference<java_sql_Connection> m_pConnection; + java::sql::ConnectionLog m_aLogger; + OUString m_sSqlStatement; + // Properties + sal_Int32 m_nResultSetConcurrency; + sal_Int32 m_nResultSetType; + bool m_bEscapeProcessing; + + + // Static data for the class + static jclass theClass; + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + + virtual void SAL_CALL getFastPropertyValue( + css::uno::Any& rValue, + sal_Int32 nHandle + ) const override; + + virtual void createStatement(JNIEnv* _pEnv) = 0; + + virtual ~java_sql_Statement_Base() override; + + sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID); + sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault); + + public: + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon ); + + sal_Int32 getStatementObjectID() const { return m_aLogger.getObjectID(); } + + // OComponentHelper + virtual void SAL_CALL disposing() override; + // XInterface + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XStatement + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override ; + virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override ; + virtual sal_Bool SAL_CALL execute( const OUString& sql ) override ; + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override ; + // XWarningsSupplier + virtual css::uno::Any SAL_CALL getWarnings( ) override; + virtual void SAL_CALL clearWarnings( ) override; + // XCancellable + virtual void SAL_CALL cancel( ) override; + // XCloseable + virtual void SAL_CALL close( ) override; + // XMultipleResults + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override; + virtual sal_Int32 SAL_CALL getUpdateCount( ) override; + virtual sal_Bool SAL_CALL getMoreResults( ) override; + //XGeneratedResultSet + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) override; + + public: + using ::cppu::OPropertySetHelper::getFastPropertyValue; + }; + + class OStatement_BASE2 : public java_sql_Statement_Base + + { + public: + OStatement_BASE2(JNIEnv * pEnv, java_sql_Connection& _rCon ) : java_sql_Statement_Base( pEnv, _rCon ) {} + + // OComponentHelper + virtual void SAL_CALL disposing() override; + }; + + class java_sql_Statement : public OStatement_BASE2, + public css::sdbc::XBatchExecution, + public css::lang::XServiceInfo + { + protected: + // Static data for the class + static jclass theClass; + + virtual void createStatement(JNIEnv* _pEnv) override; + + virtual ~java_sql_Statement() override; + public: + DECLARE_SERVICE_INFO(); + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_Statement( JNIEnv * pEnv, java_sql_Connection& _rCon ) : OStatement_BASE2( pEnv, _rCon){}; + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + // XBatchExecution + virtual void SAL_CALL addBatch( const OUString& sql ) override; + virtual void SAL_CALL clearBatch( ) override; + virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/PreparedStatement.hxx b/connectivity/source/inc/java/sql/PreparedStatement.hxx new file mode 100644 index 000000000..5bfc08587 --- /dev/null +++ b/connectivity/source/inc/java/sql/PreparedStatement.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_PREPAREDSTATEMENT_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_PREPAREDSTATEMENT_HXX + +#include <java/sql/JStatement.hxx> +#include <com/sun/star/sdbc/XPreparedStatement.hpp> +#include <com/sun/star/sdbc/XParameters.hpp> +#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +namespace connectivity +{ + + //************ Class: java.sql.PreparedStatement + + + class java_sql_PreparedStatement : public OStatement_BASE2, + public css::sdbc::XPreparedStatement, + public css::sdbc::XResultSetMetaDataSupplier, + public css::sdbc::XParameters, + public css::sdbc::XPreparedBatchExecution, + public css::lang::XServiceInfo + { + protected: + // Static data for the class + static jclass theClass; + + virtual void createStatement(JNIEnv* _pEnv) override; + virtual ~java_sql_PreparedStatement() override; + public: + DECLARE_SERVICE_INFO(); + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_PreparedStatement( JNIEnv * pEnv, java_sql_Connection& _rCon,const OUString& sql ); + + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XPreparedStatement + virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( ) override; + virtual sal_Int32 SAL_CALL executeUpdate( ) override; + virtual sal_Bool SAL_CALL execute( ) override; + virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override; + // XParameters + virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) override; + virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) override; + virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) override; + virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) override; + virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) override; + virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) override; + virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) override; + virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) override; + virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) override; + virtual void SAL_CALL setString( sal_Int32 parameterIndex, const OUString& x ) override; + virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 >& x ) override; + virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const css::util::Date& x ) override; + virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const css::util::Time& x ) override; + virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const css::util::DateTime& x ) override; + virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; + virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; + virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const css::uno::Any& x ) override; + virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const css::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) override; + virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef >& x ) override; + virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob >& x ) override; + virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob >& x ) override; + virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray >& x ) override; + virtual void SAL_CALL clearParameters( ) override; + // XPreparedBatchExecution + virtual void SAL_CALL addBatch( ) override; + virtual void SAL_CALL clearBatch( ) override; + virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override; + // XResultSetMetaDataSupplier + virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override; + + public: + using java_sql_Statement_Base::executeQuery; + using java_sql_Statement_Base::executeUpdate; + using java_sql_Statement_Base::execute; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_PREPAREDSTATEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/Ref.hxx b/connectivity/source/inc/java/sql/Ref.hxx new file mode 100644 index 000000000..eb658925f --- /dev/null +++ b/connectivity/source/inc/java/sql/Ref.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_REF_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_REF_HXX + +#include <java/lang/Object.hxx> +#include <com/sun/star/sdbc/XRef.hpp> +#include <cppuhelper/implbase.hxx> + +namespace connectivity +{ + + //************ Class: java.sql.Ref + + class java_sql_Ref : public java_lang_Object, + public ::cppu::WeakImplHelper< css::sdbc::XRef> + { + protected: + // Static data for the class + static jclass theClass; + virtual ~java_sql_Ref() override; + public: + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_Ref( JNIEnv * pEnv, jobject myObj ); + + // XRef + virtual OUString SAL_CALL getBaseTypeName( ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_REF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/ResultSet.hxx b/connectivity/source/inc/java/sql/ResultSet.hxx new file mode 100644 index 000000000..e5e0155ff --- /dev/null +++ b/connectivity/source/inc/java/sql/ResultSet.hxx @@ -0,0 +1,212 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_RESULTSET_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_RESULTSET_HXX + +#include <java/lang/Object.hxx> +#include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/XRow.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <com/sun/star/sdbc/XCloseable.hpp> +#include <com/sun/star/sdbc/XColumnLocate.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/sdbc/XWarningsSupplier.hpp> +#include <com/sun/star/sdbc/XResultSetUpdate.hpp> +#include <com/sun/star/sdbc/XRowUpdate.hpp> +#include <cppuhelper/compbase.hxx> +#include <comphelper/proparrhlp.hxx> +#include <connectivity/CommonTools.hxx> +#include <java/sql/JStatement.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <java/sql/ConnectionLog.hxx> + +namespace connectivity +{ + + /* + ** java_sql_ResultSet + */ + typedef ::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, + css::sdbc::XRow, + css::sdbc::XResultSetMetaDataSupplier, + css::util::XCancellable, + css::sdbc::XWarningsSupplier, + css::sdbc::XResultSetUpdate, + css::sdbc::XRowUpdate, + css::sdbc::XCloseable, + css::sdbc::XColumnLocate, + css::lang::XServiceInfo> java_sql_ResultSet_BASE; + + class java_sql_Connection; + class java_sql_ResultSet : public cppu::BaseMutex, + public java_sql_ResultSet_BASE, + public java_lang_Object, + public ::cppu::OPropertySetHelper, + public ::comphelper::OPropertyArrayUsageHelper<java_sql_ResultSet> + { + css::uno::Reference< css::uno::XInterface> m_xStatement; + java::sql::ConnectionLog m_aLogger; + java_sql_Connection* m_pConnection; + + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getResultSetConcurrency() const; + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getResultSetType() const; + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getFetchDirection() const; + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + sal_Int32 getFetchSize() const; + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + OUString getCursorName() const; + + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setFetchDirection(sal_Int32 _par0); + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + void setFetchSize(sal_Int32 _par0); + protected: + // Static data for the class + static jclass theClass; + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override; + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override; + + virtual sal_Bool SAL_CALL convertFastPropertyValue( + css::uno::Any & rConvertedValue, + css::uno::Any & rOldValue, + sal_Int32 nHandle, + const css::uno::Any& rValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const css::uno::Any& rValue + ) override; + virtual void SAL_CALL getFastPropertyValue( + css::uno::Any& rValue, + sal_Int32 nHandle + ) const override; + virtual ~java_sql_ResultSet() override; + public: + DECLARE_SERVICE_INFO(); + virtual jclass getMyClass() const override; + // A ctor that is needed for returning the object + java_sql_ResultSet( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rParentLogger,java_sql_Connection& _rConnection, + java_sql_Statement_Base* pStmt = nullptr ); + + // ::cppu::OComponentHelper + virtual void SAL_CALL disposing() override; + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + //XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + // XResultSet + virtual sal_Bool SAL_CALL next( ) override; + virtual sal_Bool SAL_CALL isBeforeFirst( ) override; + virtual sal_Bool SAL_CALL isAfterLast( ) override; + virtual sal_Bool SAL_CALL isFirst( ) override; + virtual sal_Bool SAL_CALL isLast( ) override; + virtual void SAL_CALL beforeFirst( ) override; + virtual void SAL_CALL afterLast( ) override; + virtual sal_Bool SAL_CALL first( ) override; + virtual sal_Bool SAL_CALL last( ) override; + virtual sal_Int32 SAL_CALL getRow( ) override; + virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) override; + virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) override; + virtual sal_Bool SAL_CALL previous( ) override; + virtual void SAL_CALL refreshRow( ) override; + virtual sal_Bool SAL_CALL rowUpdated( ) override; + virtual sal_Bool SAL_CALL rowInserted( ) override; + virtual sal_Bool SAL_CALL rowDeleted( ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) override; + // XRow + virtual sal_Bool SAL_CALL wasNull( ) override; + virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override; + virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override; + virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override; + virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override; + virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override; + virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override; + virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override; + virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override; + virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override; + virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override; + virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override; + virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override; + virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override; + virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override; + // XResultSetMetaDataSupplier + virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override; + // XCancellable + virtual void SAL_CALL cancel( ) override; + // XCloseable + virtual void SAL_CALL close( ) override; + // XWarningsSupplier + virtual css::uno::Any SAL_CALL getWarnings( ) override; + virtual void SAL_CALL clearWarnings( ) override; + // XResultSetUpdate + virtual void SAL_CALL insertRow( ) override; + virtual void SAL_CALL updateRow( ) override; + virtual void SAL_CALL deleteRow( ) override; + virtual void SAL_CALL cancelRowUpdates( ) override; + virtual void SAL_CALL moveToInsertRow( ) override; + virtual void SAL_CALL moveToCurrentRow( ) override; + // XRowUpdate + virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) override; + virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) override; + virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) override; + virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) override; + virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) override; + virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) override; + virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) override; + virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) override; + virtual void SAL_CALL updateString( sal_Int32 columnIndex, const OUString& x ) override; + virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 >& x ) override; + virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const css::util::Date& x ) override; + virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const css::util::Time& x ) override; + virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const css::util::DateTime& x ) override; + virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; + virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override; + virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const css::uno::Any& x ) override; + virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const css::uno::Any& x, sal_Int32 scale ) override; + // XColumnLocate + virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) override; + + public: + using ::cppu::OPropertySetHelper::getFastPropertyValue; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_RESULTSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/ResultSetMetaData.hxx b/connectivity/source/inc/java/sql/ResultSetMetaData.hxx new file mode 100644 index 000000000..bc96fdf4b --- /dev/null +++ b/connectivity/source/inc/java/sql/ResultSetMetaData.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_RESULTSETMETADATA_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_RESULTSETMETADATA_HXX + +#include <java/lang/Object.hxx> +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#include <cppuhelper/implbase.hxx> + +namespace connectivity +{ + + //************ Class: java.sql.ResultSetMetaData + + class java_sql_Connection; + class java_sql_ResultSetMetaData final : public ::cppu::WeakImplHelper< css::sdbc::XResultSetMetaData>, + public java_lang_Object + { + java_sql_Connection* m_pConnection; + sal_Int32 m_nColumnCount; + + // Static data for the class + static jclass theClass; + virtual ~java_sql_ResultSetMetaData() override; + public: + virtual jclass getMyClass() const override; + + // A ctor that is needed for returning the object + java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj, java_sql_Connection& _rCon ); + + virtual sal_Int32 SAL_CALL getColumnCount( ) override; + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) override; + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) override; + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) override; + virtual OUString SAL_CALL getColumnLabel( sal_Int32 column ) override; + virtual OUString SAL_CALL getColumnName( sal_Int32 column ) override; + virtual OUString SAL_CALL getSchemaName( sal_Int32 column ) override; + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) override; + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) override; + virtual OUString SAL_CALL getTableName( sal_Int32 column ) override; + virtual OUString SAL_CALL getCatalogName( sal_Int32 column ) override; + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) override; + virtual OUString SAL_CALL getColumnTypeName( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) override; + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) override; + virtual OUString SAL_CALL getColumnServiceName( sal_Int32 column ) override; + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_RESULTSETMETADATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/SQLException.hxx b/connectivity/source/inc/java/sql/SQLException.hxx new file mode 100644 index 000000000..88a147faa --- /dev/null +++ b/connectivity/source/inc/java/sql/SQLException.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_SQLEXCEPTION_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_SQLEXCEPTION_HXX + +#include <java/lang/Exception.hxx> +#include <com/sun/star/sdbc/SQLException.hpp> + +namespace connectivity +{ + //************ Class: java.sql.SQLException + + class java_sql_SQLException_BASE; + class java_sql_SQLException : public css::sdbc::SQLException + { + public: + // A ctor that is needed for returning the object + java_sql_SQLException( const java_sql_SQLException_BASE& _rException,const css::uno::Reference< css::uno::XInterface> & _rContext); + }; + + class java_sql_SQLException_BASE : public java_lang_Exception + { + protected: + // Static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_SQLException_BASE() override; + // A ctor that is needed for returning the object + java_sql_SQLException_BASE( JNIEnv * pEnv, jobject myObj ); + + OUString getSQLState() const; + sal_Int32 getErrorCode() const; + css::sdbc::SQLException getNextException() const; + + static jclass st_getMyClass(); + }; + +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_SQLEXCEPTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/SQLWarning.hxx b/connectivity/source/inc/java/sql/SQLWarning.hxx new file mode 100644 index 000000000..68a83f463 --- /dev/null +++ b/connectivity/source/inc/java/sql/SQLWarning.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_SQLWARNING_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_SQLWARNING_HXX + +#include <java/sql/SQLException.hxx> + +namespace connectivity +{ + //************ Class: java.sql.SQLWarning + + class java_sql_SQLWarning_BASE : public java_sql_SQLException_BASE + { + protected: + // Static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_SQLWarning_BASE() override; + // A ctor that is needed for returning the object + java_sql_SQLWarning_BASE( JNIEnv * pEnv, jobject myObj ) : java_sql_SQLException_BASE( pEnv, myObj ){} + + }; + + class java_sql_SQLWarning : public java_sql_SQLException + { + public: + java_sql_SQLWarning(const java_sql_SQLWarning_BASE& _rW,const css::uno::Reference< css::uno::XInterface> & _rContext) + : java_sql_SQLException(_rW,_rContext) {} + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_SQLWARNING_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx new file mode 100644 index 000000000..0d41d46d6 --- /dev/null +++ b/connectivity/source/inc/java/sql/Timestamp.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_TIMESTAMP_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_TIMESTAMP_HXX + +#include <java/util/Date.hxx> +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/DateTime.hpp> + + +namespace connectivity +{ + + //************ Class: java.sql.Date + + + class java_sql_Date : public java_util_Date + { + protected: + // static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_Date() override; + // A ctor that is needed for returning the object + java_sql_Date( JNIEnv * pEnv, jobject myObj ) : java_util_Date(pEnv,myObj){} + java_sql_Date( const css::util::Date& _rOut ); + + operator css::util::Date(); + static jclass st_getMyClass(); + }; + + + //************ Class: java.sql.Time + + + class java_sql_Time : public java_util_Date + { + protected: + // static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_Time() override; + // A ctor that is needed for returning the object + java_sql_Time( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){} + java_sql_Time( const css::util::Time& _rOut ); + operator css::util::Time(); + static jclass st_getMyClass(); + }; + + + //************ Class: java.sql.Timestamp + + class java_sql_Timestamp : public java_util_Date + { + protected: + // static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_sql_Timestamp() override; + // A ctor that is needed for returning the object + java_sql_Timestamp( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){} + java_sql_Timestamp( const css::util::DateTime& _rOut); + operator css::util::DateTime(); + + static jclass st_getMyClass(); + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_TIMESTAMP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx new file mode 100644 index 000000000..aa7cb20ca --- /dev/null +++ b/connectivity/source/inc/java/tools.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_TOOLS_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_TOOLS_HXX + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.h> + +#include <jni.h> + +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/io/XInputStream.hpp> + + +namespace connectivity +{ + + jstring convertwchar_tToJavaString(JNIEnv *pEnv,const OUString& Temp); + OUString JavaString2String(JNIEnv *pEnv,jstring Str); + class java_util_Properties; + + /// @throws css::sdbc::SQLException + /// @throws css::uno::RuntimeException + std::unique_ptr<java_util_Properties> createStringPropertyArray(const css::uno::Sequence< css::beans::PropertyValue >& info ); + + jobject convertTypeMapToJavaMap(const css::uno::Reference< css::container::XNameAccess > & _rMap); + + /** return if an exception occurred + the exception will be cleared. + @param pEnv + The native java env + */ + bool isExceptionOccurred(JNIEnv *pEnv); + + jobject createByteInputStream(const css::uno::Reference< css::io::XInputStream >& x,sal_Int32 length); + jobject createCharArrayReader(const css::uno::Reference< css::io::XInputStream >& x,sal_Int32 length); +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_TOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/util/Date.hxx b/connectivity/source/inc/java/util/Date.hxx new file mode 100644 index 000000000..9c2e8a3ee --- /dev/null +++ b/connectivity/source/inc/java/util/Date.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_UTIL_DATE_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_UTIL_DATE_HXX + +#include <java/lang/Object.hxx> +//#include <com/sun/star/util/Date.hpp> + +namespace connectivity +{ + + + //************ Class: java.util.Date + + + class java_util_Date : public java_lang_Object + { + protected: + // Static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_util_Date() override; + // A ctor that is needed for returning the object + java_util_Date( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} + }; +} +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_UTIL_DATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/java/util/Property.hxx b/connectivity/source/inc/java/util/Property.hxx new file mode 100644 index 000000000..f7835e5f1 --- /dev/null +++ b/connectivity/source/inc/java/util/Property.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_UTIL_PROPERTY_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_UTIL_PROPERTY_HXX + +#include <java/lang/Object.hxx> + +namespace connectivity +{ + class java_util_Properties : public java_lang_Object + { + protected: + // Static data for the class + static jclass theClass; + public: + virtual jclass getMyClass() const override; + virtual ~java_util_Properties() override; + java_util_Properties( ); + void setProperty(const OUString& key, const OUString& value); + }; +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_UTIL_PROPERTY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |