Tag: cws_src680_sb36 User: sb Date: 2007/01/16 06:30:17 Modified: dba/connectivity/source/drivers/jdbc/JConnection.cxx
Log: #i51803# Merged in Connection.cxx:1.22.60.5. File Changes: Directory: /dba/connectivity/source/drivers/jdbc/ ================================================= File [changed]: JConnection.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/jdbc/JConnection.cxx?r1=1.2&r2=1.2.28.1 Delta lines: +68 -33 --------------------- --- JConnection.cxx 13 Dec 2006 16:18:43 -0000 1.2 +++ JConnection.cxx 16 Jan 2007 14:30:15 -0000 1.2.28.1 @@ -4,9 +4,9 @@ * * $RCSfile: JConnection.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.2.28.1 $ * - * last change: $Author: kz $ $Date: 2006/12/13 16:18:43 $ + * last change: $Author: sb $ $Date: 2007/01/16 14:30:15 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -70,6 +70,8 @@ #include "connectivity/dbexception.hxx" #endif #include "java/util/Property.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "jvmaccess/classpath.hxx" #include <memory> using namespace connectivity; @@ -690,24 +692,74 @@ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); try { + const PropertyValue* pJavaDriverClass = 0; + const PropertyValue* pJavaDriverClassPath = 0; const PropertyValue* pBegin = info.getConstArray(); const PropertyValue* pEnd = pBegin + info.getLength(); for(;pBegin != pEnd;++pBegin) { - if ( !object && !pBegin->Name.compareToAscii("JavaDriverClass") ) + if (!pBegin->Name.compareToAscii("JavaDriverClass")) + { + pJavaDriverClass = pBegin; + } + else if (!pBegin->Name.compareToAscii("JavaDriverClassPath")) + { + pJavaDriverClassPath = pBegin; + } + else if(!pBegin->Name.compareToAscii("IsAutoRetrievingEnabled")) + { + OSL_VERIFY( pBegin->Value >>= _rbAutoRetrievingEnabled ); + } + else if(!pBegin->Name.compareToAscii("AutoRetrievingStatement")) + { + OSL_VERIFY( pBegin->Value >>= _rsGeneratedValueStatement ); + } + else if(!pBegin->Name.compareToAscii("ParameterNameSubstitution")) + { + OSL_VERIFY( pBegin->Value >>= _bParameterSubstitution ); + } + else if(!pBegin->Name.compareToAscii("IgnoreDriverPrivileges")) + { + OSL_VERIFY( pBegin->Value >>= _bIgnoreDriverPrivileges ); + } + } + if ( !object && pJavaDriverClass != 0 ) { // here I try to find the class for jdbc driver java_sql_SQLException_BASE::getMyClass(); java_lang_Throwable::getMyClass(); ::rtl::OUString aStr; - OSL_VERIFY( pBegin->Value >>= aStr ); + OSL_VERIFY( pJavaDriverClass->Value >>= aStr ); OSL_ASSERT( aStr.getLength()); if ( aStr.getLength() ) { // the driver manager holds the class of the driver for later use + ::std::auto_ptr< java_lang_Class > pDrvClass; + if ( pJavaDriverClassPath == 0 ) + { // if forName didn't find the class it will throw an exception - ::std::auto_ptr< java_lang_Class > pDrvClass = ::std::auto_ptr< java_lang_Class >(java_lang_Class::forName(aStr)); + pDrvClass = ::std::auto_ptr< java_lang_Class >(java_lang_Class::forName(aStr)); + } + else + { + ::rtl::OUString classpath; + OSL_VERIFY( pJavaDriverClassPath->Value >>= classpath ); + pDrvClass.reset( + new java_lang_Class( + t.pEnv, + jvmaccess::ClassPath::loadClass( + Reference< XComponentContext >( + Reference< XPropertySet >( + m_pDriver->getORB(), + UNO_QUERY_THROW)->getPropertyValue( + ::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "DefaultContext"))), + UNO_QUERY_THROW), + t.pEnv, classpath, aStr))); + ThrowSQLException(t.pEnv, *this); + } if ( pDrvClass.get() ) { m_pDriverobject = pDrvClass->newInstanceObject(); @@ -725,23 +777,6 @@ } } } - else if(!pBegin->Name.compareToAscii("IsAutoRetrievingEnabled")) - { - OSL_VERIFY( pBegin->Value >>= _rbAutoRetrievingEnabled ); - } - else if(!pBegin->Name.compareToAscii("AutoRetrievingStatement")) - { - OSL_VERIFY( pBegin->Value >>= _rsGeneratedValueStatement ); - } - else if(!pBegin->Name.compareToAscii("ParameterNameSubstitution")) - { - OSL_VERIFY( pBegin->Value >>= _bParameterSubstitution ); - } - else if(!pBegin->Name.compareToAscii("IgnoreDriverPrivileges")) - { - OSL_VERIFY( pBegin->Value >>= _bIgnoreDriverPrivileges ); - } - } } catch(SQLException& e) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
