Tag: cws_src680_dba28
User: fs      
Date: 05/03/23 06:55:42

Modified:
 /dba/connectivity/source/drivers/hsqldb/
  HDriver.cxx

Log:
 #i45314# proper SHUTDOWN of the DB when the last connection dies

File Changes:

Directory: /dba/connectivity/source/drivers/hsqldb/
===================================================

File [changed]: HDriver.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HDriver.cxx?r1=1.7.12.1&r2=1.7.12.2
Delta lines:  +44 -32
---------------------
--- HDriver.cxx 21 Mar 2005 12:53:32 -0000      1.7.12.1
+++ HDriver.cxx 23 Mar 2005 14:55:39 -0000      1.7.12.2
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: HDriver.cxx,v $
  *
- *  $Revision: 1.7.12.1 $
+ *  $Revision: 1.7.12.2 $
  *
- *  last change: $Author: fs $ $Date: 2005/03/21 12:53:32 $
+ *  last change: $Author: fs $ $Date: 2005/03/23 14:55:39 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -439,12 +439,12 @@
                                Reference<XStatement> xStmt = 
_xConnection->createStatement();
                                if ( xStmt.is() )
                 {
-                    Reference<XResultSet> 
xRes(xStmt->executeQuery(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" SELECT 
COUNT(*) FROM SYSTEM_SESSIONS WHERE USER_NAME ='SA'"))),UNO_QUERY);
+                    Reference<XResultSet> 
xRes(xStmt->executeQuery(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT 
COUNT(*) FROM SYSTEM_SESSIONS WHERE USER_NAME ='SA'"))),UNO_QUERY);
                     Reference<XRow> xRow(xRes,UNO_QUERY);
                     if ( xRow.is() && xRes->next() )
                         bLastOne = xRow->getInt(1) == 1;
                     if ( bLastOne )
-                                               
xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("shutdown")));
+                                               
xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN")));
                 }
                        }
                }
@@ -464,6 +464,8 @@
        {
                ::osl::MutexGuard aGuard(m_aMutex);
                Reference<XConnection> xCon(Source.Source,UNO_QUERY);
+        if ( xCon.is() )
+        {
         TWeakPairVector::iterator i = m_aConnections.begin();
                for (; m_aConnections.end() != i; ++i)
                {
@@ -473,13 +475,14 @@
                                break;
                        }
                }
-        if ( !xCon.is() )
+        }
+        else
         {
             Reference< XStorage> xStorage(Source.Source,UNO_QUERY);
             if ( xStorage.is() )
             {
                 ::rtl::OUString sKey = 
StorageContainer::getRegisteredKey(xStorage);
-                i = 
::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1(
+                TWeakPairVector::iterator i = 
::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1(
                                 ::std::bind2nd(::std::equal_to< 
::rtl::OUString >(),sKey)
                                 
,::std::compose1(::std::select1st<TWeakConnectionPair>(),::std::select2nd< 
TWeakPair >())));
                 if ( i != m_aConnections.end() )
@@ -516,6 +519,7 @@
         TWeakPairVector::iterator i = 
::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1(
                          ::std::bind2nd(::std::equal_to< ::rtl::OUString 
>(),sKey)
                         
,::std::compose1(::std::select1st<TWeakConnectionPair>(),::std::select2nd< 
TWeakPair >())));
+        OSL_ENSURE( i != m_aConnections.end(), "ODriverDelegator::preCommit: 
they're committing a storage which I do not know!" );
         if ( i != m_aConnections.end() )
         {
             try
@@ -524,14 +528,22 @@
                        if ( xConnection.is() )
                        {
                                Reference< XStatement> xStmt = 
xConnection->createStatement();
+                    OSL_ENSURE( xStmt.is(), "ODriverDelegator::preCommit: no 
statement!" );
                                if ( xStmt.is() )
-                                       {
-                                               
xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET WRITE_DELAY 
2")));
-                                       }
+                                               xStmt->execute( 
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 0" ) ) );
+
+                    sal_Bool bPreviousAutoCommit = 
xConnection->getAutoCommit();
+                    xConnection->setAutoCommit( sal_False );
+                    xConnection->commit();
+                    xConnection->setAutoCommit( bPreviousAutoCommit );
+
+                    if ( xStmt.is() )
+                                               xStmt->execute( 
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 60" ) ) );
                        }
                }
                catch(Exception&)
                {
+                OSL_ENSURE( false, "ODriverDelegator::preCommit: caught an 
exception!" );
                }
         }
     }




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

Reply via email to