diff options
Diffstat (limited to 'connectivity/source/drivers/jdbc')
36 files changed, 0 insertions, 9115 deletions
diff --git a/connectivity/source/drivers/jdbc/Array.cxx b/connectivity/source/drivers/jdbc/Array.cxx deleted file mode 100644 index 77b2492b9f..0000000000 --- a/connectivity/source/drivers/jdbc/Array.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/Array.hxx" -#include "java/tools.hxx" -#include "java/sql/ResultSet.hxx" - -using namespace connectivity; -//************************************************************** -//************ Class: java.sql.Array -//************************************************************** - -jclass java_sql_Array::theClass = 0; - -java_sql_Array::~java_sql_Array() -{} - -jclass java_sql_Array::getMyClass() const -{ - // the class must be fetched once, therefore its static - if( !theClass ) - theClass = findMyClass("java/sql/Array"); - - return theClass; -} - -::rtl::OUString SAL_CALL java_sql_Array::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - return callStringMethod("getBaseTypeName",mID); -} - -sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - return callIntMethod("getBaseType",mID); -} - -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArray( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); - static const char * cSignature = "(Ljava/util/Map;)[Ljava/lang/Object;"; - static const char * cMethodName = "getArray"; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - // submit Java-Call - (jobjectArray)t.pEnv->CallObjectMethod( object, mID, obj); - ThrowSQLException(t.pEnv,*this); - // and clean up - t.pEnv->DeleteLocalRef(obj); - } //t.pEnv - return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >(); -} - -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArrayAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); - static const char * cSignature = "(IILjava/util/Map;)[Ljava/lang/Object;"; - static const char * cMethodName = "getArray"; - // submit Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - (jobjectArray)t.pEnv->CallObjectMethod( object, mID, index,count,obj); - ThrowSQLException(t.pEnv,*this); - // and clean up - t.pEnv->DeleteLocalRef(obj); - } - return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >(); -} - -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSet( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - // convert Parameter - jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); - // initialize temporary variable - static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;"; - static const char * cMethodName = "getResultSet"; - // submit Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - t.pEnv->CallObjectMethod( object, mID, obj); - ThrowSQLException(t.pEnv,*this); - // and cleanup - t.pEnv->DeleteLocalRef(obj); - } - return NULL; -} - -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSetAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - // convert parameter - jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap); - // initialize temporary variable - static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;"; - static const char * cMethodName = "getResultSetAtIndex"; - // Java-Call absetzen - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - t.pEnv->CallObjectMethod( object, mID, index,count,obj); - ThrowSQLException(t.pEnv,*this); - // and cleanup - t.pEnv->DeleteLocalRef(obj); - } - return NULL; -} - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Blob.cxx b/connectivity/source/drivers/jdbc/Blob.cxx deleted file mode 100644 index a0d9fd73a8..0000000000 --- a/connectivity/source/drivers/jdbc/Blob.cxx +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/Blob.hxx" -#include "java/tools.hxx" -#include "java/io/InputStream.hxx" -#include <connectivity/dbexception.hxx> - -#include <string.h> - -using namespace connectivity; -//************************************************************** -//************ Class: java.sql.Blob -//************************************************************** - -jclass java_sql_Blob::theClass = 0; -java_sql_Blob::java_sql_Blob( JNIEnv * pEnv, jobject myObj ) - : java_lang_Object( pEnv, myObj ) -{ - SDBThreadAttach::addRef(); -} -java_sql_Blob::~java_sql_Blob() -{ - SDBThreadAttach::releaseRef(); -} - -jclass java_sql_Blob::getMyClass() const -{ - // the class must be fetched only once, therefore it's static - if( !theClass ) - theClass = findMyClass("java/sql/Blob"); - return theClass; -} - -sal_Int64 SAL_CALL java_sql_Blob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - jlong out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - // initialize temporary variable - static const char * cSignature = "()J"; - static const char * cMethodName = "length"; - // submit Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallLongMethod( object, mID ); - ThrowSQLException(t.pEnv,*this); - } //t.pEnv - return (sal_Int64)out; -} -::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL java_sql_Blob::getBytes( sal_Int64 pos, sal_Int32 count ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - ::com::sun::star::uno::Sequence< sal_Int8 > aSeq; - { - // initialize temporary variable - static const char * cSignature = "(JI)[B"; - static const char * cMethodName = "getBytes"; - // submit Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jbyteArray out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID,pos,count); - ThrowSQLException(t.pEnv,*this); - if(out) - { - jboolean p = sal_False; - aSeq.realloc(t.pEnv->GetArrayLength(out)); - memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength()); - t.pEnv->DeleteLocalRef(out); - } - } //t.pEnv - // WARNING: the caller becomes the owner of the returned pointer - return aSeq; -} - -::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Blob::getBinaryStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getBinaryStream","()Ljava/io/InputStream;", mID); - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_io_InputStream( t.pEnv, out ); -} - -sal_Int64 SAL_CALL java_sql_Blob::position( const ::com::sun::star::uno::Sequence< sal_Int8 >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - jlong out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - // initialize temporary variable - static const char * cSignature = "([BI)J"; - static const char * cMethodName = "position"; - // submit Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - // convert Parameter - jbyteArray pByteArray = t.pEnv->NewByteArray(pattern.getLength()); - t.pEnv->SetByteArrayRegion(pByteArray,0,pattern.getLength(),(jbyte*)pattern.getConstArray()); - out = t.pEnv->CallLongMethod( object, mID, pByteArray,start ); - t.pEnv->DeleteLocalRef(pByteArray); - ThrowSQLException(t.pEnv,*this); - } //t.pEnv - return (sal_Int64)out; -} - -sal_Int64 SAL_CALL java_sql_Blob::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*pattern*/, sal_Int64 /*start*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this ); - // this was put here in CWS warnings01. The previous implementation was defective, as it did ignore - // the pattern parameter. Since the effort for proper implementation is rather high - we would need - // to translated patter into a byte[] -, we defer this functionality for the moment (hey, it was - // unusable, anyway) - // #i57457# - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx deleted file mode 100644 index cc41160b28..0000000000 --- a/connectivity/source/drivers/jdbc/Boolean.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/lang/Boolean.hxx" -using namespace connectivity; -//************************************************************** -//************ Class: java.lang.Boolean -//************************************************************** - -jclass java_lang_Boolean::theClass = 0; - -java_lang_Boolean::~java_lang_Boolean() -{} -jclass java_lang_Boolean::st_getMyClass() -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/lang/Boolean"); - return theClass; -} - -jclass java_lang_Boolean::getMyClass() const -{ - return st_getMyClass(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx deleted file mode 100644 index 910b64347d..0000000000 --- a/connectivity/source/drivers/jdbc/CallableStatement.cxx +++ /dev/null @@ -1,360 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/CallableStatement.hxx" -#include "java/tools.hxx" -#include "java/sql/Array.hxx" -#include "java/sql/Clob.hxx" -#include "java/sql/Blob.hxx" -#include "java/sql/Connection.hxx" -#include "java/sql/Ref.hxx" -#include "java/sql/Timestamp.hxx" -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/sequence.hxx> - -#include <string.h> - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - - -IMPLEMENT_SERVICE_INFO(java_sql_CallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement"); - -//************************************************************** -//************ Class: java.sql.CallableStatement -//************************************************************** -java_sql_CallableStatement::java_sql_CallableStatement( JNIEnv * pEnv, java_sql_Connection& _rCon,const ::rtl::OUString& sql ) - : java_sql_PreparedStatement( pEnv, _rCon, sql ) -{ -} -// ----------------------------------------------------------------------------- -java_sql_CallableStatement::~java_sql_CallableStatement() -{ -} -// ----------------------------------------------------------------------------- - -Any SAL_CALL java_sql_CallableStatement::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = java_sql_PreparedStatement::queryInterface(rType); - return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< starsdbc::XRow*>(this),static_cast< starsdbc::XOutParameters*>(this)); -} -// ------------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_CallableStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) -{ - ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XRow > *)0 ), - ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XOutParameters > *)0 )); - - return ::comphelper::concatSequences(aTypes.getTypes(),java_sql_PreparedStatement::getTypes()); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_CallableStatement::wasNull( ) throw(starsdbc::SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return callBooleanMethod( "wasNull", mID ); -} - -sal_Bool SAL_CALL java_sql_CallableStatement::getBoolean( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "getBoolean", mID,columnIndex ); -} -sal_Int8 SAL_CALL java_sql_CallableStatement::getByte( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jbyte (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallByteMethod; - return callMethodWithIntArg<jbyte>(pCallMethod,"getByte","(I)B",mID,columnIndex); -} -Sequence< sal_Int8 > SAL_CALL java_sql_CallableStatement::getBytes( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - Sequence< sal_Int8 > aSeq; - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jbyteArray out = (jbyteArray)callObjectMethodWithIntArg(t.pEnv,"getBytes","(I)[B", mID, columnIndex); - if (out) - { - jboolean p = sal_False; - aSeq.realloc(t.pEnv->GetArrayLength(out)); - memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength()); - t.pEnv->DeleteLocalRef(out); - } - return aSeq; -} -::com::sun::star::util::Date SAL_CALL java_sql_CallableStatement::getDate( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getDate","(I)Ljava/sql/Date;", mID, columnIndex); - return out ? static_cast <com::sun::star::util::Date>(java_sql_Date( t.pEnv, out )) : ::com::sun::star::util::Date(); -} -double SAL_CALL java_sql_CallableStatement::getDouble( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - double (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallDoubleMethod; - return callMethodWithIntArg<double>(pCallMethod,"getDouble","(I)D",mID,columnIndex); -} - -float SAL_CALL java_sql_CallableStatement::getFloat( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jfloat (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallFloatMethod; - return callMethodWithIntArg<jfloat>(pCallMethod,"getFloat","(I)F",mID,columnIndex); -} - -sal_Int32 SAL_CALL java_sql_CallableStatement::getInt( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - return callIntMethodWithIntArg("getInt",mID,columnIndex); -} - -sal_Int64 SAL_CALL java_sql_CallableStatement::getLong( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jlong (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallLongMethod; - return callMethodWithIntArg<jlong>(pCallMethod,"getLong","(I)J",mID,columnIndex); -} - -Any SAL_CALL java_sql_CallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callObjectMethodWithIntArg(t.pEnv,"getObject","(I)Ljava/lang/Object;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return Any(); -} - -sal_Int16 SAL_CALL java_sql_CallableStatement::getShort( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jshort (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallShortMethod; - return callMethodWithIntArg<jshort>(pCallMethod,"getShort","(I)S",mID,columnIndex); -} - -::rtl::OUString SAL_CALL java_sql_CallableStatement::getString( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getString",mID,columnIndex); -} - - ::com::sun::star::util::Time SAL_CALL java_sql_CallableStatement::getTime( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getTime","(I)Ljava/sql/Time;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out ? static_cast <com::sun::star::util::Time> (java_sql_Time( t.pEnv, out )) : ::com::sun::star::util::Time(); -} - - ::com::sun::star::util::DateTime SAL_CALL java_sql_CallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getTimestamp","(I)Ljava/sql/Timestamp;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out ? static_cast <com::sun::star::util::DateTime> (java_sql_Timestamp( t.pEnv, out )) : ::com::sun::star::util::DateTime(); -} - -void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(starsdbc::SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - createStatement(t.pEnv); - - // initialize temporary variable - static const char * cSignature = "(IILjava/lang/String;)V"; - static const char * cMethodName = "registerOutParameter"; - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - // Convert Parameter - jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,typeName)); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str.get()); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } -} -void SAL_CALL java_sql_CallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - createStatement(t.pEnv); - // initialize temporary variable - static const char * cSignature = "(III)V"; - static const char * cMethodName = "registerOutParameter"; - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,scale); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } -} - -jclass java_sql_CallableStatement::theClass = 0; - -jclass java_sql_CallableStatement::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/CallableStatement"); - return theClass; -} - -Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - Reference< starsdbc::XBlob > xBlob = getBlob(columnIndex); - return xBlob.is() ? xBlob->getBinaryStream() : Reference< ::com::sun::star::io::XInputStream >(); -} -Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - Reference< starsdbc::XClob > xClob = getClob(columnIndex); - return xClob.is() ? xClob->getCharacterStream() : Reference< ::com::sun::star::io::XInputStream >(); -} - -Reference< starsdbc::XArray > SAL_CALL java_sql_CallableStatement::getArray( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getArray","(I)Ljava/sql/Array;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Array( t.pEnv, out ); -} - -Reference< starsdbc::XClob > SAL_CALL java_sql_CallableStatement::getClob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getClob","(I)Ljava/sql/Clob;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Clob( t.pEnv, out ); -} -Reference< starsdbc::XBlob > SAL_CALL java_sql_CallableStatement::getBlob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getBlob","(I)Ljava/sql/Blob;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Blob( t.pEnv, out ); -} - -Reference< starsdbc::XRef > SAL_CALL java_sql_CallableStatement::getRef( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getRef","(I)Ljava/sql/Ref;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Ref( t.pEnv, out ); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_CallableStatement::acquire() throw() -{ - java_sql_PreparedStatement::acquire(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_CallableStatement::release() throw() -{ - java_sql_PreparedStatement::release(); -} -// ----------------------------------------------------------------------------- -void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - if( t.pEnv && !object ){ - // initialize temporary variable - static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/CallableStatement;"; - static const char * cMethodName = "prepareCall"; - // execute Java-Call - jobject out = NULL; - // convert Parameter - jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,m_sSqlStatement)); - - static jmethodID mID(NULL); - if ( !mID ) - mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature ); - if( mID ){ - out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency); - } //mID - else - { - static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/CallableStatement;"; - static jmethodID mID2 = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!"); - if( mID2 ){ - out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str.get() ); - } //mID - } - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - - if ( out ) - object = t.pEnv->NewGlobalRef( out ); - } //t.pEnv -} -// ----------------------------------------------------------------------------- - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Class.cxx b/connectivity/source/drivers/jdbc/Class.cxx deleted file mode 100644 index b122ad593d..0000000000 --- a/connectivity/source/drivers/jdbc/Class.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/lang/Class.hxx" -#include "java/tools.hxx" -#include <rtl/ustring.hxx> - -using namespace connectivity; -//************************************************************** -//************ Class: java.lang.Class -//************************************************************** - -jclass java_lang_Class::theClass = 0; - -java_lang_Class::~java_lang_Class() -{} - -jclass java_lang_Class::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/lang/Class"); - return theClass; -} - -java_lang_Class * java_lang_Class::forName( const ::rtl::OUString& _par0 ) -{ - jobject out(NULL); - SDBThreadAttach t; - - { - ::rtl::OString sClassName = ::rtl::OUStringToOString(_par0, RTL_TEXTENCODING_JAVA_UTF8); - sClassName = sClassName.replace('.','/'); - out = t.pEnv->FindClass(sClassName.getStr()); - ThrowSQLException(t.pEnv,0); - } //t.pEnv - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? NULL : new java_lang_Class( t.pEnv, out ); -} - -jobject java_lang_Class::newInstanceObject() -{ - SDBThreadAttach t; - static jmethodID mID(NULL); - return callObjectMethod(t.pEnv,"newInstance","()Ljava/lang/Object;", mID); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx deleted file mode 100644 index 6cc5a4573f..0000000000 --- a/connectivity/source/drivers/jdbc/Clob.cxx +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/Clob.hxx" -#include "java/tools.hxx" -#include "java/io/Reader.hxx" -#include <connectivity/dbexception.hxx> -#include <rtl/logfile.hxx> - -using namespace connectivity; -//************************************************************** -//************ Class: java.sql.Clob -//************************************************************** - -jclass java_sql_Clob::theClass = 0; - -java_sql_Clob::java_sql_Clob( JNIEnv * pEnv, jobject myObj ) - : java_lang_Object( pEnv, myObj ) -{ - SDBThreadAttach::addRef(); -} -java_sql_Clob::~java_sql_Clob() -{ - SDBThreadAttach::releaseRef(); -} - -jclass java_sql_Clob::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/Clob"); - return theClass; -} - -sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::length" ); - jlong out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - // initialize temporary variable - static const char * cSignature = "()J"; - static const char * cMethodName = "length"; - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallLongMethod( object, mID ); - ThrowSQLException(t.pEnv,*this); - } //t.pEnv - return (sal_Int64)out; -} - -::rtl::OUString SAL_CALL java_sql_Clob::getSubString( sal_Int64 pos, sal_Int32 subStringLength ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getSubString" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - ::rtl::OUString aStr; - { - // initialize temporary variable - static const char * cSignature = "(JI)Ljava/lang/String;"; - static const char * cMethodName = "getSubString"; - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID,pos,subStringLength); - ThrowSQLException(t.pEnv,*this); - aStr = JavaString2String(t.pEnv,out); - } //t.pEnv - // WARNING: the caller becomes the owner of the returned pointer - return aStr; -} - -::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Clob::getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getCharacterStream" ); - SDBThreadAttach t; - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getCharacterStream","()Ljava/io/Reader;", mID); - - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_io_Reader( t.pEnv, out ); -} - -sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::position" ); - jlong out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jvalue args[1]; - // convert Parameter - args[0].l = convertwchar_tToJavaString(t.pEnv,searchstr); - // initialize temporary Variable - static const char * cSignature = "(Ljava/lang/String;I)J"; - static const char * cMethodName = "position"; - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallLongMethod( object, mID, args[0].l,start ); - ThrowSQLException(t.pEnv,*this); - t.pEnv->DeleteLocalRef((jstring)args[0].l); - } //t.pEnv - return (sal_Int64)out; -} - -sal_Int64 SAL_CALL java_sql_Clob::positionOfClob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*pattern*/, sal_Int64 /*start*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::positionOfClob" ); - ::dbtools::throwFeatureNotImplementedException( "XClob::positionOfClob", *this ); - // this was put here in CWS warnings01. The previous implementation was defective, as it did ignore - // the pattern parameter. Since the effort for proper implementation is rather high - we would need - // to translated patter into a byte[] -, we defer this functionality for the moment (hey, it was - // unusable, anyway) - // 2005-11-15 / #i57457# / frank.schoenheit@sun.com - return 0; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/ConnectionLog.cxx b/connectivity/source/drivers/jdbc/ConnectionLog.cxx deleted file mode 100644 index c50d4bdc9e..0000000000 --- a/connectivity/source/drivers/jdbc/ConnectionLog.cxx +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" - -#include "java/sql/ConnectionLog.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/util/Date.hpp> -#include <com/sun/star/util/Time.hpp> -#include <com/sun/star/util/DateTime.hpp> -/** === end UNO includes === **/ - -#include <stdio.h> - -//........................................................................ -namespace connectivity { namespace java { namespace sql { -//........................................................................ - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XComponentContext; - /** === end UNO using === **/ - - //-------------------------------------------------------------------- - namespace - { - sal_Int32 lcl_getFreeID( ConnectionLog::ObjectType _eType ) - { - static oslInterlockedCount s_nCounts[ ConnectionLog::ObjectTypeCount ] = { 0, 0 }; - return osl_incrementInterlockedCount( s_nCounts + _eType ); - } - } - - //==================================================================== - //= ConnectionLog - //==================================================================== - //-------------------------------------------------------------------- - ConnectionLog::ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog ) - :ConnectionLog_Base( _rDriverLog ) - ,m_nObjectID( lcl_getFreeID( CONNECTION ) ) - { - } - - //-------------------------------------------------------------------- - ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog ) - :ConnectionLog_Base( _rSourceLog ) - ,m_nObjectID( _rSourceLog.m_nObjectID ) - { - } - - //-------------------------------------------------------------------- - ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog, ConnectionLog::ObjectType _eType ) - :ConnectionLog_Base( _rSourceLog ) - ,m_nObjectID( lcl_getFreeID( _eType ) ) - { - } - -//........................................................................ -} } } // namespace connectivity::java::sql -//........................................................................ - -//........................................................................ -namespace comphelper { namespace log { namespace convert -{ -//........................................................................ - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XComponentContext; - using ::com::sun::star::util::Date; - using ::com::sun::star::util::Time; - using ::com::sun::star::util::DateTime; - /** === end UNO using === **/ - - //-------------------------------------------------------------------- - ::rtl::OUString convertLogArgToString( const Date& _rDate ) - { - char buffer[ 30 ]; - const size_t buffer_size = sizeof( buffer ); - snprintf( buffer, buffer_size, "%04i-%02i-%02i", - (int)_rDate.Year, (int)_rDate.Month, (int)_rDate.Day ); - return ::rtl::OUString::createFromAscii( buffer ); - } - - //-------------------------------------------------------------------- - ::rtl::OUString convertLogArgToString( const Time& _rTime ) - { - char buffer[ 30 ]; - const size_t buffer_size = sizeof( buffer ); - snprintf( buffer, buffer_size, "%02i:%02i:%02i.%02i", - (int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.HundredthSeconds ); - return ::rtl::OUString::createFromAscii( buffer ); - } - - //-------------------------------------------------------------------- - ::rtl::OUString convertLogArgToString( const DateTime& _rDateTime ) - { - char buffer[ 30 ]; - const size_t buffer_size = sizeof( buffer ); - snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i", - (int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day, - (int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.HundredthSeconds ); - return ::rtl::OUString::createFromAscii( buffer ); - } - -//........................................................................ -} } } // comphelper::log::convert -//........................................................................ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/ContextClassLoader.cxx b/connectivity/source/drivers/jdbc/ContextClassLoader.cxx deleted file mode 100644 index da1802f710..0000000000 --- a/connectivity/source/drivers/jdbc/ContextClassLoader.cxx +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" - -#include "java/ContextClassLoader.hxx" -#include "java/lang/Object.hxx" - -/** === begin UNO includes === **/ -/** === end UNO includes === **/ - -//........................................................................ -namespace connectivity { namespace jdbc -{ -//........................................................................ - - /** === begin UNO using === **/ - using ::com::sun::star::uno::Reference; - using ::com::sun::star::uno::XInterface; - /** === end UNO using === **/ - - using ::connectivity::java_lang_Object; - - //==================================================================== - //= ContextClassLoaderScope - //==================================================================== - //-------------------------------------------------------------------- - ContextClassLoaderScope::ContextClassLoaderScope( JNIEnv& environment, const GlobalRef< jobject >& newClassLoader, - const ::comphelper::ResourceBasedEventLogger& _rLoggerForErrors, const Reference< XInterface >& _rxErrorContext ) - :m_environment( environment ) - ,m_currentThread( environment ) - ,m_oldContextClassLoader( environment ) - { - if ( !newClassLoader.is() ) - return; - - do // artificial loop for easier flow control - { - - LocalRef< jclass > threadClass( m_environment ); - threadClass.set( m_environment.FindClass( "java/lang/Thread" ) ); - if ( !threadClass.is() ) - break; - - jmethodID currentThreadMethod( m_environment.GetStaticMethodID( - threadClass.get(), "currentThread", "()Ljava/lang/Thread;" ) ); - if ( currentThreadMethod == NULL ) - break; - - m_currentThread.set( m_environment.CallStaticObjectMethod( threadClass.get(), currentThreadMethod ) ); - if ( !m_currentThread.is() ) - break; - - jmethodID getContextClassLoaderMethod( m_environment.GetMethodID( - threadClass.get(), "getContextClassLoader", "()Ljava/lang/ClassLoader;" ) ); - if ( getContextClassLoaderMethod == NULL ) - break; - m_oldContextClassLoader.set( m_environment.CallObjectMethod( m_currentThread.get(), getContextClassLoaderMethod ) ); - LocalRef< jthrowable > throwable( m_environment, m_environment.ExceptionOccurred() ); - if ( throwable.is() ) - break; - - m_setContextClassLoaderMethod = m_environment.GetMethodID( - threadClass.get(), "setContextClassLoader", "(Ljava/lang/ClassLoader;)V" ); - if ( m_setContextClassLoaderMethod == NULL ) - break; - - } - while ( false ); - - if ( !isActive() ) - { - java_lang_Object::ThrowLoggedSQLException( _rLoggerForErrors, &environment, _rxErrorContext ); - return; - } - - // set the new class loader - m_environment.CallObjectMethod( m_currentThread.get(), m_setContextClassLoaderMethod, newClassLoader.get() ); - LocalRef< jthrowable > throwable( m_environment, m_environment.ExceptionOccurred() ); - if ( throwable.is() ) - { - m_currentThread.reset(); - m_setContextClassLoaderMethod = NULL; - java_lang_Object::ThrowLoggedSQLException( _rLoggerForErrors, &environment, _rxErrorContext ); - } - } - - //-------------------------------------------------------------------- - void ContextClassLoaderScope::pop( bool clearExceptions ) - { - if ( isActive() ) - { - LocalRef< jobject > currentThread( m_currentThread.env(), m_currentThread.release() ); - jmethodID setContextClassLoaderMethod( m_setContextClassLoaderMethod ); - m_setContextClassLoaderMethod = NULL; - - m_environment.CallObjectMethod( currentThread.get(), setContextClassLoaderMethod, m_oldContextClassLoader.get() ); - if ( clearExceptions ) - { - m_environment.ExceptionClear(); - } - } - } -//........................................................................ -} } // namespace connectivity::jdbc -//........................................................................ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx deleted file mode 100644 index 256c08fd36..0000000000 --- a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx +++ /dev/null @@ -1,1465 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include <sal/macros.h> -#include "java/sql/DatabaseMetaData.hxx" -#include "java/sql/Connection.hxx" -#include "java/sql/ResultSet.hxx" -#include "java/tools.hxx" -#include "java/lang/String.hxx" -#include "connectivity/CommonTools.hxx" -#include "FDatabaseMetaDataResultSet.hxx" -#include <comphelper/types.hxx> -#include "TPrivilegesResultSet.hxx" -#include "diagnose_ex.h" -#include "resource/jdbc_log.hrc" - -using namespace ::comphelper; - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -//************************************************************** -//************ Class: java.sql.DatabaseMetaData -//************************************************************** - -jclass java_sql_DatabaseMetaData::theClass = 0; - -java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData() -{ - SDBThreadAttach::releaseRef(); -} - -jclass java_sql_DatabaseMetaData::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/DatabaseMetaData"); - return theClass; -} -// ----------------------------------------------------------------------------- -java_sql_DatabaseMetaData::java_sql_DatabaseMetaData( JNIEnv * pEnv, jobject myObj, java_sql_Connection& _rConnection ) - :ODatabaseMetaDataBase( &_rConnection,_rConnection.getConnectionInfo() ) - ,java_lang_Object( pEnv, myObj ) - ,m_pConnection( &_rConnection ) - ,m_aLogger( _rConnection.getLogger() ) -{ - SDBThreadAttach::addRef(); -} - -// ------------------------------------------------------------------------- -Reference< XResultSet > java_sql_DatabaseMetaData::impl_getTypeInfo_throw( ) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethod( "getTypeInfo", mID ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethod( "getCatalogs", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString java_sql_DatabaseMetaData::impl_getCatalogSeparator_throw( ) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getCatalogSeparator", mID ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethod( "getSchemas", mID ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumnPrivileges( - const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getColumnPrivileges", mID, catalog, schema, table, &columnNamePattern ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumns( - const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getColumns", mID, catalog, schemaPattern, tableNamePattern, &columnNamePattern ); -} - -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables( - const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& _types ) throw(SQLException, RuntimeException) -{ - static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;"; - static const char * cMethodName = "getTables"; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName ); - - jobject out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - OSL_VERIFY_RES( !isExceptionOccurred(t.pEnv,sal_True),"Exception occurred!"); - jvalue args[4]; - - args[3].l = 0; - sal_Int32 typeFilterCount = _types.getLength(); - if ( typeFilterCount ) - { - jobjectArray pObjArray = static_cast< jobjectArray >( t.pEnv->NewObjectArray( (jsize)typeFilterCount, java_lang_String::st_getMyClass(), 0 ) ); - OSL_VERIFY_RES( !isExceptionOccurred( t.pEnv, sal_True ), "Exception occurred!" ); - const ::rtl::OUString* typeFilter = _types.getConstArray(); - bool bIncludeAllTypes = false; - for ( sal_Int32 i=0; i<typeFilterCount; ++i, ++typeFilter ) - { - if ( typeFilter->equalsAsciiL( "%", 1 ) ) - { - bIncludeAllTypes = true; - break; - } - jstring aT = convertwchar_tToJavaString( t.pEnv, *typeFilter ); - t.pEnv->SetObjectArrayElement( pObjArray, (jsize)i, aT ); - OSL_VERIFY_RES( !isExceptionOccurred( t.pEnv, sal_True ), "Exception occurred!" ); - } - - if ( bIncludeAllTypes ) - { - // the SDBC API allows to pass "%" as table type filter, but in JDBC, "all table types" - // is represented by the table type being <null/> - t.pEnv->DeleteLocalRef( pObjArray ); - OSL_VERIFY_RES( !isExceptionOccurred( t.pEnv, sal_True ), "Exception occurred!" ); - } - else - { - args[3].l = pObjArray; - } - } - // if we are to display "all catalogs", then respect m_aCatalogRestriction - Any aCatalogFilter( catalog ); - if ( !aCatalogFilter.hasValue() ) - aCatalogFilter = m_pConnection->getCatalogRestriction(); - // similar for schema - Any aSchemaFilter; - if ( schemaPattern.equalsAsciiL( "%", 1 ) ) - aSchemaFilter = m_pConnection->getSchemaRestriction(); - else - aSchemaFilter <<= schemaPattern; - - args[0].l = aCatalogFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aCatalogFilter ) ) : NULL; - args[1].l = aSchemaFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aSchemaFilter ) ) : NULL; - args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern); - out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l); - jthrowable jThrow = t.pEnv->ExceptionOccurred(); - if ( jThrow ) - t.pEnv->ExceptionClear();// we have to clear the exception here because we want to handle it below - if ( aCatalogFilter.hasValue() ) - { - t.pEnv->DeleteLocalRef((jstring)args[0].l); - OSL_VERIFY_RES( !isExceptionOccurred( t.pEnv, sal_True ), "Exception occurred!" ); - } - if(args[1].l) - { - t.pEnv->DeleteLocalRef((jstring)args[1].l); - OSL_VERIFY_RES( !isExceptionOccurred( t.pEnv, sal_True ), "Exception occurred!" ); - } - if(tableNamePattern.getLength()) - { - t.pEnv->DeleteLocalRef((jstring)args[2].l); - OSL_VERIFY_RES( !isExceptionOccurred( t.pEnv, sal_True ), "Exception occurred!" ); - } - //for(INT16 i=0;i<len;i++) - if ( args[3].l ) - { - t.pEnv->DeleteLocalRef( (jobjectArray)args[3].l ); - OSL_VERIFY_RES( !isExceptionOccurred( t.pEnv, sal_True ), "Exception occurred!" ); - } - - if ( jThrow ) - { - if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::st_getMyClass() ) ) - { - java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE( t.pEnv, jThrow ); - SQLException e( pException->getMessage(), - *this, - pException->getSQLState(), - pException->getErrorCode(), - Any() - ); - delete pException; - throw e; - } - } - } - - if ( !out ) - return NULL; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName ); - return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedureColumns( - const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getProcedureColumns", mID, catalog, schemaPattern, procedureNamePattern, &columnNamePattern ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedures( const Any& - catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getProcedures", mID, catalog, schemaPattern, procedureNamePattern ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getVersionColumns( - const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getVersionColumns", mID, catalog, schema, table ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxBinaryLiteralLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxRowSize", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxCatalogNameLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxCharLiteralLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnNameLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInIndex", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxCursorNameLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxConnections", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInTable", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxStatementLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxTableNameLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( ) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxTablesInSelect", mID ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getExportedKeys( - const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getExportedKeys", mID, catalog, schema, table ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getImportedKeys( - const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getImportedKeys", mID, catalog, schema, table ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getPrimaryKeys( - const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethodWithStrings( "getPrimaryKeys", mID, catalog, schema, table ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getIndexInfo( - const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, - sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException) -{ - static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;"; - static const char * cMethodName = "getIndexInfo"; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName ); - - jobject out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jvalue args[5]; - // convert Parameter - args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0; - args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); - args[2].l = convertwchar_tToJavaString(t.pEnv,table); - args[3].z = unique; - args[4].z = approximate; - out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,args[3].z,args[4].z ); - - // and clean up - if(catalog.hasValue()) - t.pEnv->DeleteLocalRef((jstring)args[0].l); - if(args[1].l) - t.pEnv->DeleteLocalRef((jstring)args[1].l); - if(table.getLength()) - t.pEnv->DeleteLocalRef((jstring)args[2].l); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - if ( !out ) - return NULL; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName ); - return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getBestRowIdentifier( - const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, - sal_Bool nullable ) throw(SQLException, RuntimeException) -{ - static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;"; - static const char * cMethodName = "getBestRowIdentifier"; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName ); - - jobject out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jvalue args[3]; - // convert Parameter - args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0; - args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema); - args[2].l = convertwchar_tToJavaString(t.pEnv,table); - out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,scope,nullable); - - // and cleanup - if(catalog.hasValue()) - t.pEnv->DeleteLocalRef((jstring)args[0].l); - if(args[1].l) - t.pEnv->DeleteLocalRef((jstring)args[1].l); - if(table.getLength()) - t.pEnv->DeleteLocalRef((jstring)args[2].l); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - - if ( !out ) - return NULL; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName ); - return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTablePrivileges( - const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException) -{ - if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() ) - return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern); - - static jmethodID mID(NULL); - Reference< XResultSet > xReturn( impl_callResultSetMethodWithStrings( "getTablePrivileges", mID, catalog, schemaPattern, tableNamePattern ) ); - - if ( xReturn.is() ) - { - // we have to check the result columns for the tables privleges - Reference< XResultSetMetaDataSupplier > xMetaSup(xReturn,UNO_QUERY); - if ( xMetaSup.is() ) - { - Reference< XResultSetMetaData> xMeta = xMetaSup->getMetaData(); - if ( xMeta.is() && xMeta->getColumnCount() != 7 ) - { - // here we know that the count of column doesn't match - ::std::map<sal_Int32,sal_Int32> aColumnMatching; - static const ::rtl::OUString sPrivs[] = { - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE_CAT")), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE_SCHEM")), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE_NAME")), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GRANTOR")), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GRANTEE")), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PRIVILEGE")), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IS_GRANTABLE")) - }; - - ::rtl::OUString sColumnName; - sal_Int32 nCount = xMeta->getColumnCount(); - for (sal_Int32 i = 1 ; i <= nCount ; ++i) - { - sColumnName = xMeta->getColumnName(i); - for (sal_uInt32 j = 0 ; j < SAL_N_ELEMENTS(sPrivs); ++j) - { - if ( sPrivs[j] == sColumnName ) - { - aColumnMatching.insert( ::std::map<sal_Int32,sal_Int32>::value_type(i,j+1) ); - break; - } - } - - } - // fill our own resultset - ODatabaseMetaDataResultSet* pNewPrivRes = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges ); - Reference< XResultSet > xTemp = xReturn; - xReturn = pNewPrivRes; - ODatabaseMetaDataResultSet::ORows aRows; - Reference< XRow > xRow(xTemp,UNO_QUERY); - ::rtl::OUString sValue; - - ODatabaseMetaDataResultSet::ORow aRow(8); - while ( xRow.is() && xTemp->next() ) - { - ::std::map<sal_Int32,sal_Int32>::iterator aIter = aColumnMatching.begin(); - ::std::map<sal_Int32,sal_Int32>::iterator aEnd = aColumnMatching.end(); - for (;aIter != aEnd ; ++aIter) - { - sValue = xRow->getString(aIter->first); - if ( xRow->wasNull() ) - aRow[aIter->second] = ODatabaseMetaDataResultSet::getEmptyValue(); - else - aRow[aIter->second] = new ORowSetValueDecorator(sValue); - } - - aRows.push_back(aRow); - } - pNewPrivRes->setRows(aRows); - } - } - } - return xReturn; -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCrossReference( - const Any& primaryCatalog, const ::rtl::OUString& primarySchema, - const ::rtl::OUString& primaryTable, const Any& foreignCatalog, - const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) -{ - static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; - static const char * cMethodName = "getCrossReference"; - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName ); - - jobject out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jvalue args[6]; - // convert Parameter - args[0].l = primaryCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(primaryCatalog)) : 0; - args[1].l = primarySchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,primarySchema); - args[2].l = convertwchar_tToJavaString(t.pEnv,primaryTable); - args[3].l = foreignCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(foreignCatalog)) : 0; - args[4].l = foreignSchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,foreignSchema); - args[5].l = convertwchar_tToJavaString(t.pEnv,foreignTable); - out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[2].l,args[2].l,args[3].l,args[4].l,args[5].l ); - - // and clean up - if(primaryCatalog.hasValue()) - t.pEnv->DeleteLocalRef((jstring)args[0].l); - if(args[1].l) - t.pEnv->DeleteLocalRef((jstring)args[1].l); - if(primaryTable.getLength()) - t.pEnv->DeleteLocalRef((jstring)args[2].l); - if(foreignCatalog.hasValue()) - t.pEnv->DeleteLocalRef((jstring)args[3].l); - if(args[4].l) - t.pEnv->DeleteLocalRef((jstring)args[4].l); - if(foreignTable.getLength()) - t.pEnv->DeleteLocalRef((jstring)args[5].l); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - - if ( !out ) - return NULL; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName ); - return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection); -} - -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) -{ - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName ); - jboolean out( java_lang_Object::callBooleanMethod(_pMethodName,_inout_MethodID) ); - m_aLogger.log< const sal_Char*, sal_Int16>( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out ); - return out; -} - -// ------------------------------------------------------------------------- -::rtl::OUString java_sql_DatabaseMetaData::impl_callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) -{ - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName ); - - const ::rtl::OUString sReturn( callStringMethod(_pMethodName,_inout_MethodID) ); - if ( m_aLogger.isLoggable( LogLevel::FINEST ) ) - { - ::rtl::OUString sLoggedResult( sReturn ); - if ( !sLoggedResult.getLength() ) - sLoggedResult = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "<empty string>" ) ); - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, sLoggedResult ); - } - - return sReturn; -} - -// ------------------------------------------------------------------------- -sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) -{ - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName ); - sal_Int32 out( (sal_Int32)callIntMethod(_pMethodName,_inout_MethodID) ); - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, (sal_Int32)out ); - return out; -} - -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) -{ - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG1, _pMethodName, _nArgument ); - - jboolean out( callBooleanMethodWithIntArg(_pMethodName,_inout_MethodID,_nArgument) ); - - m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out ); - return out; -} - -// ------------------------------------------------------------------------- -Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) -{ - SDBThreadAttach t; - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName ); - jobject out(callResultSetMethod(t.env(),_pMethodName,_inout_MethodID)); - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, _pMethodName ); - return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection); -} - -// ------------------------------------------------------------------------- -Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings( const char* _pMethodName, jmethodID& _inout_MethodID, - const Any& _rCatalog, const ::rtl::OUString& _rSchemaPattern, const ::rtl::OUString& _rLeastPattern, - const ::rtl::OUString* _pOptionalAdditionalString ) -{ - bool bCatalog = _rCatalog.hasValue(); - ::rtl::OUString sCatalog; - _rCatalog >>= sCatalog; - - bool bSchema = _rSchemaPattern.toChar() != '%'; - - // log the call - if ( m_aLogger.isLoggable( LogLevel::FINEST ) ) - { - ::rtl::OUString sCatalogLog = bCatalog ? sCatalog : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "null" ) ); - ::rtl::OUString sSchemaLog = bSchema ? _rSchemaPattern : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "null" ) ); - if ( _pOptionalAdditionalString ) - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG4, _pMethodName, sCatalogLog, sSchemaLog, _rLeastPattern, *_pOptionalAdditionalString ); - else - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG3, _pMethodName, sCatalogLog, sSchemaLog, _rLeastPattern ); - } - - jobject out(0); - - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings: no Java enviroment anymore!" ); - - { - const char* pSignature = _pOptionalAdditionalString - ? "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;" - : "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"; - // obtain method ID - obtainMethodId(t.pEnv, _pMethodName,pSignature, _inout_MethodID); - - // call method - - { - jvalue args[4]; - // convert parameters - args[0].l = bCatalog ? convertwchar_tToJavaString( t.pEnv, sCatalog ) : NULL; - args[1].l = bSchema ? convertwchar_tToJavaString( t.pEnv, _rSchemaPattern ) : NULL; - args[2].l = convertwchar_tToJavaString( t.pEnv, _rLeastPattern ); - args[3].l = _pOptionalAdditionalString ? convertwchar_tToJavaString( t.pEnv, *_pOptionalAdditionalString ) : NULL; - - // actually do the call - if ( _pOptionalAdditionalString ) - out = t.pEnv->CallObjectMethod( object, _inout_MethodID, args[0].l, args[1].l, args[2].l, args[3].l ); - else - out = t.pEnv->CallObjectMethod( object, _inout_MethodID, args[0].l, args[1].l, args[2].l ); - - // clean up - if ( args[0].l ) - t.pEnv->DeleteLocalRef( (jstring)args[0].l ); - if ( args[1].l ) - t.pEnv->DeleteLocalRef( (jstring)args[1].l ); - if ( args[2].l ) - t.pEnv->DeleteLocalRef( (jstring)args[2].l ); - if ( args[3].l ) - t.pEnv->DeleteLocalRef( (jstring)args[3].l ); - - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } - - if ( !out ) - return NULL; - - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, _pMethodName ); - return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection); -} - -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "doesMaxRowSizeIncludeBlobs", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "storesLowerCaseQuotedIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "storesLowerCaseIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "storesMixedCaseQuotedIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "storesMixedCaseIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "storesUpperCaseQuotedIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "storesUpperCaseIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsAlterTableWithAddColumn", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsAlterTableWithDropColumn", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxIndexLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsNonNullableColumns", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getCatalogTerm", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString java_sql_DatabaseMetaData::impl_getIdentifierQuoteString_throw( ) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getIdentifierQuoteString", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getExtraNameCharacters", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsDifferentTableCorrelationNames", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_isCatalogAtStart_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "isCatalogAtStart", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "dataDefinitionIgnoredInTransactions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "dataDefinitionCausesTransactionCommit", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsDataManipulationTransactionsOnly", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsDataDefinitionAndDataManipulationTransactions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsPositionedDelete", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsPositionedUpdate", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsOpenStatementsAcrossRollback", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsOpenStatementsAcrossCommit", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsOpenCursorsAcrossCommit", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsOpenCursorsAcrossRollback", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "supportsTransactionIsolationLevel", mID, level ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSchemasInDataManipulation", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsANSI92FullSQL", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsANSI92EntryLevelSQL", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsIntegrityEnhancementFacility", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSchemasInIndexDefinitions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSchemasInTableDefinitions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsCatalogsInTableDefinitions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsCatalogsInIndexDefinitions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsCatalogsInDataManipulation", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsOuterJoins", mID ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callResultSetMethod( "getTableTypes", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 java_sql_DatabaseMetaData::impl_getMaxStatements_throw( ) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxStatements", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxProcedureNameLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxSchemaNameLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsTransactions", mID ); -} - -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "allProceduresAreCallable", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsStoredProcedures", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSelectForUpdate", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "allTablesAreSelectable", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "isReadOnly", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "usesLocalFiles", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "usesLocalFilePerTable", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsTypeConversion", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "nullPlusNonNullIsNull", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsColumnAliasing", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsTableCorrelationNames", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException) -{ - static const char* pMethodName = "supportsConvert"; - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG2, pMethodName, fromType, toType ); - - jboolean out( sal_False ); - SDBThreadAttach t; - - { - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, pMethodName,"(II)Z", mID); - out = t.pEnv->CallBooleanMethod( object, mID, fromType, toType ); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - - m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out ); - return out; -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsExpressionsInOrderBy", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsGroupBy", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsGroupByBeyondSelect", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsGroupByUnrelated", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsMultipleTransactions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsMultipleResultSets", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsLikeEscapeClause", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsOrderByUnrelated", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsUnion", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsUnionAll", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsMixedCaseIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_DatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( ) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsMixedCaseQuotedIdentifiers", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "nullsAreSortedAtEnd", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "nullsAreSortedAtStart", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "nullsAreSortedHigh", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "nullsAreSortedLow", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSchemasInProcedureCalls", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSchemasInPrivilegeDefinitions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsCatalogsInProcedureCalls", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsCatalogsInPrivilegeDefinitions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsCorrelatedSubqueries", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSubqueriesInComparisons", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSubqueriesInExists", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSubqueriesInIns", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsSubqueriesInQuantifieds", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsANSI92IntermediateSQL", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) -{ - ::rtl::OUString sURL = m_pConnection->getURL(); - if ( !sURL.getLength() ) - { - static jmethodID mID(NULL); - sURL = impl_callStringMethod( "getURL", mID ); - } - return sURL; -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getUserName", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getDriverName", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getDriverVersion", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getDatabaseProductVersion", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getDatabaseProductName", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getProcedureTerm", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getSchemaTerm", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getDriverMajorVersion", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getDefaultTransactionIsolation", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getDriverMinorVersion", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getSQLKeywords", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getSearchStringEscape", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getStringFunctions", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getTimeDateFunctions", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getSystemFunctions", mID ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callStringMethod( "getNumericFunctions", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsExtendedSQLGrammar", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsCoreSQLGrammar", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsMinimumSQLGrammar", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsFullOuterJoins", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsLimitedOuterJoins", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInGroupBy", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInOrderBy", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxColumnsInSelect", mID ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callIntMethod( "getMaxUserNameLength", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "supportsResultSetType", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException) -{ - static const char* pMethodName = "supportsResultSetConcurrency"; - m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG2, pMethodName, setType, concurrency ); - - jboolean out( sal_False ); - SDBThreadAttach t; - - { - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, pMethodName,"(II)Z", mID); - out = t.pEnv->CallBooleanMethod( object, mID, setType, concurrency); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - - m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out ); - return out; -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "ownUpdatesAreVisible", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "ownDeletesAreVisible", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "ownInsertsAreVisible", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "othersUpdatesAreVisible", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "othersDeletesAreVisible", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "othersInsertsAreVisible", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "updatesAreDetected", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "deletesAreDetected", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethodWithIntArg( "insertsAreDetected", mID, setType ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_callBooleanMethod( "supportsBatchUpdates", mID ); -} -// ------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getUDTs( - const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, - const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException) -{ - jobject out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - - - static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I)Ljava/sql/ResultSet;"; - static const char * cMethodName = "getUDTs"; - // dismiss Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - { - jvalue args[4]; - // initialize temporary Variable - args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0; - args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern); - args[2].l = convertwchar_tToJavaString(t.pEnv,typeNamePattern); - jintArray pArray = t.pEnv->NewIntArray(types.getLength()); - t.pEnv->SetIntArrayRegion(pArray,0,types.getLength(),(jint*)types.getConstArray()); - args[3].l = pArray; - - out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l); - - if(catalog.hasValue()) - t.pEnv->DeleteLocalRef((jstring)args[0].l); - if(schemaPattern.getLength()) - t.pEnv->DeleteLocalRef((jstring)args[1].l); - if(typeNamePattern.getLength()) - t.pEnv->DeleteLocalRef((jstring)args[2].l); - if(args[3].l) - t.pEnv->DeleteLocalRef((jintArray)args[3].l); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } - - return out ? new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection ) : 0; -} -// ------------------------------------------------------------------------- - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Date.cxx b/connectivity/source/drivers/jdbc/Date.cxx deleted file mode 100644 index a2c05a67bf..0000000000 --- a/connectivity/source/drivers/jdbc/Date.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/util/Date.hxx" -#include "java/tools.hxx" -#include "connectivity/dbconversion.hxx" -using namespace connectivity; -//************************************************************** -//************ Class: java.util.Date -//************************************************************** - -jclass java_util_Date::theClass = 0; - -java_util_Date::~java_util_Date() -{} - -jclass java_util_Date::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/util/Date"); - return theClass; -} - -// ----------------------------------------------------------------------------- - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx b/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx deleted file mode 100644 index f64e9cc4f7..0000000000 --- a/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/DriverPropertyInfo.hxx" -#include "java/lang/Boolean.hxx" -#include "java/tools.hxx" -#include "java/lang/String.hxx" - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - - -//************************************************************** -//************ Class: java.sql.Driver -//************************************************************** - -jclass java_sql_DriverPropertyInfo::theClass = 0; -// -------------------------------------------------------------------------------- -java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo() -{} -// -------------------------------------------------------------------------------- -jclass java_sql_DriverPropertyInfo::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/DriverPropertyInfo"); - return theClass; -} - -// -------------------------------------------------------------------------------- -java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo() -{ - starsdbc::DriverPropertyInfo aInfo; - aInfo.Name = name(); - aInfo.Description = description(); - aInfo.IsRequired = required(); - aInfo.Value = value(); - aInfo.Choices = choices(); - - return aInfo; -} -// -------------------------------------------------------------------------------- -::rtl::OUString java_sql_DriverPropertyInfo::name() -{ - ::rtl::OUString aStr; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jfieldID id = t.pEnv->GetFieldID(getMyClass(),"name","Ljava/lang/String;"); - if(id) - aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id)); - } //t.pEnv - return aStr; -} -// -------------------------------------------------------------------------------- -::rtl::OUString java_sql_DriverPropertyInfo::description() -{ - ::rtl::OUString aStr; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jfieldID id = t.pEnv->GetFieldID(getMyClass(),"description","Ljava/lang/String;"); - if(id) - aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id)); - } //t.pEnv - return aStr; -} -// -------------------------------------------------------------------------------- -::rtl::OUString java_sql_DriverPropertyInfo::value() -{ - ::rtl::OUString aStr; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jfieldID id = t.pEnv->GetFieldID(getMyClass(),"value","Ljava/lang/String;"); - if(id) - aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id)); - } //t.pEnv - return aStr; -} -// -------------------------------------------------------------------------------- -sal_Bool java_sql_DriverPropertyInfo::required() -{ - jboolean out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z"); - if(id) - out = t.pEnv->GetBooleanField( object, id); - } //t.pEnv - return out; -} -// -------------------------------------------------------------------------------- -Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices() -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jfieldID id = t.pEnv->GetFieldID(getMyClass(),"choices","[Ljava/lang/String;"); - if(id) - { - const java_lang_String * pEmpty = NULL; - const ::rtl::OUString * pEmpty2 = NULL; - return copyArrayAndDelete(t.pEnv,(jobjectArray)t.pEnv->GetObjectField( object, id), pEmpty2, pEmpty); - } - } //t.pEnv - return Sequence< ::rtl::OUString>(); -} -// -------------------------------------------------------------------------------- - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Exception.cxx b/connectivity/source/drivers/jdbc/Exception.cxx deleted file mode 100644 index 09e0624d54..0000000000 --- a/connectivity/source/drivers/jdbc/Exception.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/lang/Exception.hxx" -using namespace connectivity; -//************************************************************** -//************ Class: java.lang.Exception -//************************************************************** - -jclass java_lang_Exception::theClass = 0; - -java_lang_Exception::~java_lang_Exception() -{} - -jclass java_lang_Exception::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/lang/Exception"); - return theClass; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx deleted file mode 100644 index 33e8acc3a4..0000000000 --- a/connectivity/source/drivers/jdbc/InputStream.cxx +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/io/InputStream.hxx" -#include "java/tools.hxx" - -#include <string.h> - -using namespace connectivity; -//************************************************************** -//************ Class: java.io.InputStream -//************************************************************** - -jclass java_io_InputStream::theClass = 0; -java_io_InputStream::java_io_InputStream( JNIEnv * pEnv, jobject myObj ) - : java_lang_Object( pEnv, myObj ) -{ - SDBThreadAttach::addRef(); -} -java_io_InputStream::~java_io_InputStream() -{ - SDBThreadAttach::releaseRef(); -} - -jclass java_io_InputStream::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/io/InputStream"); - return theClass; -} - - -sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - return readBytes(aData,nMaxBytesToRead); -} - -void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - callIntMethodWithIntArg("skip",mID,nBytesToSkip); -} - -sal_Int32 SAL_CALL java_io_InputStream::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - return callIntMethod("available",mID); -} -void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethod("close",mID); -} -// ----------------------------------------------------- -sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - if (nBytesToRead < 0) - throw ::com::sun::star::io::BufferSizeExceededException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), *this ); - - jint out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jbyteArray pByteArray = t.pEnv->NewByteArray(nBytesToRead); - static const char * cSignature = "([BII)I"; - static const char * cMethodName = "read"; - // execute Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead ); - if ( !out ) - ThrowSQLException(t.pEnv,*this); - if(out > 0) - { - jboolean p = sal_False; - aData.realloc ( out ); - rtl_copyMemory(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out); - } - t.pEnv->DeleteLocalRef((jbyteArray)pByteArray); - } //t.pEnv - return out; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/JBigDecimal.cxx b/connectivity/source/drivers/jdbc/JBigDecimal.cxx deleted file mode 100644 index a724a07de1..0000000000 --- a/connectivity/source/drivers/jdbc/JBigDecimal.cxx +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/math/BigDecimal.hxx" -#include "java/tools.hxx" -#include "resource/jdbc_log.hrc" -using namespace connectivity; -//************************************************************** -//************ Class: java.lang.Boolean -//************************************************************** - -jclass java_math_BigDecimal::theClass = 0; - -java_math_BigDecimal::~java_math_BigDecimal() -{} - -jclass java_math_BigDecimal::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/math/BigDecimal"); - return theClass; -} - -java_math_BigDecimal::java_math_BigDecimal( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - // Java-Call for the Constructor - // initialize temporary Variable - static const char * cSignature = "(Ljava/lang/String;)V"; - jobject tempObj; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, "<init>",cSignature, mID); - - jstring str = convertwchar_tToJavaString(t.pEnv,_par0.replace(',','.')); - tempObj = t.pEnv->NewObject( getMyClass(), mID, str ); - t.pEnv->DeleteLocalRef(str); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - ThrowSQLException( t.pEnv, NULL ); - // and cleanup -} - -java_math_BigDecimal::java_math_BigDecimal( const double& _par0 ): java_lang_Object( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - // Java-Call for the Constructor - // initialize temporary Variable - static const char * cSignature = "(D)V"; - jobject tempObj; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, "<init>",cSignature, mID); - tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 ); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - ThrowSQLException( t.pEnv, NULL ); - // and cleanup -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx deleted file mode 100644 index 3b3648ef8c..0000000000 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ /dev/null @@ -1,876 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" - -#include "java/sql/Connection.hxx" -#include "java/lang/Class.hxx" -#include "java/tools.hxx" -#include "java/ContextClassLoader.hxx" -#include "java/sql/DatabaseMetaData.hxx" -#include "java/sql/JStatement.hxx" -#include "java/sql/Driver.hxx" -#include "java/sql/PreparedStatement.hxx" -#include "java/sql/CallableStatement.hxx" -#include "java/sql/SQLWarning.hxx" -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/sdbc/SQLWarning.hpp> -#include <com/sun/star/sdbc/SQLWarning.hpp> -#include <com/sun/star/beans/NamedValue.hpp> -#include "connectivity/sqlparse.hxx" -#include "connectivity/dbexception.hxx" -#include "java/util/Property.hxx" -#include "java/LocalRef.hxx" -#include "resource/jdbc_log.hrc" -#include "com/sun/star/uno/XComponentContext.hpp" -#include "jvmaccess/classpath.hxx" -#include <comphelper/namedvaluecollection.hxx> -#include <rtl/ustrbuf.hxx> -#include <jni.h> -#include "resource/common_res.hrc" -#include <unotools/confignode.hxx> - -#include <list> -#include <memory> - -using namespace connectivity; -using namespace connectivity::jdbc; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -namespace { - -struct ClassMapEntry { - ClassMapEntry( - rtl::OUString const & theClassPath, rtl::OUString const & theClassName): - classPath(theClassPath), className(theClassName), classLoader(NULL), - classObject(NULL) {} - - rtl::OUString classPath; - rtl::OUString className; - jweak classLoader; - jweak classObject; -}; - -typedef std::list< ClassMapEntry > ClassMap; - -struct ClassMapData { - osl::Mutex mutex; - - ClassMap map; -}; - -struct ClassMapDataInit { - ClassMapData * operator()() { - static ClassMapData instance; - return &instance; - } -}; - -template < typename T > -bool getLocalFromWeakRef( jweak& _weak, LocalRef< T >& _inout_local ) -{ - _inout_local.set( static_cast< T >( _inout_local.env().NewLocalRef( _weak ) ) ); - - if ( !_inout_local.is() ) - { - if ( _inout_local.env().ExceptionCheck()) - { - return false; - } - else if ( _weak != NULL ) - { - _inout_local.env().DeleteWeakGlobalRef( _weak ); - _weak = NULL; - } - } - return true; -} - -// Load a class. A map from pairs of (classPath, name) to pairs of weak Java -// references to (ClassLoader, Class) is maintained, so that a class is only -// loaded once. -// -// It may happen that the weak reference to the ClassLoader becomes null while -// the reference to the Class remains non-null (in case the Class was actually -// loaded by some parent of the ClassLoader), in which case the ClassLoader is -// resurrected (which cannot cause any classes to be loaded multiple times, as -// the ClassLoader is no longer reachable, so no classes it has ever loaded are -// still reachable). -// -// Similarly, it may happen that the weak reference to the Class becomes null -// while the reference to the ClassLoader remains non-null, in which case the -// Class is simply re-loaded. -// -// This code is close to the implementation of jvmaccess::ClassPath::loadClass -// in jvmaccess/classpath.hxx, but not close enough to avoid the duplication. -// -// If false is returned, a (still pending) JNI exception occurred. -bool loadClass( - Reference< XComponentContext > const & context, JNIEnv& environment, - rtl::OUString const & classPath, rtl::OUString const & name, - LocalRef< jobject > * classLoaderPtr, LocalRef< jclass > * classPtr) -{ - OSL_ASSERT(classLoaderPtr != NULL); - // For any jweak entries still present in the map upon destruction, - // DeleteWeakGlobalRef is not called (which is a leak): - ClassMapData * d = - rtl_Instance< ClassMapData, ClassMapDataInit, osl::MutexGuard, - osl::GetGlobalMutex >::create( - ClassMapDataInit(), osl::GetGlobalMutex()); - osl::MutexGuard g(d->mutex); - ClassMap::iterator i(d->map.begin()); - LocalRef< jobject > cloader(environment); - LocalRef< jclass > cl(environment); - // Prune dangling weak references from the list while searching for a match, - // so that the list cannot grow unbounded: - for (; i != d->map.end();) - { - LocalRef< jobject > classLoader( environment ); - if ( !getLocalFromWeakRef( i->classLoader, classLoader ) ) - return false; - - LocalRef< jclass > classObject( environment ); - if ( !getLocalFromWeakRef( i->classObject, classObject ) ) - return false; - - if ( !classLoader.is() && !classObject.is() ) - { - i = d->map.erase(i); - } - else if ( i->classPath == classPath && i->className == name ) - { - cloader.set( classLoader.release() ); - cl.set( classObject.release() ); - break; - } - else - { - ++i; - } - } - if ( !cloader.is() || !cl.is() ) - { - if ( i == d->map.end() ) - { - // Push a new ClassMapEntry (which can potentially fail) before - // loading the class, so that it never happens that a class is - // loaded but not added to the map (which could have effects on the - // JVM that are not easily undone). If the pushed ClassMapEntry is - // not used after all (return false, etc.) it will be pruned on next - // call because its classLoader/classObject are null: - d->map.push_front( ClassMapEntry( classPath, name ) ); - i = d->map.begin(); - } - - LocalRef< jclass > clClass( environment ); - clClass.set( environment.FindClass( "java/net/URLClassLoader" ) ); - if ( !clClass.is() ) - return false; - - jweak wcloader = NULL; - if (!cloader.is()) - { - jmethodID ctorLoader( environment.GetMethodID( clClass.get(), "<init>", "([Ljava/net/URL;)V" ) ); - if (ctorLoader == NULL) - return false; - - LocalRef< jobjectArray > arr( environment ); - arr.set( jvmaccess::ClassPath::translateToUrls( context, &environment, classPath ) ); - if ( !arr.is() ) - return false; - - jvalue arg; - arg.l = arr.get(); - cloader.set( environment.NewObjectA( clClass.get(), ctorLoader, &arg ) ); - if ( !cloader.is() ) - return false; - - wcloader = environment.NewWeakGlobalRef( cloader.get() ); - if ( wcloader == NULL ) - return false; - } - - jweak wcl = NULL; - if ( !cl.is() ) - { - jmethodID methLoadClass( environment.GetMethodID( clClass.get(), "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;" ) ); - if ( methLoadClass == NULL ) - return false; - - LocalRef< jstring > str( environment ); - str.set( convertwchar_tToJavaString( &environment, name ) ); - if ( !str.is() ) - return false; - - jvalue arg; - arg.l = str.get(); - cl.set( static_cast< jclass >( environment.CallObjectMethodA( cloader.get(), methLoadClass, &arg ) ) ); - if ( !cl.is() ) - return false; - - wcl = environment.NewWeakGlobalRef( cl.get() ); - if ( wcl == NULL ) - return false; - } - - if ( wcloader != NULL) - { - i->classLoader = wcloader; - } - if ( wcl != NULL ) - { - i->classObject = wcl; - } - } - - classLoaderPtr->set( cloader.release() ); - classPtr->set( cl.release() ); - return true; -} - -} - -//------------------------------------------------------------------------------ -IMPLEMENT_SERVICE_INFO(java_sql_Connection,"com.sun.star.sdbcx.JConnection","com.sun.star.sdbc.Connection"); -//------------------------------------------------------------------------------ -//************************************************************** -//************ Class: java.sql.Connection -//************************************************************** -jclass java_sql_Connection::theClass = 0; - -java_sql_Connection::java_sql_Connection( const java_sql_Driver& _rDriver ) - :java_lang_Object( _rDriver.getContext().getLegacyServiceFactory() ) - ,OSubComponent<java_sql_Connection, java_sql_Connection_BASE>((::cppu::OWeakObject*)(&_rDriver), this) - ,m_pDriver( &_rDriver ) - ,m_pDriverobject(NULL) - ,m_pDriverClassLoader() - ,m_Driver_theClass(NULL) - ,m_aLogger( _rDriver.getLogger() ) - ,m_bParameterSubstitution(sal_False) - ,m_bIgnoreDriverPrivileges(sal_True) - ,m_bIgnoreCurrency(sal_False) -{ -} -// ----------------------------------------------------------------------------- -java_sql_Connection::~java_sql_Connection() -{ - ::rtl::Reference< jvmaccess::VirtualMachine > xTest = java_lang_Object::getVM(); - if ( xTest.is() ) - { - SDBThreadAttach t; - clearObject(*t.pEnv); - - { - if ( m_pDriverobject ) - t.pEnv->DeleteGlobalRef( m_pDriverobject ); - m_pDriverobject = NULL; - if ( m_Driver_theClass ) - t.pEnv->DeleteGlobalRef( m_Driver_theClass ); - m_Driver_theClass = NULL; - } - t.releaseRef(); - } -} -//----------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::release() throw() -{ - relase_ChildImpl(); -} -//------------------------------------------------------------------------------ -void java_sql_Connection::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - - m_aLogger.log( LogLevel::INFO, STR_LOG_SHUTDOWN_CONNECTION ); - - dispose_ChildImpl(); - java_sql_Connection_BASE::disposing(); - - if ( object ) - { - static jmethodID mID(NULL); - callVoidMethod("close",mID); - } -} -// ------------------------------------------------------------------------- -jclass java_sql_Connection::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/Connection"); - return theClass; -} - -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_Connection::getCatalog( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - static jmethodID mID(NULL); - return callStringMethod("getCatalog",mID); -} -// ------------------------------------------------------------------------- -Reference< XDatabaseMetaData > SAL_CALL java_sql_Connection::getMetaData( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - - Reference< XDatabaseMetaData > xMetaData = m_xMetaData; - if(!xMetaData.is()) - { - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/DatabaseMetaData;", mID); - if(out) - { - xMetaData = new java_sql_DatabaseMetaData( t.pEnv, out, *this ); - m_xMetaData = xMetaData; - } - } - - return xMetaData; -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::close( ) throw(SQLException, RuntimeException) -{ - dispose(); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::commit( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethod("commit",mID); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_Connection::isClosed( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - - static jmethodID mID(NULL); - return callBooleanMethod( "isClosed", mID ) && java_sql_Connection_BASE::rBHelper.bDisposed; -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_Connection::isReadOnly( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - static jmethodID mID(NULL); - return callBooleanMethod( "isReadOnly", mID ); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethodWithStringArg("setCatalog",mID,catalog); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::rollback( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethod("rollback",mID); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_Connection::getAutoCommit( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return callBooleanMethod( "getAutoCommit", mID ); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethodWithBoolArg("setReadOnly",mID,readOnly); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethodWithBoolArg("setAutoCommit",mID,autoCommit); -} -// ------------------------------------------------------------------------- -Reference< ::com::sun::star::container::XNameAccess > SAL_CALL java_sql_Connection::getTypeMap( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - callObjectMethod(t.pEnv,"getTypeMap","()Ljava/util/Map;", mID); - // WARNING: the caller becomes the owner of the returned pointer - return 0; -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this ); -} - -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_Connection::getTransactionIsolation( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - static jmethodID mID(NULL); - return callIntMethod("getTransactionIsolation",mID); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setTransactionIsolation",mID,level); -} -// ------------------------------------------------------------------------- -Reference< XStatement > SAL_CALL java_sql_Connection::createStatement( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_CREATE_STATEMENT ); - - SDBThreadAttach t; - java_sql_Statement* pStatement = new java_sql_Statement( t.pEnv, *this ); - Reference< XStatement > xStmt = pStatement; - m_aStatements.push_back( WeakReferenceHelper( xStmt ) ); - - m_aLogger.log( LogLevel::FINE, STR_LOG_CREATED_STATEMENT_ID, pStatement->getStatementObjectID() ); - return xStmt; -} -// ----------------------------------------------------------------------------- -::rtl::OUString java_sql_Connection::transFormPreparedStatement(const ::rtl::OUString& _sSQL) -{ - ::rtl::OUString sSqlStatement = _sSQL; - if ( m_bParameterSubstitution ) - { - try - { - OSQLParser aParser( m_pDriver->getContext().getLegacyServiceFactory() ); - ::rtl::OUString sErrorMessage; - ::rtl::OUString sNewSql; - OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sSQL); - if(pNode) - { // special handling for parameters - OSQLParseNode::substituteParameterNames(pNode); - pNode->parseNodeToStr( sNewSql, this ); - delete pNode; - sSqlStatement = sNewSql; - } - } - catch(const Exception&) - { - } - } - return sSqlStatement; -} -// ------------------------------------------------------------------------- -Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARE_STATEMENT, sql ); - - SDBThreadAttach t; - ::rtl::OUString sSqlStatement = sql; - sSqlStatement = transFormPreparedStatement( sSqlStatement ); - - java_sql_PreparedStatement* pStatement = new java_sql_PreparedStatement( t.pEnv, *this, sSqlStatement ); - Reference< XPreparedStatement > xReturn( pStatement ); - m_aStatements.push_back(WeakReferenceHelper(xReturn)); - - m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARED_STATEMENT_ID, pStatement->getStatementObjectID() ); - return xReturn; -} -// ------------------------------------------------------------------------- -Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARE_CALL, sql ); - - SDBThreadAttach t; - ::rtl::OUString sSqlStatement = sql; - sSqlStatement = transFormPreparedStatement( sSqlStatement ); - - java_sql_CallableStatement* pStatement = new java_sql_CallableStatement( t.pEnv, *this, sSqlStatement ); - Reference< XPreparedStatement > xStmt( pStatement ); - m_aStatements.push_back(WeakReferenceHelper(xStmt)); - - m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARED_CALL_ID, pStatement->getStatementObjectID() ); - return xStmt; -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_Connection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - ::rtl::OUString aStr; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - - // initialize temporary Variable - static const char * cSignature = "(Ljava/lang/String;)Ljava/lang/String;"; - static const char * cMethodName = "nativeSQL"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - // Convert Parameter - jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,sql)); - - jobject out = t.pEnv->CallObjectMethod( object, mID, str.get() ); - aStr = JavaString2String(t.pEnv, (jstring)out ); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } //t.pEnv - - m_aLogger.log( LogLevel::FINER, STR_LOG_NATIVE_SQL, sql, aStr ); - - return aStr; -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Connection::clearWarnings( ) throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethod("clearWarnings",mID); -} -// ------------------------------------------------------------------------- -Any SAL_CALL java_sql_Connection::getWarnings( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID); - // WARNING: the caller becomes the owner of the returned pointer - if( out ) - { - java_sql_SQLWarning_BASE warn_base(t.pEnv, out); - SQLException aAsException( static_cast< starsdbc::SQLException >( java_sql_SQLWarning( warn_base, *this ) ) ); - - // translate to warning - SQLWarning aWarning; - aWarning.Context = aAsException.Context; - aWarning.Message = aAsException.Message; - aWarning.SQLState = aAsException.SQLState; - aWarning.ErrorCode = aAsException.ErrorCode; - aWarning.NextException = aAsException.NextException; - - return makeAny( aWarning ); - } - - return Any(); -} - -// ----------------------------------------------------------------------------- -namespace -{ - ::rtl::OUString lcl_getDriverLoadErrorMessage( const ::connectivity::SharedResources& _aResource,const ::rtl::OUString& _rDriverClass, const ::rtl::OUString& _rDriverClassPath ) - { - ::rtl::OUString sError1( _aResource.getResourceStringWithSubstitution( - STR_NO_CLASSNAME, - "$classname$", _rDriverClass - ) ); - if ( _rDriverClassPath.getLength() ) - { - const ::rtl::OUString sError2( _aResource.getResourceStringWithSubstitution( - STR_NO_CLASSNAME_PATH, - "$classpath$", _rDriverClassPath - ) ); - sError1 += sError2; - } // if ( _rDriverClassPath.getLength() ) - return sError1; - } -} - -// ----------------------------------------------------------------------------- -namespace -{ - bool lcl_setSystemProperties_nothrow( const java::sql::ConnectionLog& _rLogger, - JNIEnv& _rEnv, const Sequence< NamedValue >& _rSystemProperties ) - { - if ( _rSystemProperties.getLength() == 0 ) - // nothing to do - return true; - - LocalRef< jclass > systemClass( _rEnv ); - jmethodID nSetPropertyMethodID = 0; - // retrieve the java.lang.System class - systemClass.set( _rEnv.FindClass( "java/lang/System" ) ); - if ( systemClass.is() ) - { - nSetPropertyMethodID = _rEnv.GetStaticMethodID( - systemClass.get(), "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;" ); - } - - if ( nSetPropertyMethodID == 0 ) - return false; - - for ( const NamedValue* pSystemProp = _rSystemProperties.getConstArray(); - pSystemProp != _rSystemProperties.getConstArray() + _rSystemProperties.getLength(); - ++pSystemProp - ) - { - ::rtl::OUString sValue; - OSL_VERIFY( pSystemProp->Value >>= sValue ); - - _rLogger.log( LogLevel::FINER, STR_LOG_SETTING_SYSTEM_PROPERTY, pSystemProp->Name, sValue ); - - LocalRef< jstring > jName( _rEnv, convertwchar_tToJavaString( &_rEnv, pSystemProp->Name ) ); - LocalRef< jstring > jValue( _rEnv, convertwchar_tToJavaString( &_rEnv, sValue ) ); - - _rEnv.CallStaticObjectMethod( systemClass.get(), nSetPropertyMethodID, jName.get(), jValue.get() ); - LocalRef< jthrowable > throwable( _rEnv, _rEnv.ExceptionOccurred() ); - if ( throwable.is() ) - return false; - } - - return true; - } -} - -// ----------------------------------------------------------------------------- -void java_sql_Connection::loadDriverFromProperties( const ::rtl::OUString& _sDriverClass, const ::rtl::OUString& _sDriverClassPath, - const Sequence< NamedValue >& _rSystemProperties ) -{ - // contains the statement which should be used when query for automatically generated values - ::rtl::OUString sGeneratedValueStatement; - // set to <TRUE/> when we should allow to query for generated values - sal_Bool bAutoRetrievingEnabled = sal_False; - - // first try if the jdbc driver is alraedy registered at the driver manager - SDBThreadAttach t; - try - { - if ( !object ) - { - if ( !lcl_setSystemProperties_nothrow( getLogger(), *t.pEnv, _rSystemProperties ) ) - ThrowLoggedSQLException( getLogger(), t.pEnv, *this ); - - m_pDriverClassLoader.reset(); - - // here I try to find the class for jdbc driver - java_sql_SQLException_BASE::st_getMyClass(); - java_lang_Throwable::st_getMyClass(); - - if ( !_sDriverClass.getLength() ) - { - m_aLogger.log( LogLevel::SEVERE, STR_LOG_NO_DRIVER_CLASS ); - ::dbtools::throwGenericSQLException( - lcl_getDriverLoadErrorMessage( getResources(),_sDriverClass, _sDriverClassPath ), - *this - ); - } - else - { - m_aLogger.log( LogLevel::INFO, STR_LOG_LOADING_DRIVER, _sDriverClass ); - // the driver manager holds the class of the driver for later use - ::std::auto_ptr< java_lang_Class > pDrvClass; - if ( !_sDriverClassPath.getLength() ) - { - // if forName didn't find the class it will throw an exception - pDrvClass = ::std::auto_ptr< java_lang_Class >(java_lang_Class::forName(_sDriverClass)); - } - else - { - LocalRef< jclass > driverClass(t.env()); - LocalRef< jobject > driverClassLoader(t.env()); - - loadClass( - m_pDriver->getContext().getUNOContext(), - t.env(), _sDriverClassPath, _sDriverClass, &driverClassLoader, &driverClass ); - - m_pDriverClassLoader.set( driverClassLoader ); - pDrvClass.reset( new java_lang_Class( t.pEnv, driverClass.release() ) ); - - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - if ( pDrvClass.get() ) - { - LocalRef< jobject > driverObject( t.env() ); - driverObject.set( pDrvClass->newInstanceObject() ); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - m_pDriverobject = driverObject.release(); - - if( t.pEnv && m_pDriverobject ) - m_pDriverobject = t.pEnv->NewGlobalRef( m_pDriverobject ); - - { - jclass tempClass = t.pEnv->GetObjectClass(m_pDriverobject); - if ( m_pDriverobject ) - { - m_Driver_theClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); - t.pEnv->DeleteLocalRef( tempClass ); - } - } - } - m_aLogger.log( LogLevel::INFO, STR_LOG_CONN_SUCCESS ); - } - } - } - catch( const SQLException& e ) - { - throw SQLException( - lcl_getDriverLoadErrorMessage( getResources(),_sDriverClass, _sDriverClassPath ), - *this, - ::rtl::OUString(), - 1000, - makeAny(e) - ); - } - catch( Exception& ) - { - ::dbtools::throwGenericSQLException( - lcl_getDriverLoadErrorMessage( getResources(),_sDriverClass, _sDriverClassPath ), - *this - ); - } - - enableAutoRetrievingEnabled( bAutoRetrievingEnabled ); - setAutoRetrievingStatement( sGeneratedValueStatement ); -} -// ----------------------------------------------------------------------------- -::rtl::OUString java_sql_Connection::impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass) -{ - static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/JDBC/DriverClassPaths")); - ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory( - m_pDriver->getContext().getLegacyServiceFactory(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY); - ::rtl::OUString sURL; - if ( aNamesRoot.isValid() && aNamesRoot.hasByName( _sDriverClass ) ) - { - ::utl::OConfigurationNode aRegisterObj = aNamesRoot.openNode( _sDriverClass ); - OSL_VERIFY( aRegisterObj.getNodeValue( "Path" ) >>= sURL ); - } - return sURL; -} -// ----------------------------------------------------------------------------- -sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, - const Sequence< PropertyValue >& info) -{ - { // initialize the java vm - ::rtl::Reference< jvmaccess::VirtualMachine > xTest = java_lang_Object::getVM(getORB()); - if ( !xTest.is() ) - throwGenericSQLException(STR_NO_JAVA,*this); - } - SDBThreadAttach t; - t.addRef(); // will be released in dtor - if ( !t.pEnv ) - throwGenericSQLException(STR_NO_JAVA,*this); - - ::rtl::OUString sGeneratedValueStatement; // contains the statement which should be used when query for automatically generated values - sal_Bool bAutoRetrievingEnabled = sal_False; // set to <TRUE/> when we should allow to query for generated values - ::rtl::OUString sDriverClassPath,sDriverClass; - Sequence< NamedValue > aSystemProperties; - - ::comphelper::NamedValueCollection aSettings( info ); - sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass ); - sDriverClassPath = aSettings.getOrDefault( "JavaDriverClassPath", sDriverClassPath); - if ( !sDriverClassPath.getLength() ) - sDriverClassPath = impl_getJavaDriverClassPath_nothrow(sDriverClass); - bAutoRetrievingEnabled = aSettings.getOrDefault( "IsAutoRetrievingEnabled", bAutoRetrievingEnabled ); - sGeneratedValueStatement = aSettings.getOrDefault( "AutoRetrievingStatement", sGeneratedValueStatement ); - m_bParameterSubstitution = aSettings.getOrDefault( "ParameterNameSubstitution", m_bParameterSubstitution ); - m_bIgnoreDriverPrivileges = aSettings.getOrDefault( "IgnoreDriverPrivileges", m_bIgnoreDriverPrivileges ); - m_bIgnoreCurrency = aSettings.getOrDefault( "IgnoreCurrency", m_bIgnoreCurrency ); - aSystemProperties = aSettings.getOrDefault( "SystemProperties", aSystemProperties ); - m_aCatalogRestriction = aSettings.getOrDefault( "ImplicitCatalogRestriction", Any() ); - m_aSchemaRestriction = aSettings.getOrDefault( "ImplicitSchemaRestriction", Any() ); - - loadDriverFromProperties( sDriverClass, sDriverClassPath, aSystemProperties ); - - enableAutoRetrievingEnabled(bAutoRetrievingEnabled); - setAutoRetrievingStatement(sGeneratedValueStatement); - - if ( t.pEnv && m_Driver_theClass && m_pDriverobject ) - { - // initialize temporary Variable - static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;"; - static const char * cMethodName = "connect"; - // Java-Call - jmethodID mID = NULL; - if ( !mID ) - mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature ); - if ( mID ) - { - jvalue args[2]; - // convert Parameter - args[0].l = convertwchar_tToJavaString(t.pEnv,url); - java_util_Properties* pProps = createStringPropertyArray(info); - args[1].l = pProps->getJavaObject(); - - LocalRef< jobject > ensureDelete( t.env(), args[0].l ); - - jobject out = NULL; - // In some cases (e.g., - // connectivity/source/drivers/hsqldb/HDriver.cxx:1.24 - // l. 249) the JavaDriverClassPath contains multiple jars, - // as creating the JavaDriverClass instance requires - // (reflective) access to those other jars. Now, if the - // JavaDriverClass is actually loaded by some parent class - // loader (e.g., because its jar is also on the global - // class path), it would still not have access to the - // additional jars on the JavaDriverClassPath. Hence, the - // JavaDriverClassPath class loader is pushed as context - // class loader around the JavaDriverClass instance - // creation: - // #i82222# / 2007-10-15 - { - ContextClassLoaderScope ccl( t.env(), getDriverClassLoader(), getLogger(), *this ); - out = t.pEnv->CallObjectMethod( m_pDriverobject, mID, args[0].l,args[1].l ); - delete pProps, pProps = NULL; - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - - if ( !out ) - m_aLogger.log( LogLevel::SEVERE, STR_LOG_NO_SYSTEM_CONNECTION ); - - if ( out ) - object = t.pEnv->NewGlobalRef( out ); - - if ( object ) - m_aLogger.log( LogLevel::INFO, STR_LOG_GOT_JDBC_CONNECTION, url ); - - m_aConnectionInfo = info; - } //mID - } //t.pEnv - return object != NULL; -} -// ----------------------------------------------------------------------------- - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx deleted file mode 100644 index 8decaa3751..0000000000 --- a/connectivity/source/drivers/jdbc/JDriver.cxx +++ /dev/null @@ -1,258 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/Driver.hxx" -#include "java/lang/Object.hxx" -#include "java/lang/Class.hxx" -#include "java/sql/DriverPropertyInfo.hxx" -#include "java/sql/Connection.hxx" -#include "java/util/Property.hxx" -#include "java/tools.hxx" -#include "connectivity/dbexception.hxx" -#include <jvmfwk/framework.h> -#include "diagnose_ex.h" -#include "resource/jdbc_log.hrc" -#include "resource/common_res.hrc" -#include "resource/sharedresources.hxx" -#include <comphelper/componentcontext.hxx> - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -// ------------------------------------------------------------------------- -java_sql_Driver::java_sql_Driver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) - :m_aContext( _rxFactory ) - ,m_aLogger( m_aContext.getUNOContext(), "sdbcl", "org.openoffice.sdbc.jdbcBridge" ) -{ -} -// -------------------------------------------------------------------------------- -java_sql_Driver::~java_sql_Driver() -{ -} - -// static ServiceInfo -//------------------------------------------------------------------------------ -rtl::OUString java_sql_Driver::getImplementationName_Static( ) throw(RuntimeException) -{ - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sdbc.JDBCDriver")); - // this name is referenced in the configuration and in the jdbc.xml - // Please take care when changing it. -} -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > java_sql_Driver::getSupportedServiceNames_Static( ) throw (RuntimeException) -{ - Sequence< ::rtl::OUString > aSNS( 1 ); - aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.Driver")); - return aSNS; -} -//------------------------------------------------------------------ -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::java_sql_Driver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception ) -{ - return *(new java_sql_Driver(_rxFactory)); -} -// -------------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_Driver::getImplementationName( ) throw(RuntimeException) -{ - return getImplementationName_Static(); -} - -// -------------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_Driver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) -{ - Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); - const ::rtl::OUString* pSupported = aSupported.getConstArray(); - const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); - for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) - ; - - return pSupported != pEnd; -} - -// -------------------------------------------------------------------------------- -Sequence< ::rtl::OUString > SAL_CALL java_sql_Driver::getSupportedServiceNames( ) throw(RuntimeException) -{ - return getSupportedServiceNames_Static(); -} -// ------------------------------------------------------------------------- -Reference< XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUString& url, const - Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) -{ - m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_CONNECTING_URL, url ); - - Reference< XConnection > xOut; - if ( acceptsURL(url ) ) - { - java_sql_Connection* pConnection = new java_sql_Connection( *this ); - xOut = pConnection; - if ( !pConnection->construct(url,info) ) - xOut.clear(); // an error occurred and the java driver didn't throw an exception - else - m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_SUCCESS ); - } - return xOut; -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_Driver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException) -{ - // don't ask the real driver for the url - // I feel responsible for all jdbc url's - sal_Bool bEnabled = sal_False; - OSL_VERIFY_EQUALS( jfw_getEnabled( &bEnabled ), JFW_E_NONE, "error in jfw_getEnabled" ); - static const ::rtl::OUString s_sJdbcPrefix( RTL_CONSTASCII_USTRINGPARAM( "jdbc:" )); - return bEnabled && 0 == url.compareTo(s_sJdbcPrefix, 5); -} -// ------------------------------------------------------------------------- -Sequence< DriverPropertyInfo > SAL_CALL java_sql_Driver::getPropertyInfo( const ::rtl::OUString& url, - const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException) -{ - if ( acceptsURL(url) ) - { - ::std::vector< DriverPropertyInfo > aDriverInfo; - - Sequence< ::rtl::OUString > aBooleanValues(2); - aBooleanValues[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) ); - aBooleanValues[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ); - - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The JDBC driver class name.")) - ,sal_True - ,::rtl::OUString() - ,Sequence< ::rtl::OUString >()) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClassPath")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The class path where to look for the JDBC driver.")) - ,sal_True - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) ) - ,Sequence< ::rtl::OUString >()) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemProperties")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Additional properties to set at java.lang.System before loading the driver.")) - ,sal_True - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) ) - ,Sequence< ::rtl::OUString >()) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParameterNameSubstitution")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Change named parameters with '?'.")) - ,sal_False - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) ) - ,aBooleanValues) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreDriverPrivileges")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Ignore the privileges from the database driver.")) - ,sal_False - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) ) - ,aBooleanValues) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAutoRetrievingEnabled")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Retrieve generated values.")) - ,sal_False - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) ) - ,aBooleanValues) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutoRetrievingStatement")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Auto-increment statement.")) - ,sal_False - ,::rtl::OUString() - ,Sequence< ::rtl::OUString >()) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GenerateASBeforeCorrelationName")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Generate AS before table correlation names.")) - ,sal_False - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) - ,aBooleanValues) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Ignore the currency field from the ResultsetMetaData.")) - ,sal_False - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) ) - ,aBooleanValues) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EscapeDateTime")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Escape date time format.")) - ,sal_False - ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) - ,aBooleanValues) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeInfoSettings")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Defines how the type info of the database metadata should be manipulated.")) - ,sal_False - ,::rtl::OUString( ) - ,Sequence< ::rtl::OUString > ()) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImplicitCatalogRestriction")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The catalog which should be used in getTables calls, when the caller passed NULL.")) - ,sal_False - ,::rtl::OUString( ) - ,Sequence< ::rtl::OUString > ()) - ); - aDriverInfo.push_back(DriverPropertyInfo( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImplicitSchemaRestriction")) - ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The schema which should be used in getTables calls, when the caller passed NULL.")) - ,sal_False - ,::rtl::OUString( ) - ,Sequence< ::rtl::OUString > ()) - ); - return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size()); - } - ::connectivity::SharedResources aResources; - const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); - ::dbtools::throwGenericSQLException(sMessage ,*this); - return Sequence< DriverPropertyInfo >(); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_Driver::getMajorVersion( ) throw(RuntimeException) -{ - return 1; -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_Driver::getMinorVersion( ) throw(RuntimeException) -{ - return 0; -} -// ------------------------------------------------------------------------- - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx deleted file mode 100644 index b5847ba21e..0000000000 --- a/connectivity/source/drivers/jdbc/JStatement.cxx +++ /dev/null @@ -1,831 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" - -#include "java/sql/JStatement.hxx" -#include "java/sql/ResultSet.hxx" -#include "java/sql/Connection.hxx" -#include "java/sql/SQLWarning.hxx" -#include "java/tools.hxx" -#include "java/ContextClassLoader.hxx" -#include <comphelper/property.hxx> -#include <com/sun/star/lang/DisposedException.hpp> -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/sequence.hxx> -#include "TConnection.hxx" -#include <comphelper/types.hxx> -#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> -#include <com/sun/star/sdbc/ResultSetType.hpp> -#include <com/sun/star/sdbc/FetchDirection.hpp> - -#include "resource/jdbc_log.hrc" - -#include <algorithm> -#include <string.h> - -using namespace ::comphelper; -using namespace connectivity; -using namespace ::cppu; -//------------------------------------------------------------------------------ -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -//------------------------------------------------------------------------------ -//************************************************************** -//************ Class: java.sql.Statement -//************************************************************** - -jclass java_sql_Statement_Base::theClass = 0; - -// ------------------------------------------------------------------------- -java_sql_Statement_Base::java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon ) - :java_sql_Statement_BASE(m_aMutex) - ,java_lang_Object( pEnv, NULL ) - ,OPropertySetHelper(java_sql_Statement_BASE::rBHelper) - ,m_pConnection( &_rCon ) - ,m_aLogger( _rCon.getLogger(), java::sql::ConnectionLog::STATEMENT ) - ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY) - ,m_nResultSetType(ResultSetType::FORWARD_ONLY) - ,m_bEscapeProcessing(sal_True) - ,rBHelper(java_sql_Statement_BASE::rBHelper) -{ - m_pConnection->acquire(); -} - -//------------------------------------------------------------------------------ -java_sql_Statement_Base::~java_sql_Statement_Base() -{ -} - -//------------------------------------------------------------------------------ -void SAL_CALL OStatement_BASE2::disposing() -{ - ::osl::MutexGuard aGuard(m_aMutex); - - if ( object ) - { - static jmethodID mID(NULL); - callVoidMethod("close",mID); - } - - ::comphelper::disposeComponent(m_xGeneratedStatement); - if (m_pConnection) - m_pConnection->release(); - m_pConnection = NULL; - - dispose_ChildImpl(); - java_sql_Statement_Base::disposing(); -} -// ------------------------------------------------------------------------- -jclass java_sql_Statement_Base::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/Statement"); - return theClass; -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_Statement_Base::disposing(void) -{ - m_aLogger.log( LogLevel::FINE, STR_LOG_CLOSING_STATEMENT ); - java_sql_Statement_BASE::disposing(); - clearObject(); -} -// ------------------------------------------------------------------------- - -void SAL_CALL OStatement_BASE2::release() throw() -{ - relase_ChildImpl(); -} - -// ------------------------------------------------------------------------- -Any SAL_CALL java_sql_Statement_Base::queryInterface( const Type & rType ) throw(RuntimeException) -{ - if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) ) - return Any(); - Any aRet( java_sql_Statement_BASE::queryInterface(rType) ); - return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType); -} -// ------------------------------------------------------------------------- -Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( ) throw(RuntimeException) -{ - ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), - ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), - ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 )); - - Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes(); - if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() ) - { - ::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(), - ::getCppuType( (const Reference< XGeneratedResultSet > *)0 )); - aOldTypes.realloc(aOldTypes.getLength() - 1); - } - - return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes); -} -// ----------------------------------------------------------------------------- -Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues( ) throw (SQLException, RuntimeException) -{ - m_aLogger.log( LogLevel::FINE, STR_LOG_GENERATED_VALUES ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - jobject out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - // initialize temporary Variable - try - { - static jmethodID mID(NULL); - out = callResultSetMethod(t.env(),"getGeneratedKeys",mID); - } - catch(const SQLException&) - { - // ignore - } - - Reference< XResultSet > xRes; - if ( !out ) - { - OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!"); - if ( m_pConnection ) - { - ::rtl::OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement); - if ( sStmt.getLength() ) - { - m_aLogger.log( LogLevel::FINER, STR_LOG_GENERATED_VALUES_FALLBACK, sStmt ); - ::comphelper::disposeComponent(m_xGeneratedStatement); - m_xGeneratedStatement = m_pConnection->createStatement(); - xRes = m_xGeneratedStatement->executeQuery(sStmt); - } - } - } - else - xRes = new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection, this ); - return xRes; -} - -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_Statement_Base::cancel( ) throw(RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("cancel",mID); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_Statement_Base::close( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - { - ::osl::MutexGuard aGuard( m_aMutex ); - if (java_sql_Statement_BASE::rBHelper.bDisposed) - throw DisposedException(); - } - dispose(); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_Statement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("clearBatch",mID); - } //t.pEnv -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_Statement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_STATEMENT, sql ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - jboolean out(sal_False); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - m_sSqlStatement = sql; - // initialize temporary Variable - static const char * cSignature = "(Ljava/lang/String;)Z"; - static const char * cMethodName = "execute"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - // convert Parameter - jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) ); - { - jdbc::ContextClassLoaderScope ccl( t.env(), - m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(), - m_aLogger, - *this - ); - - out = t.pEnv->CallBooleanMethod( object, mID, str.get() ); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } //t.pEnv - return out; -} -// ------------------------------------------------------------------------- - -Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_QUERY, sql ); - - jobject out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - createStatement(t.pEnv); - m_sSqlStatement = sql; - // initialize temporary variable - static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/ResultSet;"; - static const char * cMethodName = "executeQuery"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - // convert Parameter - jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) ); - { - jdbc::ContextClassLoaderScope ccl( t.env(), - m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(), - m_aLogger, - *this - ); - - out = t.pEnv->CallObjectMethod( object, mID, str.get() ); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } //t.pEnv - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this ); -} -// ------------------------------------------------------------------------- -Reference< XConnection > SAL_CALL java_sql_Statement_Base::getConnection( ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - return (Reference< XConnection >)m_pConnection; -} -// ------------------------------------------------------------------------- - -Any SAL_CALL java_sql_Statement::queryInterface( const Type & rType ) throw(RuntimeException) -{ - Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this)); - return aRet.hasValue() ? aRet : java_sql_Statement_Base::queryInterface(rType); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_Statement::addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethodWithStringArg("addBatch",mID,sql); - } //t.pEnv -} -// ------------------------------------------------------------------------- - -Sequence< sal_Int32 > SAL_CALL java_sql_Statement::executeBatch( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - Sequence< sal_Int32 > aSeq; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID); - if (out) - { - jboolean p = sal_False; - aSeq.realloc(t.pEnv->GetArrayLength(out)); - memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength()); - t.pEnv->DeleteLocalRef(out); - } - return aSeq; -} -// ------------------------------------------------------------------------- - - -sal_Int32 SAL_CALL java_sql_Statement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_UPDATE, sql ); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - m_sSqlStatement = sql; - static jmethodID mID(NULL); - return callIntMethodWithStringArg("executeUpdate",mID,sql); -} -// ------------------------------------------------------------------------- - -Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Statement_Base::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callResultSetMethod(t.env(),"getResultSet",mID); - - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this ); -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_Statement_Base::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - sal_Int32 out = callIntMethod("getUpdateCount",mID); - m_aLogger.log( LogLevel::FINER, STR_LOG_UPDATE_COUNT, (sal_Int32)out ); - return out; -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_Statement_Base::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return callBooleanMethod( "getMoreResults", mID ); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- -Any SAL_CALL java_sql_Statement_Base::getWarnings( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - SDBThreadAttach t; - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID); - // WARNING: the caller becomes the owner of the returned pointer - if( out ) - { - java_sql_SQLWarning_BASE warn_base( t.pEnv, out ); - return makeAny( - static_cast< starsdbc::SQLException >( - java_sql_SQLWarning(warn_base,*(::cppu::OWeakObject*)this))); - } - - return Any(); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_Statement_Base::clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; - - { - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("clearWarnings",mID); - } -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::getQueryTimeOut() throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_getProperty("getQueryTimeOut",mID); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::getMaxRows() throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_getProperty("getMaxRows",mID); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::getResultSetConcurrency() throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_getProperty("getResultSetConcurrency",mID,m_nResultSetConcurrency); -} - -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::getResultSetType() throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_getProperty("getResultSetType",mID,m_nResultSetType); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault) -{ - sal_Int32 out = _nDefault; - if ( object ) - out = callIntMethod(_pMethodName,_inout_MethodID,true); - - return out; -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - return callIntMethod(_pMethodName,_inout_MethodID,true); -} - -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::getFetchDirection() throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_getProperty("getFetchDirection",mID); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::getFetchSize() throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_getProperty("getFetchSize",mID); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_Statement_Base::getMaxFieldSize() throw(SQLException, RuntimeException) -{ - static jmethodID mID(NULL); - return impl_getProperty("getMaxFieldSize",mID); -} -//------------------------------------------------------------------------------ -::rtl::OUString java_sql_Statement_Base::getCursorName() throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - try - { - return callStringMethod("getCursorName",mID); - } - catch(const SQLException&) - { - } - return ::rtl::OUString(); -} -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setQueryTimeOut(sal_Int32 _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setQueryTimeOut",mID,_par0,true); -} - -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setEscapeProcessing(sal_Bool _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_SET_ESCAPE_PROCESSING, _par0 ); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - m_bEscapeProcessing = _par0; - createStatement( t.pEnv ); - static jmethodID mID(NULL); - callVoidMethodWithBoolArg("setEscapeProcessing",mID,_par0,true); -} - -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setMaxRows",mID,_par0,true); -} -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_CONCURRENCY, (sal_Int32)_par0 ); - m_nResultSetConcurrency = _par0; - - clearObject(); -} -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_TYPE, (sal_Int32)_par0 ); - m_nResultSetType = _par0; - - clearObject(); -} -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_DIRECTION, (sal_Int32)_par0 ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true); -} -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_SIZE, (sal_Int32)_par0 ); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchSize",mID,_par0,true); -} -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setMaxFieldSize",mID,_par0,true); -} -//------------------------------------------------------------------------------ -void java_sql_Statement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethodWithStringArg("setCursorName",mID,_par0); - } //t.pEnv -} - -// ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper* java_sql_Statement_Base::createArrayHelper( ) const -{ - Sequence< Property > aProps(10); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - DECL_PROP0(CURSORNAME, ::rtl::OUString); - DECL_BOOL_PROP0(ESCAPEPROCESSING); - DECL_PROP0(FETCHDIRECTION,sal_Int32); - DECL_PROP0(FETCHSIZE, sal_Int32); - DECL_PROP0(MAXFIELDSIZE,sal_Int32); - DECL_PROP0(MAXROWS, sal_Int32); - DECL_PROP0(QUERYTIMEOUT,sal_Int32); - DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32); - DECL_PROP0(RESULTSETTYPE,sal_Int32); - DECL_BOOL_PROP0(USEBOOKMARKS); - - return new ::cppu::OPropertyArrayHelper(aProps); -} - -// ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper & java_sql_Statement_Base::getInfoHelper() - -{ - return *const_cast<java_sql_Statement_Base*>(this)->getArrayHelper(); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_Statement_Base::convertFastPropertyValue( - Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException) -{ - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut()); - case PROPERTY_ID_MAXFIELDSIZE: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize()); - case PROPERTY_ID_MAXROWS: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows()); - case PROPERTY_ID_CURSORNAME: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName()); - case PROPERTY_ID_RESULTSETCONCURRENCY: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency()); - case PROPERTY_ID_RESULTSETTYPE: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType()); - case PROPERTY_ID_FETCHDIRECTION: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); - case PROPERTY_ID_FETCHSIZE: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); - case PROPERTY_ID_ESCAPEPROCESSING: - return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEscapeProcessing ); - case PROPERTY_ID_USEBOOKMARKS: - // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); - default: - ; - } - return sal_False; -} -// ------------------------------------------------------------------------- -void java_sql_Statement_Base::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const Any& rValue - ) - throw (Exception) -{ - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - setQueryTimeOut(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_MAXFIELDSIZE: - setMaxFieldSize(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_MAXROWS: - setMaxRows(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_CURSORNAME: - setCursorName(comphelper::getString(rValue)); - break; - case PROPERTY_ID_RESULTSETCONCURRENCY: - setResultSetConcurrency(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_RESULTSETTYPE: - setResultSetType(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_FETCHDIRECTION: - setFetchDirection(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_FETCHSIZE: - setFetchSize(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_ESCAPEPROCESSING: - setEscapeProcessing( ::comphelper::getBOOL( rValue ) ); - break; - case PROPERTY_ID_USEBOOKMARKS: - // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink); - default: - ; - } -} -// ------------------------------------------------------------------------- -void java_sql_Statement_Base::getFastPropertyValue( - Any& rValue, - sal_Int32 nHandle - ) const -{ - java_sql_Statement_Base* THIS = const_cast<java_sql_Statement_Base*>(this); - try - { - switch(nHandle) - { - case PROPERTY_ID_QUERYTIMEOUT: - rValue <<= THIS->getQueryTimeOut(); - break; - case PROPERTY_ID_MAXFIELDSIZE: - rValue <<= THIS->getMaxFieldSize(); - break; - case PROPERTY_ID_MAXROWS: - rValue <<= THIS->getMaxRows(); - break; - case PROPERTY_ID_CURSORNAME: - rValue <<= THIS->getCursorName(); - break; - case PROPERTY_ID_RESULTSETCONCURRENCY: - rValue <<= THIS->getResultSetConcurrency(); - break; - case PROPERTY_ID_RESULTSETTYPE: - rValue <<= THIS->getResultSetType(); - break; - case PROPERTY_ID_FETCHDIRECTION: - rValue <<= THIS->getFetchDirection(); - break; - case PROPERTY_ID_FETCHSIZE: - rValue <<= THIS->getFetchSize(); - break; - case PROPERTY_ID_ESCAPEPROCESSING: - rValue <<= (sal_Bool)m_bEscapeProcessing; - break; - case PROPERTY_ID_USEBOOKMARKS: - default: - ; - } - } - catch(const Exception&) - { - } -} -// ------------------------------------------------------------------------- -jclass java_sql_Statement::theClass = 0; - -java_sql_Statement::~java_sql_Statement() -{} - -jclass java_sql_Statement::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/Statement"); - return theClass; -} - -// ----------------------------------------------------------------------------- -void java_sql_Statement::createStatement(JNIEnv* _pEnv) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - if( _pEnv && !object ){ - // initialize temporary variable - static const char * cSignature = "(II)Ljava/sql/Statement;"; - static const char * cMethodName = "createStatement"; - // Java-Call - jobject out = NULL; - static jmethodID mID(NULL); - if ( !mID ) - mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature ); - if( mID ){ - out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID,m_nResultSetType,m_nResultSetConcurrency ); - } //mID - else - { - static const char * cSignature2 = "()Ljava/sql/Statement;"; - static jmethodID mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!"); - if( mID2 ){ - out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2); - } //mID - } - ThrowLoggedSQLException( m_aLogger, _pEnv, *this ); - - if ( out ) - object = _pEnv->NewGlobalRef( out ); - } //_pEnv -} -// ----------------------------------------------------------------------------- - - -IMPLEMENT_SERVICE_INFO(java_sql_Statement,"com.sun.star.sdbcx.JStatement","com.sun.star.sdbc.Statement"); -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_Statement_Base::acquire() throw() -{ - java_sql_Statement_BASE::acquire(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_Statement_Base::release() throw() -{ - java_sql_Statement_BASE::release(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_Statement::acquire() throw() -{ - OStatement_BASE2::acquire(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_Statement::release() throw() -{ - OStatement_BASE2::release(); -} -// ----------------------------------------------------------------------------- -::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL java_sql_Statement_Base::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) -{ - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} -// ----------------------------------------------------------------------------- - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx deleted file mode 100644 index a78d8fe3de..0000000000 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ /dev/null @@ -1,428 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" - - -#include "java/lang/Class.hxx" -#include "connectivity/CommonTools.hxx" -#include <com/sun/star/uno/Exception.hpp> -#include "java/tools.hxx" -#include "java/sql/SQLException.hxx" -#include <osl/mutex.hxx> -#include <osl/thread.h> -#include <com/sun/star/uno/Sequence.hxx> -#include "java/LocalRef.hxx" -#include "resource/jdbc_log.hrc" -#include <rtl/logfile.hxx> -#include <comphelper/logging.hxx> - -#include <memory> - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - - -// ----------------------------------------------------------------------------- -::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM2(const ::rtl::Reference< jvmaccess::VirtualMachine >& _rVM = ::rtl::Reference< jvmaccess::VirtualMachine >(), - sal_Bool _bSet = sal_False) -{ - static ::rtl::Reference< jvmaccess::VirtualMachine > s_VM; - if ( _rVM.is() || _bSet ) - s_VM = _rVM; - return s_VM; -} -// ----------------------------------------------------------------------------- -::rtl::Reference< jvmaccess::VirtualMachine > java_lang_Object::getVM(const Reference<XMultiServiceFactory >& _rxFactory) -{ - ::rtl::Reference< jvmaccess::VirtualMachine > xVM = getJavaVM2(); - if ( !xVM.is() && _rxFactory.is() ) - xVM = getJavaVM2(::connectivity::getJavaVM(_rxFactory)); - - return xVM; -} -// ----------------------------------------------------------------------------- -SDBThreadAttach::SDBThreadAttach() - : m_aGuard(java_lang_Object::getVM()) - , pEnv(NULL) -{ - pEnv = m_aGuard.getEnvironment(); - OSL_ENSURE(pEnv,"Environment is nULL!"); -} -// ----------------------------------------------------------------------------- -SDBThreadAttach::~SDBThreadAttach() -{ -} -// ----------------------------------------------------------------------------- -oslInterlockedCount& getJavaVMRefCount() -{ - static oslInterlockedCount s_nRefCount = 0; - return s_nRefCount; -} -// ----------------------------------------------------------------------------- -void SDBThreadAttach::addRef() -{ - osl_incrementInterlockedCount(&getJavaVMRefCount()); -} -// ----------------------------------------------------------------------------- -void SDBThreadAttach::releaseRef() -{ - osl_decrementInterlockedCount(&getJavaVMRefCount()); - if ( getJavaVMRefCount() == 0 ) - { - getJavaVM2(::rtl::Reference< jvmaccess::VirtualMachine >(),sal_True); - } -} -// ----------------------------------------------------------------------------- -// static variables of the class -jclass java_lang_Object::theClass = 0; - -jclass java_lang_Object::getMyClass() const -{ - if( !theClass ) - theClass = findMyClass("java/lang/Object"); - return theClass; -} -// the actual constructor -java_lang_Object::java_lang_Object(const Reference<XMultiServiceFactory >& _rxFactory) - : m_xFactory(_rxFactory),object( 0 ) -{ - SDBThreadAttach::addRef(); -} - -// the protected-constructor for the derived classes -java_lang_Object::java_lang_Object( JNIEnv * pXEnv, jobject myObj ) - : object( NULL ) -{ - SDBThreadAttach::addRef(); - if( pXEnv && myObj ) - object = pXEnv->NewGlobalRef( myObj ); -} - -java_lang_Object::~java_lang_Object() -{ - if( object ) - { - SDBThreadAttach t; - clearObject(*t.pEnv); - } - SDBThreadAttach::releaseRef(); -} -void java_lang_Object::clearObject(JNIEnv& rEnv) -{ - if( object ) - { - rEnv.DeleteGlobalRef( object ); - object = NULL; - } -} - -void java_lang_Object::clearObject() -{ - if( object ) - { - SDBThreadAttach t; - clearObject(*t.pEnv); - } -} -// the protected-constructor for the derived classes -void java_lang_Object::saveRef( JNIEnv * pXEnv, jobject myObj ) -{ - OSL_ENSURE( myObj, "object in c++ -> Java Wrapper" ); - if( myObj ) - object = pXEnv->NewGlobalRef( myObj ); -} - - -::rtl::OUString java_lang_Object::toString() const -{ - static jmethodID mID(NULL); - return callStringMethod("toString",mID); -} - -// -------------------------------------------------------------------------------- -namespace -{ - bool lcl_translateJNIExceptionToUNOException( - JNIEnv* _pEnvironment, const Reference< XInterface >& _rxContext, SQLException& _out_rException ) - { - jthrowable jThrow = _pEnvironment ? _pEnvironment->ExceptionOccurred() : NULL; - if ( !jThrow ) - return false; - - _pEnvironment->ExceptionClear(); - // we have to clear the exception here because we want to handle it itself - - if ( _pEnvironment->IsInstanceOf( jThrow, java_sql_SQLException_BASE::st_getMyClass() ) ) - { - ::std::auto_ptr< java_sql_SQLException_BASE > pException( new java_sql_SQLException_BASE( _pEnvironment, jThrow ) ); - _out_rException = SQLException( pException->getMessage(), _rxContext, - pException->getSQLState(), pException->getErrorCode(), Any() ); - return true; - } - else if ( _pEnvironment->IsInstanceOf( jThrow, java_lang_Throwable::st_getMyClass() ) ) - { - ::std::auto_ptr< java_lang_Throwable > pThrow( new java_lang_Throwable( _pEnvironment, jThrow ) ); - ::rtl::OUString sMessage = pThrow->getMessage(); - if ( !sMessage.getLength() ) - sMessage = pThrow->getLocalizedMessage(); - if( !sMessage.getLength() ) - sMessage = pThrow->toString(); - _out_rException = SQLException( sMessage, _rxContext, ::rtl::OUString(), -1, Any() ); - return true; - } - else - _pEnvironment->DeleteLocalRef( jThrow ); - return false; - } -} - -// -------------------------------------------------------------------------------- -void java_lang_Object::ThrowLoggedSQLException( const ::comphelper::ResourceBasedEventLogger& _rLogger, JNIEnv* _pEnvironment, - const Reference< XInterface >& _rxContext ) -{ - SQLException aException; - if ( lcl_translateJNIExceptionToUNOException( _pEnvironment, _rxContext, aException ) ) - { - _rLogger.log( ::com::sun::star::logging::LogLevel::SEVERE, STR_LOG_THROWING_EXCEPTION, aException.Message, aException.SQLState, aException.ErrorCode ); - throw aException; - } -} - -// -------------------------------------------------------------------------------- -void java_lang_Object::ThrowSQLException( JNIEnv* _pEnvironment, const Reference< XInterface>& _rxContext ) -{ - SQLException aException; - if ( lcl_translateJNIExceptionToUNOException( _pEnvironment, _rxContext, aException ) ) - throw aException; -} -// ----------------------------------------------------------------------------- -void java_lang_Object::obtainMethodId(JNIEnv* _pEnv,const char* _pMethodName, const char* _pSignature,jmethodID& _inout_MethodID) const -{ - if ( !_inout_MethodID ) - { - _inout_MethodID = _pEnv->GetMethodID( getMyClass(), _pMethodName, _pSignature ); - OSL_ENSURE( _inout_MethodID, _pSignature ); - if ( !_inout_MethodID ) - throw SQLException(); - } // if ( !_inout_MethodID ) -} -// ----------------------------------------------------------------------------- -sal_Bool java_lang_Object::callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const -{ - jboolean out( sal_False ); - - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethod: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"()Z", _inout_MethodID); - // call method - out = t.pEnv->CallBooleanMethod( object, _inout_MethodID ); - ThrowSQLException( t.pEnv, NULL ); - - return out; -} -// ----------------------------------------------------------------------------- -sal_Bool java_lang_Object::callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const -{ - jboolean out( sal_False ); - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethodWithIntArg: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"(I)Z", _inout_MethodID); - // call method - out = t.pEnv->CallBooleanMethod( object, _inout_MethodID, _nArgument ); - ThrowSQLException( t.pEnv, NULL ); - - return out; -} -// ------------------------------------------------------------------------- -jobject java_lang_Object::callResultSetMethod( JNIEnv& _rEnv,const char* _pMethodName, jmethodID& _inout_MethodID ) const -{ - // call method - jobject out = callObjectMethod(&_rEnv,_pMethodName,"()Ljava/sql/ResultSet;", _inout_MethodID); - return out; -} -// ------------------------------------------------------------------------- -sal_Int32 java_lang_Object::callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException ) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"()I", _inout_MethodID); - - // call method - jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) ); - if ( _bIgnoreException ) - isExceptionOccurred(t.pEnv,sal_True); - else - ThrowSQLException( t.pEnv, NULL ); - - return (sal_Int32)out; -} -// ------------------------------------------------------------------------- -sal_Int32 java_lang_Object::callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"(I)I", _inout_MethodID); - // call method - jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) ); - ThrowSQLException( t.pEnv, NULL ); - - return (sal_Int32)out; -} -// ------------------------------------------------------------------------- -void java_lang_Object::callVoidMethod( const char* _pMethodName, jmethodID& _inout_MethodID) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"()V", _inout_MethodID); - - // call method - t.pEnv->CallVoidMethod( object, _inout_MethodID ); - ThrowSQLException( t.pEnv, NULL ); -} -// ------------------------------------------------------------------------- -void java_lang_Object::callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException ) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"(I)V", _inout_MethodID); - - // call method - t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument ); - if ( _bIgnoreException ) - isExceptionOccurred(t.pEnv,sal_True); - else - ThrowSQLException( t.pEnv, NULL ); -} -// ------------------------------------------------------------------------- -void java_lang_Object::callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException ) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"(Z)V", _inout_MethodID); - // call method - t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument ); - if ( _bIgnoreException ) - isExceptionOccurred(t.pEnv,sal_True); - else - ThrowSQLException( t.pEnv, NULL ); -} -// ----------------------------------------------------------------------------- -::rtl::OUString java_lang_Object::callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java enviroment anymore!" ); - - // call method - jstring out = (jstring)callObjectMethod(t.pEnv,_pMethodName,"()Ljava/lang/String;", _inout_MethodID); - return JavaString2String( t.pEnv, out ); -} -// ----------------------------------------------------------------------------- -jobject java_lang_Object::callObjectMethod( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID ) const -{ - // obtain method ID - obtainMethodId(_pEnv, _pMethodName,_pSignature, _inout_MethodID); - // call method - jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID); - ThrowSQLException( _pEnv, NULL ); - return out; -} - -// ----------------------------------------------------------------------------- -jobject java_lang_Object::callObjectMethodWithIntArg( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const -{ - obtainMethodId(_pEnv, _pMethodName,_pSignature, _inout_MethodID); - // call method - jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID,_nArgument ); - ThrowSQLException( _pEnv, NULL ); - return out; -} -// ----------------------------------------------------------------------------- -::rtl::OUString java_lang_Object::callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java enviroment anymore!" ); - jstring out = (jstring)callObjectMethodWithIntArg(t.pEnv,_pMethodName,"(I)Ljava/lang/String;",_inout_MethodID,_nArgument); - return JavaString2String( t.pEnv, out ); -} -// ------------------------------------------------------------------------- -void java_lang_Object::callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)V", _inout_MethodID); - - jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument)); - // call method - t.pEnv->CallVoidMethod( object, _inout_MethodID , str.get()); - ThrowSQLException( t.pEnv, NULL ); -} -// ------------------------------------------------------------------------- -sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const -{ - SDBThreadAttach t; - OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethodWithStringArg: no Java enviroment anymore!" ); - obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)I", _inout_MethodID); - - //TODO: Check if the code below is needed - //jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) ); - //{ - // jdbc::ContextClassLoaderScope ccl( t.env(), - // m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(), - // m_aLogger, - // *this - // ); - - jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument)); - // call method - jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str.get()); - ThrowSQLException( t.pEnv, NULL ); - return (sal_Int32)out; -} -// ----------------------------------------------------------------------------- -jclass java_lang_Object::findMyClass(const char* _pClassName) -{ - // the class must be fetched only once, therefore static - SDBThreadAttach t; - jclass tempClass = t.pEnv->FindClass(_pClassName); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!"); - if(!tempClass) - { - t.pEnv->ExceptionDescribe(); - t.pEnv->ExceptionClear(); - } - jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass ); - t.pEnv->DeleteLocalRef( tempClass ); - return globClass; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx deleted file mode 100644 index 5c112dd70e..0000000000 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ /dev/null @@ -1,668 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/PreparedStatement.hxx" -#include "java/sql/ResultSet.hxx" -#include "java/sql/ResultSetMetaData.hxx" -#include "java/sql/Connection.hxx" -#include "java/sql/Timestamp.hxx" -#include "java/math/BigDecimal.hxx" -#include "java/tools.hxx" -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/sequence.hxx> -#include "connectivity/dbtools.hxx" -#include "connectivity/FValue.hxx" -#include "connectivity/dbexception.hxx" -#include "resource/jdbc_log.hrc" -#include "resource/common_res.hrc" -#include "resource/sharedresources.hxx" -#include "java/LocalRef.hxx" -#include <string.h> - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -//************************************************************** -//************ Class: java.sql.PreparedStatement -//************************************************************** -IMPLEMENT_SERVICE_INFO(java_sql_PreparedStatement,"com.sun.star.sdbcx.JPreparedStatement","com.sun.star.sdbc.PreparedStatement"); - -java_sql_PreparedStatement::java_sql_PreparedStatement( JNIEnv * pEnv, java_sql_Connection& _rCon, const ::rtl::OUString& sql ) - : OStatement_BASE2( pEnv, _rCon ) -{ - m_sSqlStatement = sql; -} -// ----------------------------------------------------------------------------- -jclass java_sql_PreparedStatement::theClass = 0; - -java_sql_PreparedStatement::~java_sql_PreparedStatement() -{ -} -// ----------------------------------------------------------------------------- - -jclass java_sql_PreparedStatement::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/PreparedStatement"); - return theClass; -} -// ------------------------------------------------------------------------- - -::com::sun::star::uno::Any SAL_CALL java_sql_PreparedStatement::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Any aRet = OStatement_BASE2::queryInterface(rType); - return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, - static_cast< XPreparedStatement*>(this), - static_cast< XParameters*>(this), - static_cast< XResultSetMetaDataSupplier*>(this), - static_cast< XPreparedBatchExecution*>(this)); -} -// ------------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_PreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) -{ - ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), - ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), - ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ), - ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 )); - - return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes()); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_PreparedStatement::execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - static jmethodID mID(NULL); - return callBooleanMethod( "execute", mID ); -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_UPDATE ); - static jmethodID mID(NULL); - return callIntMethod("executeUpdate",mID); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - m_aLogger.log( LogLevel::FINER, STR_LOG_STRING_PARAMETER, parameterIndex, x ); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { // initialize temporary Variable - createStatement(t.pEnv); - static const char * cSignature = "(ILjava/lang/String;)V"; - static const char * cMethodName = "setString"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x)); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,str.get()); - // and clean up - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } //t.pEnv -} -// ------------------------------------------------------------------------- - -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL java_sql_PreparedStatement::getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - return (Reference< XConnection >)m_pConnection; -} -// ------------------------------------------------------------------------- - -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_PreparedStatement::executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_QUERY ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callResultSetMethod(t.env(),"executeQuery",mID); - - return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_BOOLEAN_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setBoolean", "(IZ)V", mID, parameterIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_BYTE_PARAMETER, parameterIndex, (sal_Int32)x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setByte", "(IB)V", mID, parameterIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_DATE_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - java_sql_Date aT(x); - static jmethodID mID(NULL); - callVoidMethod("setDate", "(ILjava/sql/Date;)V", mID, parameterIndex, aT.getJavaObject()); -} -// ------------------------------------------------------------------------- - - -void SAL_CALL java_sql_PreparedStatement::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_TIME_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - java_sql_Time aT(x); - static jmethodID mID(NULL); - callVoidMethod("setTime", "(ILjava/sql/Time;)V", mID, parameterIndex, aT.getJavaObject()); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_TIMESTAMP_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - java_sql_Timestamp aD(x); - callVoidMethod("setTimestamp", "(ILjava/sql/Timestamp;)V", mID, parameterIndex, aD.getJavaObject()); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_PreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_DOUBLE_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setDouble", "(ID)V", mID, parameterIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_FLOAT_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setFloat", "(IF)V", mID, parameterIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_INT_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setInt", "(II)V", mID, parameterIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_LONG_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setLong", "(IJ)V", mID, parameterIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_NULL_PARAMETER, parameterIndex, sqlType ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setNull", "(II)V", mID, parameterIndex, sqlType); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this ); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this ); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this ); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this ); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - - // initialize temporary Variable - static const char * cSignature = "(ILjava/lang/Object;II)V"; - static const char * cMethodName = "setObject"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - { - jobject obj = NULL; - double nTemp = 0.0; - switch(targetSqlType) - { - case DataType::DECIMAL: - case DataType::NUMERIC: - { - ::std::auto_ptr<java_math_BigDecimal> pBigDecimal; - if ( x >>= nTemp) - { - pBigDecimal.reset(new java_math_BigDecimal(nTemp)); - //setDouble(parameterIndex,nTemp); - //return; - } - else - { - ORowSetValue aValue; - aValue.fill(x); - const ::rtl::OUString sValue = aValue; - if ( sValue.getLength() ) - pBigDecimal.reset(new java_math_BigDecimal(sValue)); - else - pBigDecimal.reset(new java_math_BigDecimal(0.0)); - } - //obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x)); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,pBigDecimal->getJavaObject(),targetSqlType,scale); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - return; - } - default: - obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x)); - break; - } - t.pEnv->CallVoidMethod( object, mID, parameterIndex,obj,targetSqlType,scale); - t.pEnv->DeleteLocalRef(obj); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - // and clean up - } //mID - } //t.pEnv -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/, const ::rtl::OUString& /*typeName*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod<jobject>("setObject", "(ILjava/lang/Object;)V", mID, parameterIndex, NULL); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - if(!::dbtools::implSetObject(this,parameterIndex,x)) - { - const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution( - STR_UNKNOWN_PARA_TYPE, - "$position$", ::rtl::OUString::valueOf(parameterIndex) - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_SHORT_PARAMETER, parameterIndex, x ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("setShort", "(IS)V", mID, parameterIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_BYTES_PARAMETER, parameterIndex ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - - // initialize temporary Variable - static const char * cSignature = "(I[B)V"; - static const char * cMethodName = "setBytes"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jbyteArray pByteArray = t.pEnv->NewByteArray(x.getLength()); - t.pEnv->SetByteArrayRegion(pByteArray,0,x.getLength(),(jbyte*)x.getConstArray()); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,pByteArray); - t.pEnv->DeleteLocalRef(pByteArray); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } //t.pEnv -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_CHARSTREAM_PARAMETER, parameterIndex ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - - // initialize temporary variable - static const char * cSignature = "(ILjava/io/InputStream;I)V"; - static const char * cMethodName = "setCharacterStream"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - Sequence< sal_Int8 > aSeq; - if ( x.is() ) - x->readBytes( aSeq, length ); - sal_Int32 actualLength = aSeq.getLength(); - - jvalue args2[3]; - jbyteArray pByteArray = t.pEnv->NewByteArray( actualLength ); - t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray()); - args2[0].l = pByteArray; - args2[1].i = 0; - args2[2].i = actualLength; - // initialize temporary variable - const char * cSignatureStream = "([BII)V"; - // Java-Call - jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream"); - static jmethodID mID2 = NULL; - if ( !mID2 ) - mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream ); - jobject tempObj = NULL; - if(mID2) - tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 ); - - t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,actualLength); - // and clean up - t.pEnv->DeleteLocalRef(pByteArray); - t.pEnv->DeleteLocalRef(tempObj); - t.pEnv->DeleteLocalRef(aClass); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } //t.pEnv -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_BINARYSTREAM_PARAMETER, parameterIndex ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - // initialize temporary variable - static const char * cSignature = "(ILjava/io/InputStream;I)V"; - static const char * cMethodName = "setBinaryStream"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - { - Sequence< sal_Int8 > aSeq; - if ( x.is() ) - x->readBytes( aSeq, length ); - sal_Int32 actualLength = aSeq.getLength(); - - jvalue args2[3]; - jbyteArray pByteArray = t.pEnv->NewByteArray(actualLength); - t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray()); - args2[0].l = pByteArray; - args2[1].i = 0; - args2[2].i = (sal_Int32)actualLength; - - // initialize temporary variable - const char * cSignatureStream = "([BII)V"; - // Java-Call - jclass aClass = t.pEnv->FindClass("java/io/ByteArrayInputStream"); - static jmethodID mID2 = NULL; - if ( !mID2 ) - mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream ); - jobject tempObj = NULL; - if(mID2) - tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 ); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,(sal_Int32)actualLength); - // and clean up - t.pEnv->DeleteLocalRef(pByteArray); - t.pEnv->DeleteLocalRef(tempObj); - t.pEnv->DeleteLocalRef(aClass); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } //t.pEnv -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - m_aLogger.log( LogLevel::FINER, STR_LOG_CLEAR_PARAMETERS ); - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - SDBThreadAttach t; - { - createStatement(t.pEnv); - - static jmethodID mID(NULL); - callVoidMethod("clearParameters",mID); - } //t.pEnv -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_PreparedStatement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("clearBatch",mID); - } //t.pEnv -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - createStatement(t.pEnv); - static jmethodID mID(NULL); - callVoidMethod("addBatch",mID); - } //t.pEnv -} -// ------------------------------------------------------------------------- - -::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL java_sql_PreparedStatement::executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - ::com::sun::star::uno::Sequence< sal_Int32 > aSeq; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID); - if(out) - { - jboolean p = sal_False; - aSeq.realloc(t.pEnv->GetArrayLength(out)); - memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength()); - t.pEnv->DeleteLocalRef(out); - } - return aSeq; -} -// ------------------------------------------------------------------------- -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_PreparedStatement::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - createStatement(t.pEnv); - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/ResultSetMetaData;", mID); - - return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection ); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_PreparedStatement::acquire() throw() -{ - OStatement_BASE2::acquire(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_PreparedStatement::release() throw() -{ - OStatement_BASE2::release(); -} -// ----------------------------------------------------------------------------- -void java_sql_PreparedStatement::createStatement(JNIEnv* _pEnv) -{ - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); - - if( !object && _pEnv ){ - // initialize temporary variable - static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/PreparedStatement;"; - static const char * cMethodName = "prepareStatement"; - - jvalue args[1]; - // convert Parameter - args[0].l = convertwchar_tToJavaString(_pEnv,m_sSqlStatement); - // Java-Call - jobject out = NULL; - static jmethodID mID(NULL); - if ( !mID ) - mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature ); - if( mID ) - { - out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, args[0].l ,m_nResultSetType,m_nResultSetConcurrency); - } - else - { - static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/PreparedStatement;"; - static jmethodID mID2 = NULL; - if ( !mID2) - mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID,"Unknown method id!"); - if ( mID2 ) - out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, args[0].l ); - } - _pEnv->DeleteLocalRef((jstring)args[0].l); - ThrowLoggedSQLException( m_aLogger, _pEnv, *this ); - if ( out ) - object = _pEnv->NewGlobalRef( out ); - } //t.pEnv -} -// ----------------------------------------------------------------------------- - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Reader.cxx b/connectivity/source/drivers/jdbc/Reader.cxx deleted file mode 100644 index 9998b6c87d..0000000000 --- a/connectivity/source/drivers/jdbc/Reader.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/io/Reader.hxx" -#include <string.h> -using namespace connectivity; - -//************************************************************** -//************ Class: java.io.Reader -//************************************************************** - -jclass java_io_Reader::theClass = 0; -java_io_Reader::java_io_Reader( JNIEnv * pEnv, jobject myObj ) - : java_lang_Object( pEnv, myObj ) -{ - SDBThreadAttach::addRef(); -} -java_io_Reader::~java_io_Reader() -{ - SDBThreadAttach::releaseRef(); -} - -jclass java_io_Reader::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/io/Reader"); - return theClass; -} - -sal_Int32 SAL_CALL java_io_Reader::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - return readBytes(aData,nMaxBytesToRead); -} - -void SAL_CALL java_io_Reader::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - callIntMethodWithIntArg("skip",mID,nBytesToSkip); -} - -sal_Int32 SAL_CALL java_io_Reader::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - jboolean out(sal_False); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - static const char * cSignature = "()Z"; - static const char * cMethodName = "available"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallBooleanMethod( object, mID); - ThrowSQLException(t.pEnv,*this); - } //t.pEnv - return out; -} - -void SAL_CALL java_io_Reader::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - callVoidMethod("close",mID); -} -// ----------------------------------------------------- -sal_Int32 SAL_CALL java_io_Reader::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) -{ - OSL_ENSURE(aData.getLength() < nBytesToRead," Sequence is smaller than BytesToRead"); - jint out(0); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - - { - jcharArray pCharArray = t.pEnv->NewCharArray(nBytesToRead); - static const char * cSignature = "([CII)I"; - static const char * cMethodName = "read"; - // Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nBytesToRead ); - if ( !out ) - ThrowSQLException(t.pEnv,*this); - if(out > 0) - { - jboolean p = sal_False; - if(aData.getLength() < out) - aData.realloc(out-aData.getLength()); - - memcpy(aData.getArray(),t.pEnv->GetCharArrayElements(pCharArray,&p),out); - } - t.pEnv->DeleteLocalRef((jcharArray)pCharArray); - } //t.pEnv - return out; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Ref.cxx b/connectivity/source/drivers/jdbc/Ref.cxx deleted file mode 100644 index ad49a24f76..0000000000 --- a/connectivity/source/drivers/jdbc/Ref.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/Ref.hxx" -#include "java/tools.hxx" -using namespace connectivity; -//************************************************************** -//************ Class: java.sql.Ref -//************************************************************** - -jclass java_sql_Ref::theClass = 0; -java_sql_Ref::java_sql_Ref( JNIEnv * pEnv, jobject myObj ) -: java_lang_Object( pEnv, myObj ) -{ - SDBThreadAttach::addRef(); -} -java_sql_Ref::~java_sql_Ref() -{ - SDBThreadAttach::releaseRef(); -} - -jclass java_sql_Ref::getMyClass() const -{ - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/Ref"); - return theClass; -} - -::rtl::OUString SAL_CALL java_sql_Ref::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - static jmethodID mID(NULL); - return callStringMethod("getBaseTypeName",mID); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx deleted file mode 100644 index 64a17ad1ca..0000000000 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ /dev/null @@ -1,1088 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/lang/String.hxx" -#include "java/lang/Boolean.hxx" -#include "java/sql/ResultSet.hxx" -#include "java/math/BigDecimal.hxx" -#include "java/sql/JStatement.hxx" -#include "java/sql/SQLWarning.hxx" -#include "java/sql/Timestamp.hxx" -#include "java/sql/Array.hxx" -#include "java/sql/Ref.hxx" -#include "java/sql/Clob.hxx" -#include "java/sql/Timestamp.hxx" -#include "java/sql/Blob.hxx" -#include "java/sql/ResultSetMetaData.hxx" -#include "java/io/InputStream.hxx" -#include "java/io/Reader.hxx" -#include "java/tools.hxx" -#include <comphelper/property.hxx> -#include "connectivity/CommonTools.hxx" -#include <cppuhelper/typeprovider.hxx> -#include <comphelper/sequence.hxx> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include "TConnection.hxx" -#include <comphelper/types.hxx> -#include "connectivity/dbtools.hxx" -#include "connectivity/dbexception.hxx" -#include "resource/common_res.hrc" -#include "resource/sharedresources.hxx" -#include "java/LocalRef.hxx" - -#include <rtl/logfile.hxx> -#include <string.h> - -using namespace ::comphelper; - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -IMPLEMENT_SERVICE_INFO(java_sql_ResultSet,"com.sun.star.sdbcx.JResultSet","com.sun.star.sdbc.ResultSet"); -//************************************************************** -//************ Class: java.sql.ResultSet -//************************************************************** - -jclass java_sql_ResultSet::theClass = 0; -java_sql_ResultSet::java_sql_ResultSet( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rParentLogger,java_sql_Connection& _rConnection, java_sql_Statement_Base* pStmt) - :java_sql_ResultSet_BASE(m_aMutex) - ,java_lang_Object( pEnv, myObj ) - ,OPropertySetHelper(java_sql_ResultSet_BASE::rBHelper) - ,m_aLogger( _rParentLogger, java::sql::ConnectionLog::RESULTSET ) - ,m_pConnection(&_rConnection) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::java_sql_ResultSet" ); - SDBThreadAttach::addRef(); - osl_incrementInterlockedCount(&m_refCount); - if ( pStmt ) - m_xStatement = *pStmt; - - osl_decrementInterlockedCount(&m_refCount); -} -// ----------------------------------------------------------------------------- -java_sql_ResultSet::~java_sql_ResultSet() -{ - if ( !java_sql_ResultSet_BASE::rBHelper.bDisposed && !java_sql_ResultSet_BASE::rBHelper.bInDispose ) - { - // increment ref count to prevent double call of Dtor - osl_incrementInterlockedCount( &m_refCount ); - dispose(); - } -} - -jclass java_sql_ResultSet::getMyClass() const -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getMyClass" ); - // the class must be fetched only once, therefore static - if( !theClass ) - theClass = findMyClass("java/sql/ResultSet"); - return theClass; -} - -// ------------------------------------------------------------------------- -void java_sql_ResultSet::disposing(void) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::disposing" ); - OPropertySetHelper::disposing(); - - ::osl::MutexGuard aGuard(m_aMutex); -m_xMetaData.clear(); - if( object ) - { - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - callVoidMethod("close",mID); - clearObject(*t.pEnv); - } - - SDBThreadAttach::releaseRef(); -} -// ------------------------------------------------------------------------- -::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::queryInterface" ); - ::com::sun::star::uno::Any aRet = OPropertySetHelper::queryInterface(rType); - return aRet.hasValue() ? aRet : java_sql_ResultSet_BASE::queryInterface(rType); -} -// ------------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_ResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTypes" ); - ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), - ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ), - ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 )); - - return ::comphelper::concatSequences(aTypes.getTypes(),java_sql_ResultSet_BASE::getTypes()); -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_ResultSet::findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::findColumn" ); - static jmethodID mID(NULL); - return callIntMethodWithStringArg("findColumn",mID,columnName); -} -// ------------------------------------------------------------------------- -Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBinaryStream" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getBinaryStream","(I)Ljava/io/InputStream;", mID, columnIndex); - - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_io_InputStream( t.pEnv, out ); -} -// ------------------------------------------------------------------------- -Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getCharacterStream" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getCharacterStream","(I)Ljava/io/Reader;", mID, columnIndex); - - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_io_Reader( t.pEnv, out ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBoolean" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "getBoolean", mID,columnIndex ); -} -// ------------------------------------------------------------------------- - -sal_Int8 SAL_CALL java_sql_ResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getByte" ); - static jmethodID mID(NULL); - jbyte (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallByteMethod; - return callMethodWithIntArg<jbyte>(pCallMethod,"getByte","(I)B",mID,columnIndex); -} -// ------------------------------------------------------------------------- - -Sequence< sal_Int8 > SAL_CALL java_sql_ResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBytes" ); - Sequence< sal_Int8 > aSeq; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jbyteArray out = (jbyteArray)callObjectMethodWithIntArg(t.pEnv,"getBytes","(I)[B", mID, columnIndex); - if (out) - { - jboolean p = sal_False; - aSeq.realloc(t.pEnv->GetArrayLength(out)); - memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength()); - t.pEnv->DeleteLocalRef(out); - } - return aSeq; -} -// ------------------------------------------------------------------------- - -::com::sun::star::util::Date SAL_CALL java_sql_ResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getDate" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getDate","(I)Ljava/sql/Date;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out ? static_cast <com::sun::star::util::Date> (java_sql_Date( t.pEnv, out )) : ::com::sun::star::util::Date(); -} -// ------------------------------------------------------------------------- - -double SAL_CALL java_sql_ResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getDouble" ); - static jmethodID mID(NULL); - jdouble (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallDoubleMethod; - return callMethodWithIntArg<double>(pCallMethod,"getDouble","(I)D",mID,columnIndex); -} -// ------------------------------------------------------------------------- - -float SAL_CALL java_sql_ResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFloat" ); - static jmethodID mID(NULL); - jfloat (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallFloatMethod; - return callMethodWithIntArg<jfloat>(pCallMethod,"getFloat","(I)F",mID,columnIndex); -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_ResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getInt" ); - static jmethodID mID(NULL); - return callIntMethodWithIntArg("getInt",mID,columnIndex); -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_ResultSet::getRow( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getRow" ); - static jmethodID mID(NULL); - return callIntMethod("getRow",mID); -} -// ------------------------------------------------------------------------- - -sal_Int64 SAL_CALL java_sql_ResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getLong" ); - static jmethodID mID(NULL); - jlong (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallLongMethod; - return callMethodWithIntArg<jlong>(pCallMethod,"getLong","(I)J",mID,columnIndex); -} -// ------------------------------------------------------------------------- - -::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_ResultSet::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getMetaData" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/ResultSetMetaData;", mID); - - return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection ); -} -// ------------------------------------------------------------------------- -Reference< XArray > SAL_CALL java_sql_ResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getArray" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getArray","(I)Ljava/sql/Array;", mID, columnIndex); - - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Array( t.pEnv, out ); -} -// ------------------------------------------------------------------------- - -Reference< XClob > SAL_CALL java_sql_ResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getClob" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getClob","(I)Ljava/sql/Clob;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Clob( t.pEnv, out ); -} -// ------------------------------------------------------------------------- -Reference< XBlob > SAL_CALL java_sql_ResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBlob" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getBlob","(I)Ljava/sql/Blob;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Blob( t.pEnv, out ); -} -// ------------------------------------------------------------------------- - -Reference< XRef > SAL_CALL java_sql_ResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getRef" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getRef","(I)Ljava/sql/Ref;", mID, columnIndex); - - // WARNING: the caller becomes the owner of the returned pointer - return out==0 ? 0 : new java_sql_Ref( t.pEnv, out ); -} -// ------------------------------------------------------------------------- - -Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getObject" ); - jobject out(0); - Any aRet; - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - { - jvalue args[2]; - // convert parameter - args[0].i = (sal_Int32)columnIndex; - args[1].l = convertTypeMapToJavaMap(t.pEnv,typeMap); - // initialize temporary Variable - // Java-Call - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "(I)Ljava/lang/Object;"; - static const char * cMethodName = "getObject"; - - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - } - - out = t.pEnv->CallObjectMethodA( object, mID, args); - t.pEnv->DeleteLocalRef((jstring)args[1].l); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - // and clean up - if ( out ) - { - if ( t.pEnv->IsInstanceOf(out,java_lang_String::st_getMyClass()) ) - { - java_lang_String aVal(t.pEnv,out); - aRet <<= (::rtl::OUString)aVal; - } - else if ( t.pEnv->IsInstanceOf(out,java_lang_Boolean::st_getMyClass()) ) - { - java_lang_Boolean aVal(t.pEnv,out); - static jmethodID methodID = NULL; - aRet <<= aVal.callBooleanMethod("booleanValue",methodID); - } - else if ( t.pEnv->IsInstanceOf(out,java_sql_Date::st_getMyClass()) ) - { - java_sql_Date aVal(t.pEnv,out); - aRet <<= (::com::sun::star::util::Date)aVal; - } - else if ( t.pEnv->IsInstanceOf(out,java_sql_Time::st_getMyClass()) ) - { - java_sql_Time aVal(t.pEnv,out); - aRet <<= (::com::sun::star::util::Time)aVal; - } - else if ( t.pEnv->IsInstanceOf(out,java_sql_Timestamp::st_getMyClass()) ) - { - java_sql_Timestamp aVal(t.pEnv,out); - aRet <<= (::com::sun::star::util::DateTime)aVal; - } - else - t.pEnv->DeleteLocalRef(out); - } - } //t.pEnv - return aRet; -} -// ------------------------------------------------------------------------- - -sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getShort" ); - static jmethodID mID(NULL); - jshort (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallShortMethod; - return callMethodWithIntArg<jshort>(pCallMethod,"getShort","(I)S",mID,columnIndex); -} -// ------------------------------------------------------------------------- - - -::rtl::OUString SAL_CALL java_sql_ResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getString" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getString",mID,columnIndex); -} -// ------------------------------------------------------------------------- - - -::com::sun::star::util::Time SAL_CALL java_sql_ResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTime" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getTime","(I)Ljava/sql/Time;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out ? static_cast <com::sun::star::util::Time> (java_sql_Time( t.pEnv, out )) : ::com::sun::star::util::Time(); -} -// ------------------------------------------------------------------------- - - -::com::sun::star::util::DateTime SAL_CALL java_sql_ResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTimestamp" ); - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - static jmethodID mID(NULL); - jobject out = callObjectMethodWithIntArg(t.pEnv,"getTimestamp","(I)Ljava/sql/Timestamp;", mID, columnIndex); - // WARNING: the caller becomes the owner of the returned pointer - return out ? static_cast <com::sun::star::util::DateTime> (java_sql_Timestamp( t.pEnv, out )) : ::com::sun::star::util::DateTime(); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::isAfterLast( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isAfterLast" ); - static jmethodID mID(NULL); - return callBooleanMethod( "isAfterLast", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSet::isFirst( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isFirst" ); - static jmethodID mID(NULL); - return callBooleanMethod( "isFirst", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSet::isLast( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isLast" ); - static jmethodID mID(NULL); - return callBooleanMethod( "isLast", mID ); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::beforeFirst( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::beforeFirst" ); - static jmethodID mID(NULL); - callVoidMethod("beforeFirst",mID); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::afterLast( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::afterLast" ); - static jmethodID mID(NULL); - callVoidMethod("afterLast",mID); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::close" ); - dispose(); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::first( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::first" ); - static jmethodID mID(NULL); - return callBooleanMethod( "first", mID ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::last( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::last" ); - static jmethodID mID(NULL); - return callBooleanMethod( "last", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::absolute" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "absolute", mID,row ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::relative" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "relative", mID,row ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSet::previous( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::previous" ); - static jmethodID mID(NULL); - return callBooleanMethod( "previous", mID ); -} -// ------------------------------------------------------------------------- -Reference< XInterface > SAL_CALL java_sql_ResultSet::getStatement( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getStatement" ); - return m_xStatement; -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::rowDeleted( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowDeleted" ); - static jmethodID mID(NULL); - return callBooleanMethod( "rowDeleted", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSet::rowInserted( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowInserted" ); - static jmethodID mID(NULL); - return callBooleanMethod( "rowInserted", mID ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSet::rowUpdated( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowUpdated" ); - static jmethodID mID(NULL); - return callBooleanMethod( "rowUpdated", mID ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isBeforeFirst" ); - static jmethodID mID(NULL); - return callBooleanMethod( "isBeforeFirst", mID ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::next( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::next" ); - static jmethodID mID(NULL); - return callBooleanMethod( "next", mID ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSet::wasNull( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::wasNull" ); - static jmethodID mID(NULL); - return callBooleanMethod( "wasNull", mID ); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::cancel( ) throw(::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::cancel" ); - static jmethodID mID(NULL); - callVoidMethod("cancel",mID); -} -// ------------------------------------------------------------------------- -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::clearWarnings" ); - static jmethodID mID(NULL); - callVoidMethod("clearWarnings",mID); -} -// ------------------------------------------------------------------------- -::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getWarnings" ); - SDBThreadAttach t; - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID); - // WARNING: the caller becomes the owner of the returned pointer - if( out ) - { - java_sql_SQLWarning_BASE warn_base( t.pEnv, out ); - return makeAny( - static_cast< starsdbc::SQLException >( - java_sql_SQLWarning(warn_base,*this))); - } - - return ::com::sun::star::uno::Any(); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::insertRow" ); - static jmethodID mID(NULL); - callVoidMethod("insertRow",mID); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateRow" ); - static jmethodID mID(NULL); - callVoidMethod("updateRow",mID); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::deleteRow" ); - static jmethodID mID(NULL); - callVoidMethod("deleteRow",mID); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::cancelRowUpdates" ); - static jmethodID mID(NULL); - callVoidMethod("cancelRowUpdates",mID); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::moveToInsertRow" ); - static jmethodID mID(NULL); - callVoidMethod("moveToInsertRow",mID); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::moveToCurrentRow" ); - static jmethodID mID(NULL); - callVoidMethod("moveToCurrentRow",mID); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateNull" ); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("updateNull",mID,columnIndex); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBoolean" ); - static jmethodID mID(NULL); - callVoidMethod("updateBoolean", "(IZ)V", mID, columnIndex, x); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateByte" ); - static jmethodID mID(NULL); - callVoidMethod("updateByte", "(IB)V", mID, columnIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateShort" ); - static jmethodID mID(NULL); - callVoidMethod("updateShort", "(IS)V", mID, columnIndex, x); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateInt" ); - static jmethodID mID(NULL); - callVoidMethod("updateInt", "(II)V", mID, columnIndex, x); -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateLong" ); - static jmethodID mID(NULL); - callVoidMethod("updateLong", "(IJ)V", mID, columnIndex, x); -} -// ------------------------------------------------------------------------- - -// ----------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateFloat" ); - static jmethodID mID(NULL); - callVoidMethod("updateFloat", "(IF)V", mID, columnIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateDouble" ); - static jmethodID mID(NULL); - callVoidMethod("updateDouble", "(ID)V", mID, columnIndex, x); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateString" ); - SDBThreadAttach t; - - { - - // initialize temporary variable - // Java-Call - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "(ILjava/lang/String;)V"; - static const char * cMethodName = "updateString"; - - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - } - - { - // convert parameter - jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x)); - t.pEnv->CallVoidMethod( object, mID,columnIndex,str.get()); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBytes" ); - SDBThreadAttach t; - - { - // initialize temporary variable - // Java-Call - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "(I[B)V"; - static const char * cMethodName = "updateBytes"; - - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - } - - { - jbyteArray aArray = t.pEnv->NewByteArray(x.getLength()); - t.pEnv->SetByteArrayRegion(aArray,0,x.getLength(),(jbyte*)x.getConstArray()); - // convert parameter - t.pEnv->CallVoidMethod( object, mID,columnIndex,aArray); - t.pEnv->DeleteLocalRef(aArray); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateDate" ); - java_sql_Date aD(x); - static jmethodID mID(NULL); - callVoidMethod("updateDate", "(ILjava/sql/Date;)V", mID, columnIndex, aD.getJavaObject()); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateTime" ); - java_sql_Time aD(x); - static jmethodID mID(NULL); - callVoidMethod("updateTime", "(ILjava/sql/Time;)V", mID, columnIndex, aD.getJavaObject()); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateTimestamp" ); - java_sql_Timestamp aD(x); - static jmethodID mID(NULL); - callVoidMethod("updateTimestamp", "(ILjava/sql/Timestamp;)V", mID, columnIndex, aD.getJavaObject()); -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBinaryStream" ); - try - { - SDBThreadAttach t; - { - - // initialize temporary variable - // Java-Call - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "(ILjava/io/InputStream;I)V"; - static const char * cMethodName = "updateBinaryStream"; - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - } - - { - // convert Parameter - jobject obj = createByteInputStream(x,length); - t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } - } - catch(const Exception&) - { - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this ); - } -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateCharacterStream" ); - try - { - SDBThreadAttach t; - { - - // initialize temporary variable - // Java-Call - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "(ILjava/io/Reader;I)V"; - static const char * cMethodName = "updateCharacterStream"; - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - } - - { - // convert Parameter - jobject obj = createCharArrayReader(x,length); - t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } - } - catch(const Exception&) - { - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this ); - } -} -// ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateObject" ); - if(!::dbtools::implUpdateObject(this,columnIndex,x)) - { - ::connectivity::SharedResources aResources; - const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( - STR_UNKNOWN_COLUMN_TYPE, - "$position$", ::rtl::OUString::valueOf(columnIndex) - ) ); - ::dbtools::throwGenericSQLException(sError,*this); - } -} -// ------------------------------------------------------------------------- - -void SAL_CALL java_sql_ResultSet::updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateNumericObject" ); - // OSL_FAIL("java_sql_ResultSet::updateNumericObject: NYI"); - try - { - SDBThreadAttach t; - - { - - // initialize temporary variable - // Java-Call - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "(ILjava/lang/Object;I)V"; - static const char * cMethodName = "updateObject"; - - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - } - - { - // convert parameter - double nTemp = 0.0; - ::std::auto_ptr<java_math_BigDecimal> pBigDecimal; - if ( x >>= nTemp) - { - pBigDecimal.reset(new java_math_BigDecimal(nTemp)); - } - else - pBigDecimal.reset(new java_math_BigDecimal(::comphelper::getString(x))); - - t.pEnv->CallVoidMethod( object, mID, columnIndex,pBigDecimal->getJavaObject(),scale); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - } - } - } - catch(const Exception&) - { - updateObject( columnIndex,x); - } -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_ResultSet::getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getResultSetConcurrency" ); - static jmethodID mID(NULL); - return callIntMethod("getConcurrency",mID,true); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_ResultSet::getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getResultSetType" ); - static jmethodID mID(NULL); - return callIntMethod("getType",mID,true); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_ResultSet::getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFetchDirection" ); - static jmethodID mID(NULL); - return callIntMethod("getFetchDirection",mID,true); -} -//------------------------------------------------------------------------------ -sal_Int32 java_sql_ResultSet::getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFetchSize" ); - static jmethodID mID(NULL); - return callIntMethod("getFetchSize",mID,true); -} -//------------------------------------------------------------------------------ -::rtl::OUString java_sql_ResultSet::getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getCursorName" ); - static jmethodID mID(NULL); - return callStringMethod("getCursorName",mID); -} - -//------------------------------------------------------------------------------ -void java_sql_ResultSet::setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFetchDirection" ); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true); -} -//------------------------------------------------------------------------------ -void SAL_CALL java_sql_ResultSet::refreshRow( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::refreshRow" ); - static jmethodID mID(NULL); - callVoidMethod("refreshRow",mID); -} -//------------------------------------------------------------------------------ -void java_sql_ResultSet::setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFetchSize" ); - static jmethodID mID(NULL); - callVoidMethodWithIntArg("setFetchSize",mID,_par0,true); -} -// ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper* java_sql_ResultSet::createArrayHelper( ) const -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::createArrayHelper" ); - Sequence< Property > aProps(5); - Property* pProperties = aProps.getArray(); - sal_Int32 nPos = 0; - DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY); - DECL_PROP0(FETCHDIRECTION, sal_Int32); - DECL_PROP0(FETCHSIZE, sal_Int32); - DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY); - DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY); - - return new ::cppu::OPropertyArrayHelper(aProps); -} -// ------------------------------------------------------------------------- -::cppu::IPropertyArrayHelper & java_sql_ResultSet::getInfoHelper() -{ - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getInfoHelper" ); - return *const_cast<java_sql_ResultSet*>(this)->getArrayHelper(); -} -// ------------------------------------------------------------------------- -sal_Bool java_sql_ResultSet::convertFastPropertyValue( - ::com::sun::star::uno::Any & rConvertedValue, - ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue ) - throw (::com::sun::star::lang::IllegalArgumentException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::convertFastPropertyValue" ); - sal_Bool bRet = sal_False; - switch(nHandle) - { - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw ::com::sun::star::lang::IllegalArgumentException(); - case PROPERTY_ID_FETCHDIRECTION: - bRet = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection()); - break; - case PROPERTY_ID_FETCHSIZE: - bRet = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize()); - default: - ; - } - return bRet; -} - -// ------------------------------------------------------------------------- -void java_sql_ResultSet::setFastPropertyValue_NoBroadcast( - sal_Int32 nHandle, - const ::com::sun::star::uno::Any& rValue - ) - throw (::com::sun::star::uno::Exception) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFastPropertyValue_NoBroadcast" ); - switch(nHandle) - { - case PROPERTY_ID_CURSORNAME: - case PROPERTY_ID_RESULTSETCONCURRENCY: - case PROPERTY_ID_RESULTSETTYPE: - throw ::com::sun::star::uno::Exception(); - case PROPERTY_ID_FETCHDIRECTION: - setFetchDirection(comphelper::getINT32(rValue)); - break; - case PROPERTY_ID_FETCHSIZE: - setFetchSize(comphelper::getINT32(rValue)); - break; - default: - ; - } -} -// ------------------------------------------------------------------------- -void java_sql_ResultSet::getFastPropertyValue( - ::com::sun::star::uno::Any& rValue, - sal_Int32 nHandle - ) const -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFastPropertyValue" ); - try - { - switch(nHandle) - { - case PROPERTY_ID_CURSORNAME: - rValue <<= getCursorName(); - break; - case PROPERTY_ID_RESULTSETCONCURRENCY: - rValue <<= getResultSetConcurrency(); - break; - case PROPERTY_ID_RESULTSETTYPE: - rValue <<= getResultSetType(); - break; - case PROPERTY_ID_FETCHDIRECTION: - rValue <<= getFetchDirection(); - break; - case PROPERTY_ID_FETCHSIZE: - rValue <<= getFetchSize(); - break; - } - } - catch(const Exception&) - { - } -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::acquire() throw() -{ - java_sql_ResultSet_BASE::acquire(); -} -// ----------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::release() throw() -{ - java_sql_ResultSet_BASE::release(); -} -// ----------------------------------------------------------------------------- -::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL java_sql_ResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getPropertySetInfo" ); - return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); -} -// ----------------------------------------------------------------------------- - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx deleted file mode 100644 index a6da0676a2..0000000000 --- a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx +++ /dev/null @@ -1,239 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/ResultSetMetaData.hxx" -#include "java/sql/Connection.hxx" -#include "java/tools.hxx" -#include <rtl/logfile.hxx> - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -#define NULLABLE_UNDEFINED 99 -//************************************************************** -//************ Class: java.sql.ResultSetMetaData -//************************************************************** - -jclass java_sql_ResultSetMetaData::theClass = 0; -java_sql_ResultSetMetaData::java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rResultSetLogger, java_sql_Connection& _rCon ) - :java_lang_Object( pEnv, myObj ) - ,m_aLogger( _rResultSetLogger ) - ,m_pConnection( &_rCon ) - ,m_nColumnCount(-1) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::java_sql_ResultSetMetaData" ); - SDBThreadAttach::addRef(); -} -java_sql_ResultSetMetaData::~java_sql_ResultSetMetaData() -{ - SDBThreadAttach::releaseRef(); -} - -jclass java_sql_ResultSetMetaData::getMyClass() const -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getMyClass" ); - // The class needs to be fetched just once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/sql/ResultSetMetaData"); - return theClass; -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnDisplaySize" ); - static jmethodID mID(NULL); - return callIntMethodWithIntArg("getColumnDisplaySize",mID,column); -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnType" ); - static jmethodID mID(NULL); - return callIntMethodWithIntArg("getColumnType",mID,column); -} -// ------------------------------------------------------------------------- - -sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnCount" ); - if ( m_nColumnCount == -1 ) - { - static jmethodID mID(NULL); - m_nColumnCount = callIntMethod("getColumnCount",mID); - } // if ( m_nColumnCount == -1 ) - return m_nColumnCount; - -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCaseSensitive" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isCaseSensitive", mID,column ); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getSchemaName" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getSchemaName",mID,column); -} -// ------------------------------------------------------------------------- - -::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnName" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getColumnName",mID,column); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getTableName" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getTableName",mID,column); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getCatalogName" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getCatalogName",mID,column); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnTypeName" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getColumnTypeName",mID,column); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnLabel" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getColumnLabel",mID,column); -} -// ------------------------------------------------------------------------- -::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnServiceName" ); - static jmethodID mID(NULL); - return callStringMethodWithIntArg("getColumnClassName",mID,column); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCurrency" ); - if ( m_pConnection->isIgnoreCurrencyEnabled() ) - return sal_False; - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isCurrency", mID,column ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isAutoIncrement" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isAutoIncrement", mID,column ); -} -// ------------------------------------------------------------------------- - - -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSigned" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isSigned", mID,column ); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getPrecision" ); - static jmethodID mID(NULL); - return callIntMethodWithIntArg("getPrecision",mID,column); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getScale" ); - static jmethodID mID(NULL); - return callIntMethodWithIntArg("getScale",mID,column); -} -// ------------------------------------------------------------------------- -sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isNullable" ); - static jmethodID mID(NULL); - return callIntMethodWithIntArg("isNullable",mID,column); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSearchable" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isSearchable", mID,column ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isReadOnly" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isReadOnly", mID,column ); -} -// ------------------------------------------------------------------------- - -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isDefinitelyWritable" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isDefinitelyWritable", mID,column ); -} -// ------------------------------------------------------------------------- -sal_Bool SAL_CALL java_sql_ResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isWritable" ); - static jmethodID mID(NULL); - return callBooleanMethodWithIntArg( "isWritable", mID,column ); -} -// ------------------------------------------------------------------------- - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/SQLException.cxx b/connectivity/source/drivers/jdbc/SQLException.cxx deleted file mode 100644 index a0ebe17938..0000000000 --- a/connectivity/source/drivers/jdbc/SQLException.cxx +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/SQLException.hxx" -#include "java/tools.hxx" - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; -//************************************************************** -//************ Class: java.sql.SQLException -//************************************************************** -java_sql_SQLException::java_sql_SQLException( const java_sql_SQLException_BASE& _rException,const Reference< XInterface> & _rContext) - : starsdbc::SQLException( _rException.getMessage(), - _rContext, - _rException.getSQLState(), - _rException.getErrorCode(), - makeAny(_rException.getNextException()) - ) -{ -} - -java_sql_SQLException_BASE::java_sql_SQLException_BASE( JNIEnv * pEnv, jobject myObj ) : java_lang_Exception( pEnv, myObj ) -{ -} - -jclass java_sql_SQLException_BASE::theClass = 0; - -java_sql_SQLException_BASE::~java_sql_SQLException_BASE() -{} - - -jclass java_sql_SQLException_BASE::getMyClass() const -{ - return st_getMyClass(); -} -jclass java_sql_SQLException_BASE::st_getMyClass() -{ - // The class needs to be fetched just once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/sql/SQLException"); - return theClass; -} - -starsdbc::SQLException java_sql_SQLException_BASE::getNextException() const -{ - SDBThreadAttach t; - static jmethodID mID(NULL); - jobject out = callObjectMethod(t.pEnv,"getNextException","()Ljava/sql/SQLException;", mID); - // WARNING: the caller will become the owner of the returned pointers !!! - if( out ) - { - java_sql_SQLException_BASE warn_base(t.pEnv,out); - return (starsdbc::SQLException)java_sql_SQLException(warn_base,0); - } - - return starsdbc::SQLException(); -} - -::rtl::OUString java_sql_SQLException_BASE::getSQLState() const -{ - static jmethodID mID(NULL); - return callStringMethod("getSQLState",mID); -} -sal_Int32 java_sql_SQLException_BASE::getErrorCode() const -{ - static jmethodID mID(NULL); - return callIntMethod("getErrorCode",mID); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/SQLWarning.cxx b/connectivity/source/drivers/jdbc/SQLWarning.cxx deleted file mode 100644 index aa5c8fe456..0000000000 --- a/connectivity/source/drivers/jdbc/SQLWarning.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/SQLWarning.hxx" -using namespace connectivity; -//************************************************************** -//************ Class: java.sql.SQLWarning -//************************************************************** - -jclass java_sql_SQLWarning_BASE::theClass = 0; - -java_sql_SQLWarning_BASE::~java_sql_SQLWarning_BASE() -{} - -jclass java_sql_SQLWarning_BASE::getMyClass() const -{ - // the class needs to be fetched only once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/sql/SQLWarning"); - return theClass; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/String.cxx b/connectivity/source/drivers/jdbc/String.cxx deleted file mode 100644 index a85a3fd6b2..0000000000 --- a/connectivity/source/drivers/jdbc/String.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/lang/String.hxx" -#include "java/tools.hxx" -using namespace connectivity; -//************************************************************** -//************ Class: java.lang.String -//************************************************************** - -jclass java_lang_String::theClass = 0; - -java_lang_String::~java_lang_String() -{} - -jclass java_lang_String::getMyClass() const -{ - return st_getMyClass(); -} -jclass java_lang_String::st_getMyClass() -{ - // the class needs to be fetched only once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/lang/String"); - return theClass; -} - -//-------------------------------------------------------------------------- -java_lang_String::operator ::rtl::OUString() -{ - SDBThreadAttach t; - if(!t.pEnv) - return ::rtl::OUString(); - return JavaString2String(t.pEnv,(jstring)object); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Throwable.cxx b/connectivity/source/drivers/jdbc/Throwable.cxx deleted file mode 100644 index 50302bcb7c..0000000000 --- a/connectivity/source/drivers/jdbc/Throwable.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/lang/Throwable.hxx" -#include "java/tools.hxx" -using namespace connectivity; -//************************************************************** -//************ Class: java.lang.Throwable -//************************************************************** - -jclass java_lang_Throwable::theClass = 0; - -java_lang_Throwable::~java_lang_Throwable() -{} - -jclass java_lang_Throwable::getMyClass() const -{ - return st_getMyClass(); -} -jclass java_lang_Throwable::st_getMyClass() -{ - // the class needs to be fetched only once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/lang/Throwable"); - return theClass; -} -// ----------------------------------------------------------------------------- - -::rtl::OUString java_lang_Throwable::getMessage() const -{ - static jmethodID mID(NULL); - return callStringMethod("getMessage",mID); -} -// ----------------------------------------------------------------------------- - -::rtl::OUString java_lang_Throwable::getLocalizedMessage() const -{ - static jmethodID mID(NULL); - return callStringMethod("getLocalizedMessage",mID); -} -// ----------------------------------------------------------------------------- - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx deleted file mode 100644 index f38a1a610b..0000000000 --- a/connectivity/source/drivers/jdbc/Timestamp.cxx +++ /dev/null @@ -1,194 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/Timestamp.hxx" -#include "java/tools.hxx" -#include <comphelper/types.hxx> -#include "connectivity/dbconversion.hxx" - -using namespace ::comphelper; -using namespace connectivity; -//************************************************************** -//************ Class: java.sql.Date -//************************************************************** -const double fMilliSecondsPerDay = 86400000.0; -jclass java_sql_Date::theClass = 0; -java_sql_Date::java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java_util_Date( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - jvalue args[1]; - // Convert parameters - ::rtl::OUString sDateStr; - sDateStr = ::dbtools::DBTypeConversion::toDateString(_rOut); - args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr); - - // Turn of Java-Call for the constructor - // initialise temporary variables - static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Date;"; - jobject tempObj; - static jmethodID mID(NULL); - if ( !mID ) - mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!"); - tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l ); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - // and clean -} - -java_sql_Date::~java_sql_Date() -{} - -jclass java_sql_Date::getMyClass() const -{ - return st_getMyClass(); -} -jclass java_sql_Date::st_getMyClass() -{ - // the class needs only be fetched once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/sql/Date"); - return theClass; -} -// ----------------------------------------------------------------------------- - -java_sql_Date::operator ::com::sun::star::util::Date() -{ - return ::dbtools::DBTypeConversion::toDate(toString()); -} - -//************************************************************** -//************ Class: java.sql.Time -//************************************************************** - -jclass java_sql_Time::theClass = 0; - -java_sql_Time::~java_sql_Time() -{} - -jclass java_sql_Time::getMyClass() const -{ - return st_getMyClass(); -} -jclass java_sql_Time::st_getMyClass() -{ - // the class needs only be fetched once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/sql/Time"); - return theClass; -} -java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - jvalue args[1]; - // Convert parameters - ::rtl::OUString sDateStr; - sDateStr = ::dbtools::DBTypeConversion::toTimeString(_rOut); - args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr); - - // Turn off Java-Call for the constructor - // intialise temporary variables - static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Time;"; - jobject tempObj; - static jmethodID mID(NULL); - if ( !mID ) - mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!"); - tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l ); - t.pEnv->DeleteLocalRef((jstring)args[0].l); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - // and clean -} -// ----------------------------------------------------------------------------- -java_sql_Time::operator ::com::sun::star::util::Time() -{ - return ::dbtools::DBTypeConversion::toTime(toString()); -} -//************************************************************** -//************ Class: java.sql.Timestamp -//************************************************************** - -jclass java_sql_Timestamp::theClass = 0; - -java_sql_Timestamp::~java_sql_Timestamp() -{} - -jclass java_sql_Timestamp::getMyClass() const -{ - return st_getMyClass(); -} - -jclass java_sql_Timestamp::st_getMyClass() -{ - // the class needs only be fetched once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/sql/Timestamp"); - return theClass; -} - -java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut) - :java_util_Date( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - jvalue args[1]; - // Convert parameters - ::rtl::OUString sDateStr; - sDateStr = ::dbtools::DBTypeConversion::toDateTimeString(_rOut); - - args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr); - - // Turn off Java-Call for the constructor - // initialise temporary variables - static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Timestamp;"; - jobject tempObj; - static jmethodID mID(NULL); - if ( !mID ) - mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!"); - tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l ); - - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); - // and clean -} - -// ----------------------------------------------------------------------------- -java_sql_Timestamp::operator ::com::sun::star::util::DateTime() -{ - return ::dbtools::DBTypeConversion::toDateTime(toString()); -} -// ----------------------------------------------------------------------------- - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/exports.dxp b/connectivity/source/drivers/jdbc/exports.dxp deleted file mode 100755 index 7003307892..0000000000 --- a/connectivity/source/drivers/jdbc/exports.dxp +++ /dev/null @@ -1 +0,0 @@ -component_getFactory diff --git a/connectivity/source/drivers/jdbc/jdbc.component b/connectivity/source/drivers/jdbc/jdbc.component deleted file mode 100755 index 5d7db4690b..0000000000 --- a/connectivity/source/drivers/jdbc/jdbc.component +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--********************************************************************** -* -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* Copyright 2000, 2010 Oracle and/or its affiliates. -* -* OpenOffice.org - a multi-platform office productivity suite -* -* This file is part of OpenOffice.org. -* -* OpenOffice.org is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License version 3 -* only, as published by the Free Software Foundation. -* -* OpenOffice.org is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License version 3 for more details -* (a copy is included in the LICENSE file that accompanied this code). -* -* You should have received a copy of the GNU Lesser General Public License -* version 3 along with OpenOffice.org. If not, see -* <http://www.openoffice.org/license.html> -* for a copy of the LGPLv3 License. -* -**********************************************************************--> - -<component loader="com.sun.star.loader.SharedLibrary" - xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.sdbc.JDBCDriver"> - <service name="com.sun.star.sdbc.Driver"/> - </implementation> -</component> diff --git a/connectivity/source/drivers/jdbc/jdbc.mxp.map b/connectivity/source/drivers/jdbc/jdbc.mxp.map deleted file mode 100755 index 2437d90ec8..0000000000 --- a/connectivity/source/drivers/jdbc/jdbc.mxp.map +++ /dev/null @@ -1,152 +0,0 @@ -component_getFactory -__mh_dylib_header -___builtin_delete -___check_eh_spec -___cp_pop_exception -___get_eh_context -___pure_virtual -___rtti_class -___rtti_si -___rtti_user -___sjthrow -___start_cp_handler -___terminate -dyld_stub_binding_helper -rest_world -save_world -___builtin_new -___builtin_vec_delete -___builtin_vec_new -___cp_push_exception -___eh_alloc -_terminate__Fv -___eh_rtime_match -__._10bad_typeid -__._8bad_cast -___get_eh_info -___is_pointer__FPv -___throw_type_match_rtti -___vt_10bad_typeid -___vt_8bad_cast -__keymgr_get_per_thread_data -__keymgr_set_per_thread_data -___tf9exception -___ti9exception -___vt_9exception -_what__C9exception -__._9bad_alloc -___tf9bad_alloc -___vt_9bad_alloc -__._9type_info -___eq__C9type_infoRCB0 -___tf16__user_type_info -___tf9type_info -___ti9type_info -___vt_9type_info -_getMyClass__Q212connectivity14java_sql_Array -_saveClassRef__Q212connectivity14java_sql_ArrayP7_jclass -_getMyClass__Q212connectivity13java_sql_Blob -_saveClassRef__Q212connectivity13java_sql_BlobP7_jclass -_saveClassRef__Q212connectivity17java_lang_BooleanP7_jclass -__._Q212connectivity26java_sql_CallableStatement -_release__Q212connectivity26java_sql_CallableStatement -_acquire__Q212connectivity26java_sql_CallableStatement -_saveClassRef__Q212connectivity26java_sql_CallableStatementP7_jclass -_getMyClass__Q212connectivity26java_sql_CallableStatement -_getMyClass__Q212connectivity15java_lang_Class -_saveClassRef__Q212connectivity15java_lang_ClassP7_jclass -_getMyClass__Q212connectivity13java_sql_Clob -_saveClassRef__Q212connectivity13java_sql_ClobP7_jclass -_getMyClass__Q212connectivity19java_sql_Connection -_saveClassRef__Q212connectivity19java_sql_ConnectionP7_jclass -_getMyClass__Q212connectivity25java_sql_DatabaseMetaData -_saveClassRef__Q212connectivity25java_sql_DatabaseMetaDataP7_jclass -_saveClassRef__Q212connectivity14java_util_DateP7_jclass -_getMyClass__Q212connectivity14java_util_Date -_getMyClass__Q212connectivity22java_sql_DriverManager -_saveClassRef__Q212connectivity22java_sql_DriverManagerP7_jclass -_choices__CQ212connectivity27java_sql_DriverPropertyInfo -_value__CQ212connectivity27java_sql_DriverPropertyInfo -_required__CQ212connectivity27java_sql_DriverPropertyInfo -_description__CQ212connectivity27java_sql_DriverPropertyInfo -_name__CQ212connectivity27java_sql_DriverPropertyInfo -_saveClassRef__Q212connectivity27java_sql_DriverPropertyInfoP7_jclass -_saveClassRef__Q212connectivity19java_lang_ExceptionP7_jclass -_getMyClass__Q212connectivity19java_io_InputStream -_saveClassRef__Q212connectivity19java_io_InputStreamP7_jclass -_getMyClass__Q212connectivity15java_sql_Driver -_saveClassRef__Q212connectivity15java_sql_DriverP7_jclass -___Q212connectivity15java_sql_DriverRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory -_getMyClass__Q212connectivity16java_lang_Object -_setError__Q212connectivity15SDBThreadAttach -_StartJava__Q212connectivity15SDBThreadAttachRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory -_xInit__Q212connectivity15SDBThreadAttachRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory -_detachThread__Q212connectivity15SDBThreadAttach -_attachThread__Q212connectivity15SDBThreadAttachRP7JNIEnv_RCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory -_release__Q212connectivity26java_sql_PreparedStatement -_acquire__Q212connectivity26java_sql_PreparedStatement -_getMyClass__Q212connectivity26java_sql_PreparedStatement -_saveClassRef__Q212connectivity26java_sql_PreparedStatementP7_jclass -_getMyClass__Q212connectivity14java_io_Reader -_saveClassRef__Q212connectivity14java_io_ReaderP7_jclass -_getMyClass__Q212connectivity12java_sql_Ref -_saveClassRef__Q212connectivity12java_sql_RefP7_jclass -__._Q312connectivity4jdbc18UStringDescription -___Q312connectivity4jdbc18UStringDescriptionPFv_PCc -_getPropertySetInfo__Q212connectivity18java_sql_ResultSet -_release__Q212connectivity18java_sql_ResultSet -_acquire__Q212connectivity18java_sql_ResultSet -_getResultSetType__CQ212connectivity18java_sql_ResultSet -_getResultSetConcurrency__CQ212connectivity18java_sql_ResultSet -_getCursorName__CQ212connectivity18java_sql_ResultSet -_setFetchSize__Q212connectivity18java_sql_ResultSetl -_setFetchDirection__Q212connectivity18java_sql_ResultSetl -_getFetchSize__CQ212connectivity18java_sql_ResultSet -_getFetchDirection__CQ212connectivity18java_sql_ResultSet -_saveClassRef__Q212connectivity18java_sql_ResultSetP7_jclass -_getMyClass__Q212connectivity18java_sql_ResultSet -_getMyClass__Q212connectivity26java_sql_ResultSetMetaData -_saveClassRef__Q212connectivity26java_sql_ResultSetMetaDataP7_jclass -_saveClassRef__Q212connectivity26java_sql_SQLException_BASEP7_jclass -_getNextException__CQ212connectivity26java_sql_SQLException_BASE -_getErrorCode__CQ212connectivity26java_sql_SQLException_BASE -_getSQLState__CQ212connectivity26java_sql_SQLException_BASE -_saveClassRef__Q212connectivity24java_sql_SQLWarning_BASEP7_jclass -_disposing__Q212connectivity23java_sql_Statement_Base -_release__Q212connectivity23java_sql_Statement_Base -_acquire__Q212connectivity23java_sql_Statement_Base -__._Q212connectivity16OStatement_BASE2 -_release__Q212connectivity18java_sql_Statement -_acquire__Q212connectivity18java_sql_Statement -_saveClassRef__Q212connectivity18java_sql_StatementP7_jclass -_setFetchSize__Q212connectivity23java_sql_Statement_Basel -_setFetchDirection__Q212connectivity23java_sql_Statement_Basel -_setResultSetType__Q212connectivity23java_sql_Statement_Basel -_setResultSetConcurrency__Q212connectivity23java_sql_Statement_Basel -_setCursorName__Q212connectivity23java_sql_Statement_BaseRCQ23rtl8OUString -_setMaxRows__Q212connectivity23java_sql_Statement_Basel -_setMaxFieldSize__Q212connectivity23java_sql_Statement_Basel -_setQueryTimeOut__Q212connectivity23java_sql_Statement_Basel -_getFetchSize__CQ212connectivity23java_sql_Statement_Base -_getFetchDirection__CQ212connectivity23java_sql_Statement_Base -_getResultSetType__CQ212connectivity23java_sql_Statement_Base -_getResultSetConcurrency__CQ212connectivity23java_sql_Statement_Base -_getCursorName__CQ212connectivity23java_sql_Statement_Base -_getMaxRows__CQ212connectivity23java_sql_Statement_Base -_getMaxFieldSize__CQ212connectivity23java_sql_Statement_Base -_getQueryTimeOut__CQ212connectivity23java_sql_Statement_Base -_getMyClass__Q212connectivity18java_sql_Statement -_saveClassRef__Q212connectivity23java_sql_Statement_BaseP7_jclass -_getMyClass__Q212connectivity23java_sql_Statement_Base -_saveClassRef__Q212connectivity16java_lang_StringP7_jclass -_saveClassRef__Q212connectivity19java_lang_ThrowableP7_jclass -_getMyClass__Q212connectivity18java_sql_Timestamp -_saveClassRef__Q212connectivity18java_sql_TimestampP7_jclass -_getMyClass__Q212connectivity13java_sql_Time -_saveClassRef__Q212connectivity13java_sql_TimeP7_jclass -_saveClassRef__Q212connectivity13java_sql_DateP7_jclass -___tf13bad_exception -___uncatch_exception -___eh_free -___tfv -___dynamic_cast diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu deleted file mode 100644 index dd0da5df4d..0000000000 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ /dev/null @@ -1,219 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--*********************************************************************** - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************ --> -<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <node oor:name="Installed"> - <node oor:name="jdbc:*" oor:op="replace"> - <prop oor:name="Driver"> - <value>com.sun.star.comp.sdbc.JDBCDriver</value> - </prop> - <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> - <value xml:lang="en-US">JDBC</value> - </prop> - <node oor:name="Properties"> - <node oor:name="JavaDriverClass" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:string"> - <value></value> - </prop> - </node> - <node oor:name="JavaDriverClassPath" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:string"> - <value></value> - </prop> - </node> - <node oor:name="AutoIncrementCreation" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:string"> - <value></value> - </prop> - </node> - <node oor:name="AutoRetrievingStatement" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:string"> - <value></value> - </prop> - </node> - <node oor:name="IsAutoRetrievingEnabled" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>false</value> - </prop> - </node> - <node oor:name="AddIndexAppendix" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - </node> - <node oor:name="Features"> - <node oor:name="GeneratedValues" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseSQL92NamingConstraints" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="AppendTableAliasInSelect" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseBracketedOuterJoinSyntax" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="IgnoreDriverPrivileges" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="ParameterNameSubstitution" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="DisplayVersionColumns" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseCatalogInSelect" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseSchemaInSelect" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseIndexDirectionKeyword" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseDOSLineEnds" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="BooleanComparisonMode" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="FormsCheckRequiredFields" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="EscapeDateTime" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="PrimaryKeySupport" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="RespectDriverResultSetType" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - </node> - <node oor:name="MetaData"> - <node oor:name="SupportsTableCreation" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="UseJava" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="Authentication" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:string"> - <value>UserPassword</value> - </prop> - </node> - </node> - </node> - <node oor:name="jdbc:oracle:thin:*" oor:op="replace"> - <prop oor:name="ParentURLPattern"> - <value>jdbc:*</value> - </prop> - <prop oor:name="DriverTypeDisplayName" oor:type="xs:string"> - <value xml:lang="en-US">Oracle JDBC</value> - </prop> - <node oor:name="Properties"> - <node oor:name="IgnoreCurrency" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - <node oor:name="TypeInfoSettings" oor:op="replace"> - <prop oor:name="Value" oor:type="oor:string-list"> - <value oor:separator=",">Column(2) = -5,Column(6) = PRECISION,Column(2) = -4,Column(6) = PRECISION,Column(2) = -3,Column(6) = PRECISION,Column(2) = -2,Column(6) = PRECISION,Column(2) = -1,Column(6) = PRECISION,Column(2) = -1,Column(6) = PRECISION,Column(2) = 2,Column(6) = PRECISION,Column(2) = 12,Column(6) = PRECISION</value> - </prop> - </node> - <node oor:name="JavaDriverClass" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:string"> - <value>oracle.jdbc.driver.OracleDriver</value> - </prop> - </node> - <node oor:name="AddIndexAppendix" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>false</value> - </prop> - </node> - </node> - <node oor:name="Features"> - <node oor:name="IgnoreCurrency" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:boolean"> - <value>true</value> - </prop> - </node> - </node> - <node oor:name="MetaData"> - <node oor:name="Authentication" oor:op="replace"> - <prop oor:name="Value" oor:type="xs:string"> - <value>UserPassword</value> - </prop> - </node> - </node> - </node> - </node> -</oor:component-data> diff --git a/connectivity/source/drivers/jdbc/jdbc.xml b/connectivity/source/drivers/jdbc/jdbc.xml deleted file mode 100755 index 8fe04eb8a5..0000000000 --- a/connectivity/source/drivers/jdbc/jdbc.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version='1.0' encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name> jdbc </module-name> - <component-description> - <author>Ocke Janssen</author> - <name>com.sun.star.comp.sdbc.JDBCDriver</name> - <description> - This is the implementation of the sdbc-jdbc bridge. - </description> - <loader-name>com.sun.star.loader.SharedLibrary</loader-name> - <language>c++</language> - <status value="final"/> - <supported-service> com.sun.star.sdbc.Driver </supported-service> - <service-dependency> ... </service-dependency> - </component-description> - <project-build-dependency>cppuhelper</project-build-dependency> - <project-build-dependency>cppu</project-build-dependency> - <project-build-dependency>sal</project-build-dependency> - <runtime-module-dependency>cppuhelper</runtime-module-dependency> - <runtime-module-dependency>cppu</runtime-module-dependency> - <runtime-module-dependency>sal</runtime-module-dependency> - <runtime-module-dependency>osl</runtime-module-dependency> - <runtime-module-dependency>dbtools</runtime-module-dependency> - <runtime-module-dependency>comphelper</runtime-module-dependency> -</module-description> - - diff --git a/connectivity/source/drivers/jdbc/jservices.cxx b/connectivity/source/drivers/jdbc/jservices.cxx deleted file mode 100644 index cf4d8cdc20..0000000000 --- a/connectivity/source/drivers/jdbc/jservices.cxx +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" -#include "java/sql/Driver.hxx" -#include <cppuhelper/factory.hxx> - -using namespace connectivity; -using ::rtl::OUString; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::lang::XSingleServiceFactory; -using ::com::sun::star::lang::XMultiServiceFactory; - -typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) - ( - const Reference< XMultiServiceFactory > & rServiceManager, - const OUString & rComponentName, - ::cppu::ComponentInstantiation pCreateFunction, - const Sequence< OUString > & rServiceNames, - rtl_ModuleCount* _pModCount - ); - -//--------------------------------------------------------------------------------------- -struct ProviderRequest -{ - Reference< XSingleServiceFactory > xRet; - Reference< XMultiServiceFactory > const xServiceManager; - OUString const sImplementationName; - - ProviderRequest( - void* pServiceManager, - sal_Char const* pImplementationName - ) - : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) - , sImplementationName(OUString::createFromAscii(pImplementationName)) - { - } - - inline - sal_Bool CREATE_PROVIDER( - const OUString& Implname, - const Sequence< OUString > & Services, - ::cppu::ComponentInstantiation Factory, - createFactoryFunc creator - ) - { - if (!xRet.is() && (Implname == sImplementationName)) - try - { - xRet = creator( xServiceManager, sImplementationName,Factory, Services,0); - } - catch(...) - { - } - return xRet.is(); - } - - void* getProvider() const { return xRet.get(); } -}; - -//--------------------------------------------------------------------------------------- -extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( - const sal_Char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/) -{ - void* pRet = 0; - if (pServiceManager) - { - ProviderRequest aReq(pServiceManager,pImplementationName); - - aReq.CREATE_PROVIDER( - java_sql_Driver::getImplementationName_Static(), - java_sql_Driver::getSupportedServiceNames_Static(), - java_sql_Driver_CreateInstance, - ::cppu::createSingleFactory); - - if(aReq.xRet.is()) - aReq.xRet->acquire(); - pRet = aReq.getProvider(); - } - - return pRet; -} - - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk deleted file mode 100755 index befdc73d7b..0000000000 --- a/connectivity/source/drivers/jdbc/makefile.mk +++ /dev/null @@ -1,120 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. -PRJINC=..$/.. -PRJNAME=connectivity -TARGET=jdbc - -ENABLE_EXCEPTIONS=TRUE -VISIBILITY_HIDDEN=TRUE - -# --- Settings ---------------------------------- -.IF "$(DBGUTIL_OJ)"!="" -ENVCFLAGS+=/FR$(SLO)$/ -.ENDIF - -.INCLUDE : $(PRJ)$/makefile.pmk -.INCLUDE : $(PRJ)$/version.mk - - -.IF "$(SOLAR_JAVA)" != "" - -# --- Files ------------------------------------- - -SLOFILES=\ - $(SLO)$/Array.obj \ - $(SLO)$/Blob.obj \ - $(SLO)$/Boolean.obj \ - $(SLO)$/CallableStatement.obj \ - $(SLO)$/Class.obj \ - $(SLO)$/Clob.obj \ - $(SLO)$/ConnectionLog.obj \ - $(SLO)$/DatabaseMetaData.obj \ - $(SLO)$/Date.obj \ - $(SLO)$/DriverPropertyInfo.obj \ - $(SLO)$/Exception.obj \ - $(SLO)$/InputStream.obj \ - $(SLO)$/JConnection.obj \ - $(SLO)$/JDriver.obj \ - $(SLO)$/JStatement.obj \ - $(SLO)$/Object.obj \ - $(SLO)$/PreparedStatement.obj \ - $(SLO)$/Reader.obj \ - $(SLO)$/Ref.obj \ - $(SLO)$/ResultSet.obj \ - $(SLO)$/ResultSetMetaData.obj \ - $(SLO)$/SQLException.obj \ - $(SLO)$/SQLWarning.obj \ - $(SLO)$/String.obj \ - $(SLO)$/Throwable.obj \ - $(SLO)$/Timestamp.obj \ - $(SLO)$/jservices.obj \ - $(SLO)$/JBigDecimal.obj \ - $(SLO)$/tools.obj \ - $(SLO)$/ContextClassLoader.obj - -SHL1VERSIONMAP=$(SOLARENV)/src/component.map - -# --- Library ----------------------------------- - -SHL1TARGET= $(JDBC_TARGET)$(DLLPOSTFIX) -SHL1OBJS=$(SLOFILES) -SHL1STDLIBS=\ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(SALLIB) \ - $(SALHELPERLIB) \ - $(JVMACCESSLIB) \ - $(DBTOOLSLIB) \ - $(UNOTOOLSLIB) \ - $(JVMFWKLIB) \ - $(COMPHELPERLIB) - -SHL1DEPN= -SHL1IMPLIB= i$(JDBC_TARGET) - -SHL1DEF= $(MISC)$/$(SHL1TARGET).def - -DEF1NAME= $(SHL1TARGET) -DEF1EXPORTFILE= exports.dxp - -.ENDIF # SOLAR_JAVA - -# --- Targets ---------------------------------- - -.INCLUDE : $(PRJ)$/target.pmk - - - -ALLTAR : $(MISC)/jdbc.component - -$(MISC)/jdbc.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ - jdbc.component - $(XSLTPROC) --nonet --stringparam uri \ - '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ - $(SOLARENV)/bin/createcomponent.xslt jdbc.component diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx deleted file mode 100644 index 4e938585c1..0000000000 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ /dev/null @@ -1,277 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_connectivity.hxx" - -#include <cstdarg> -#include "java/tools.hxx" -#include "java/lang/String.hxx" -#include "java/lang/Class.hxx" -#include "java/util/Property.hxx" -#include <com/sun/star/sdbc/DriverPropertyInfo.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <connectivity/dbexception.hxx> - -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; - -void java_util_Properties::setProperty(const ::rtl::OUString key, const ::rtl::OUString& value) -{ - SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); - jobject out(0); - - { - jvalue args[2]; - // Convert Parameter - args[0].l = convertwchar_tToJavaString(t.pEnv,key); - args[1].l = convertwchar_tToJavaString(t.pEnv,value); - // Initialize temporary Variables - static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;"; - static const char * cMethodName = "setProperty"; - // Turn off Java-Call - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l); - ThrowSQLException(t.pEnv,NULL); - t.pEnv->DeleteLocalRef((jstring)args[1].l); - t.pEnv->DeleteLocalRef((jstring)args[0].l); - ThrowSQLException(t.pEnv,0); - if(out) - t.pEnv->DeleteLocalRef(out); - } //t.pEnv - // WARNING: The caller will be owner of the returned pointers!!! -} -jclass java_util_Properties::theClass = 0; - -java_util_Properties::~java_util_Properties() -{} - -jclass java_util_Properties::getMyClass() const -{ - // the class needs only be called once, that is why it is static - if( !theClass ) - theClass = findMyClass("java/util/Properties"); - return theClass; -} - -//-------------------------------------------------------------------------- -java_util_Properties::java_util_Properties( ): java_lang_Object( NULL, (jobject)NULL ) -{ - SDBThreadAttach t; - if( !t.pEnv ) - return; - // Turn off Java-Call for the constructor - // Initialize temperary Variables - static const char * cSignature = "()V"; - jobject tempObj; - static jmethodID mID(NULL); - obtainMethodId(t.pEnv, "<init>",cSignature, mID); - tempObj = t.pEnv->NewObject( getMyClass(), mID); - saveRef( t.pEnv, tempObj ); - t.pEnv->DeleteLocalRef( tempObj ); -} - -// -------------------------------------------------------------------------------- -jstring connectivity::convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& _rTemp) -{ - OSL_ENSURE(pEnv,"Environment is NULL!"); - jstring pStr = pEnv->NewString(_rTemp.getStr(), _rTemp.getLength()); - pEnv->ExceptionClear(); - OSL_ENSURE(pStr,"Could not create a jsstring object!"); - return pStr; -} - -// -------------------------------------------------------------------------------- -java_util_Properties* connectivity::createStringPropertyArray(const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) -{ - java_util_Properties* pProps = new java_util_Properties(); - const PropertyValue* pBegin = info.getConstArray(); - const PropertyValue* pEnd = pBegin + info.getLength(); - - for(;pBegin != pEnd;++pBegin) - { - // this is a special property to find the jdbc driver - if ( pBegin->Name.compareToAscii( "JavaDriverClass" ) - && pBegin->Name.compareToAscii( "JavaDriverClassPath" ) - && pBegin->Name.compareToAscii( "SystemProperties" ) - && pBegin->Name.compareToAscii( "CharSet" ) - && pBegin->Name.compareToAscii( "AppendTableAliasName" ) - && pBegin->Name.compareToAscii( "AddIndexAppendix" ) - && pBegin->Name.compareToAscii( "FormsCheckRequiredFields" ) - && pBegin->Name.compareToAscii( "GenerateASBeforeCorrelationName" ) - && pBegin->Name.compareToAscii( "EscapeDateTime" ) - && pBegin->Name.compareToAscii( "ParameterNameSubstitution" ) - && pBegin->Name.compareToAscii( "IsPasswordRequired" ) - && pBegin->Name.compareToAscii( "IsAutoRetrievingEnabled" ) - && pBegin->Name.compareToAscii( "AutoRetrievingStatement" ) - && pBegin->Name.compareToAscii( "UseCatalogInSelect" ) - && pBegin->Name.compareToAscii( "UseSchemaInSelect" ) - && pBegin->Name.compareToAscii( "AutoIncrementCreation" ) - && pBegin->Name.compareToAscii( "Extension" ) - && pBegin->Name.compareToAscii( "NoNameLengthLimit" ) - && pBegin->Name.compareToAscii( "EnableSQL92Check" ) - && pBegin->Name.compareToAscii( "EnableOuterJoinEscape" ) - && pBegin->Name.compareToAscii( "BooleanComparisonMode" ) - && pBegin->Name.compareToAscii( "IgnoreCurrency" ) - && pBegin->Name.compareToAscii( "TypeInfoSettings" ) - && pBegin->Name.compareToAscii( "IgnoreDriverPrivileges" ) - && pBegin->Name.compareToAscii( "ImplicitCatalogRestriction" ) - && pBegin->Name.compareToAscii( "ImplicitSchemaRestriction" ) - && pBegin->Name.compareToAscii( "SupportsTableCreation" ) - && pBegin->Name.compareToAscii( "UseJava" ) - && pBegin->Name.compareToAscii( "Authentication" ) - && pBegin->Name.compareToAscii( "PreferDosLikeLineEnds" ) - && pBegin->Name.compareToAscii( "PrimaryKeySupport" ) - && pBegin->Name.compareToAscii( "RespectDriverResultSetType" ) - ) - { - ::rtl::OUString aStr; - OSL_VERIFY( pBegin->Value >>= aStr ); - pProps->setProperty(pBegin->Name,aStr); - } - } - return pProps; -} -// -------------------------------------------------------------------------------- -::rtl::OUString connectivity::JavaString2String(JNIEnv *pEnv,jstring _Str) -{ - ::rtl::OUString aStr; - if(_Str) - { - jboolean bCopy(sal_True); - const jchar* pChar = pEnv->GetStringChars(_Str,&bCopy); - jsize len = pEnv->GetStringLength(_Str); - aStr = ::rtl::OUString(pChar,len); - - if(bCopy) - pEnv->ReleaseStringChars(_Str,pChar); - pEnv->DeleteLocalRef(_Str); - } - return aStr; -} -// -------------------------------------------------------------------------------- -jobject connectivity::convertTypeMapToJavaMap(JNIEnv* /*pEnv*/,const Reference< ::com::sun::star::container::XNameAccess > & _rMap) -{ - if ( _rMap.is() ) - { - ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames = _rMap->getElementNames(); - if ( aNames.getLength() > 0 ) - ::dbtools::throwFeatureNotImplementedException( "Type maps", NULL ); - } - return 0; -} -// ----------------------------------------------------------------------------- -sal_Bool connectivity::isExceptionOccurred(JNIEnv *pEnv,sal_Bool _bClear) -{ - if ( !pEnv ) - return sal_False; - - jthrowable pThrowable = pEnv->ExceptionOccurred(); - sal_Bool bRet = pThrowable != NULL; - if ( pThrowable ) - { - if ( _bClear ) - pEnv->ExceptionClear(); -#if OSL_DEBUG_LEVEL > 1 - if(pEnv->IsInstanceOf(pThrowable,java_sql_SQLException_BASE::st_getMyClass())) - { - - java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE(pEnv,pThrowable); - ::rtl::OUString sError = pException->getMessage(); - delete pException; - } -#else - pEnv->DeleteLocalRef(pThrowable); -#endif - - } - - return bRet; -} -// ----------------------------------------------------------------------------- -jobject connectivity::createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length) -{ - SDBThreadAttach t; - if( !t.pEnv || !x.is() ) - return NULL; - // Turn off Java-Call for the constructor - // Initialize temperary variables - jclass clazz = java_lang_Object::findMyClass("java/io/ByteArrayInputStream"); - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "([B)V"; - mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature ); - OSL_ENSURE( mID, cSignature ); - if ( !mID ) - throw SQLException(); - } // if ( !_inout_MethodID ) - jbyteArray pByteArray = t.pEnv->NewByteArray(length); - Sequence< sal_Int8 > aData; - x->readBytes(aData,length); - jboolean p = sal_False; - rtl_copyMemory(t.pEnv->GetByteArrayElements(pByteArray,&p),aData.getArray(),aData.getLength()); - jobject out = t.pEnv->NewObject( clazz, mID,pByteArray); - t.pEnv->DeleteLocalRef((jbyteArray)pByteArray); - return out; -} -// ----------------------------------------------------------------------------- -jobject connectivity::createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length) -{ - SDBThreadAttach t; - if( !t.pEnv || !x.is() ) - return NULL; - // Turn off Java-Call for the constructor - // Initialize temperary Variables - jclass clazz = java_lang_Object::findMyClass("java/io/CharArrayReader"); - static jmethodID mID(NULL); - if ( !mID ) - { - static const char * cSignature = "([C)V"; - mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature ); - OSL_ENSURE( mID, cSignature ); - if ( !mID ) - throw SQLException(); - } // if ( !_inout_MethodID ) - jcharArray pCharArray = t.pEnv->NewCharArray(length); - Sequence< sal_Int8 > aData; - x->readBytes(aData,length); - jboolean p = sal_False; - rtl_copyMemory(t.pEnv->GetCharArrayElements(pCharArray,&p),aData.getArray(),aData.getLength()); - jobject out = t.pEnv->NewObject( clazz, mID,pCharArray); - t.pEnv->DeleteLocalRef((jcharArray)pCharArray); - return out; -} -// ----------------------------------------------------------------------------- - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |