Tag: cws_src680_hsql1808
User: fs      
Date: 2007-10-16 13:11:22+0000
Modified:
   dba/connectivity/source/drivers/jdbc/JConnection.cxx
   dba/connectivity/source/drivers/jdbc/JDriver.cxx
   dba/connectivity/source/drivers/jdbc/tools.cxx

Log:
 support additional setting 'SystemProperties', which denotes properties to the 
set via java.lang.System.setProperty

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.5.14.1&r2=1.5.14.2
Delta lines:  +61 -2
--------------------
--- JConnection.cxx     2007-07-30 07:22:06+0000        1.5.14.1
+++ JConnection.cxx     2007-10-16 13:11:20+0000        1.5.14.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: JConnection.cxx,v $
  *
- *  $Revision: 1.5.14.1 $
+ *  $Revision: 1.5.14.2 $
  *
- *  last change: $Author: fs $ $Date: 2007/07/30 07:22:06 $
+ *  last change: $Author: fs $ $Date: 2007/10/16 13:11:20 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -66,6 +66,9 @@
 #ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_
 #include <com/sun/star/sdbc/SQLWarning.hpp>
 #endif
+#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
+#include <com/sun/star/beans/NamedValue.hpp>
+#endif
 #ifndef _CONNECTIVITY_SQLPARSE_HXX
 #include "connectivity/sqlparse.hxx"
 #endif
@@ -73,6 +76,7 @@
 #include "connectivity/dbexception.hxx"
 #endif
 #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"
@@ -83,6 +87,7 @@
 #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;
@@ -816,6 +821,52 @@
        return Any();
 }
 // 
-----------------------------------------------------------------------------
+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 Sequence< PropertyValue >& info, ::rtl::OUString& 
_rsGeneratedValueStatement,
                sal_Bool& _rbAutoRetrievingEnabled, sal_Bool& 
_bParameterSubstitution, sal_Bool& _bIgnoreDriverPrivileges )
@@ -824,6 +875,7 @@
     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
        try
        {
+        Sequence< NamedValue > aSystemProperties;
         const PropertyValue* pJavaDriverClass = 0;
         const PropertyValue* pJavaDriverClassPath = 0;
                const PropertyValue* pBegin     = info.getConstArray();
@@ -854,9 +906,16 @@
                        {
                                OSL_VERIFY( pBegin->Value >>= 
_bIgnoreDriverPrivileges );
                        }
+            else if(!pBegin->Name.compareToAscii("SystemProperties"))
+            {
+                OSL_VERIFY( pBegin->Value >>= aSystemProperties );
+            }
                }
         if ( !object && pJavaDriverClass != 0 )
         {
+            if ( !lcl_setSystemProperties_nothrow( getLogger(), *t.pEnv, 
aSystemProperties ) )
+                ThrowLoggedSQLException( getLogger(), t.pEnv, *this );
+
             // here I try to find the class for jdbc driver
             java_sql_SQLException_BASE::getMyClass();
             java_lang_Throwable::getMyClass();

File [changed]: JDriver.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/jdbc/JDriver.cxx?r1=1.38&r2=1.38.14.1
Delta lines:  +26 -5
--------------------
--- JDriver.cxx 2007-06-27 14:36:14+0000        1.38
+++ JDriver.cxx 2007-10-16 13:11:20+0000        1.38.14.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: JDriver.cxx,v $
  *
- *  $Revision: 1.38 $
+ *  $Revision: 1.38.14.1 $
  *
- *  last change: $Author: hr $ $Date: 2007/06/27 14:36:14 $
+ *  last change: $Author: fs $ $Date: 2007/10/16 13:11:20 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -176,9 +176,26 @@
                                
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))
                                
,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The JDBC driver class name."))
                                ,sal_True
-                               
,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.mysql.jdbc.Driver"))
+                               ,::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 
'?'."))
@@ -186,6 +203,7 @@
                                ,::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."))
@@ -193,6 +211,7 @@
                                ,::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."))
@@ -200,6 +219,7 @@
                                ,::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."))
@@ -207,6 +227,7 @@
                                ,::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."))

File [changed]: tools.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/jdbc/tools.cxx?r1=1.25&r2=1.25.40.1
Delta lines:  +4 -3
-------------------
--- tools.cxx   2007-03-12 10:41:24+0000        1.25
+++ tools.cxx   2007-10-16 13:11:20+0000        1.25.40.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: tools.cxx,v $
  *
- *  $Revision: 1.25 $
+ *  $Revision: 1.25.40.1 $
  *
- *  last change: $Author: obo $ $Date: 2007/03/12 10:41:24 $
+ *  last change: $Author: fs $ $Date: 2007/10/16 13:11:20 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -164,6 +164,7 @@
                // 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("AppendTableAlias") &&
                        
pBegin->Name.compareToAscii("GenerateASBeforeCorrelationName") &&




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to