1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 30*cdf0e10cSrcweir #include <unotools/tempfile.hxx> 31*cdf0e10cSrcweir #include "adabas/BDriver.hxx" 32*cdf0e10cSrcweir #include "adabas/BConnection.hxx" 33*cdf0e10cSrcweir #include "odbc/OFunctions.hxx" 34*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 35*cdf0e10cSrcweir #include "odbc/OTools.hxx" 36*cdf0e10cSrcweir #include "connectivity/dbexception.hxx" 37*cdf0e10cSrcweir #include "TConnection.hxx" 38*cdf0e10cSrcweir #include "diagnose_ex.h" 39*cdf0e10cSrcweir #include <vos/process.hxx> 40*cdf0e10cSrcweir #include <osl/process.h> 41*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx> 42*cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 43*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 44*cdf0e10cSrcweir #include "resource/adabas_res.hrc" 45*cdf0e10cSrcweir #include "resource/sharedresources.hxx" 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <memory> 49*cdf0e10cSrcweir #include <sys/stat.h> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #if defined(UNX) 52*cdf0e10cSrcweir const char sNewLine = '\012'; 53*cdf0e10cSrcweir #else 54*cdf0e10cSrcweir const char sNewLine[] = "\015\012"; // \015\012 and not \n 55*cdf0e10cSrcweir #endif 56*cdf0e10cSrcweir #define ADABAS_DB_11 "11.02.00" 57*cdf0e10cSrcweir #define ADABAS_KERNEL_11 "11.02" 58*cdf0e10cSrcweir #define ADABAS_DB_12 "12.01.00" 59*cdf0e10cSrcweir #define ADABAS_KERNEL_12 "12.01" 60*cdf0e10cSrcweir #define CURRENT_DB_VERSION "13.01.00" 61*cdf0e10cSrcweir #define CURRENT_KERNEL_VERSION "13.01" 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #define OPROCESS_ADABAS (OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath) 64*cdf0e10cSrcweir #define OPROCESS_ADABAS_DBG (OProcess::TOption_Wait | OProcess::TOption_SearchPath) 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir using namespace connectivity; 68*cdf0e10cSrcweir namespace connectivity 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir namespace adabas 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir // extern declaration of the function pointer 73*cdf0e10cSrcweir extern T3SQLAllocHandle pODBC3SQLAllocHandle; 74*cdf0e10cSrcweir extern T3SQLConnect pODBC3SQLConnect; 75*cdf0e10cSrcweir extern T3SQLDriverConnect pODBC3SQLDriverConnect; 76*cdf0e10cSrcweir extern T3SQLBrowseConnect pODBC3SQLBrowseConnect; 77*cdf0e10cSrcweir extern T3SQLDataSources pODBC3SQLDataSources; 78*cdf0e10cSrcweir extern T3SQLDrivers pODBC3SQLDrivers; 79*cdf0e10cSrcweir extern T3SQLGetInfo pODBC3SQLGetInfo; 80*cdf0e10cSrcweir extern T3SQLGetFunctions pODBC3SQLGetFunctions; 81*cdf0e10cSrcweir extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo; 82*cdf0e10cSrcweir extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr; 83*cdf0e10cSrcweir extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr; 84*cdf0e10cSrcweir extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr; 85*cdf0e10cSrcweir extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr; 86*cdf0e10cSrcweir extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr; 87*cdf0e10cSrcweir extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr; 88*cdf0e10cSrcweir //extern T3SQLSetDescField pODBC3SQLSetDescField; 89*cdf0e10cSrcweir //extern T3SQLGetDescField pODBC3SQLGetDescField; 90*cdf0e10cSrcweir //extern T3SQLGetDescRec pODBC3SQLGetDescRec; 91*cdf0e10cSrcweir //extern T3SQLSetDescRec pODBC3SQLSetDescRec; 92*cdf0e10cSrcweir extern T3SQLPrepare pODBC3SQLPrepare; 93*cdf0e10cSrcweir extern T3SQLBindParameter pODBC3SQLBindParameter; 94*cdf0e10cSrcweir //extern T3SQLGetCursorName pODBC3SQLGetCursorName; 95*cdf0e10cSrcweir extern T3SQLSetCursorName pODBC3SQLSetCursorName; 96*cdf0e10cSrcweir extern T3SQLExecute pODBC3SQLExecute; 97*cdf0e10cSrcweir extern T3SQLExecDirect pODBC3SQLExecDirect; 98*cdf0e10cSrcweir //extern T3SQLNativeSql pODBC3SQLNativeSql; 99*cdf0e10cSrcweir extern T3SQLDescribeParam pODBC3SQLDescribeParam; 100*cdf0e10cSrcweir extern T3SQLNumParams pODBC3SQLNumParams; 101*cdf0e10cSrcweir extern T3SQLParamData pODBC3SQLParamData; 102*cdf0e10cSrcweir extern T3SQLPutData pODBC3SQLPutData; 103*cdf0e10cSrcweir extern T3SQLRowCount pODBC3SQLRowCount; 104*cdf0e10cSrcweir extern T3SQLNumResultCols pODBC3SQLNumResultCols; 105*cdf0e10cSrcweir extern T3SQLDescribeCol pODBC3SQLDescribeCol; 106*cdf0e10cSrcweir extern T3SQLColAttribute pODBC3SQLColAttribute; 107*cdf0e10cSrcweir extern T3SQLBindCol pODBC3SQLBindCol; 108*cdf0e10cSrcweir extern T3SQLFetch pODBC3SQLFetch; 109*cdf0e10cSrcweir extern T3SQLFetchScroll pODBC3SQLFetchScroll; 110*cdf0e10cSrcweir extern T3SQLGetData pODBC3SQLGetData; 111*cdf0e10cSrcweir extern T3SQLSetPos pODBC3SQLSetPos; 112*cdf0e10cSrcweir extern T3SQLBulkOperations pODBC3SQLBulkOperations; 113*cdf0e10cSrcweir extern T3SQLMoreResults pODBC3SQLMoreResults; 114*cdf0e10cSrcweir //extern T3SQLGetDiagField pODBC3SQLGetDiagField; 115*cdf0e10cSrcweir extern T3SQLGetDiagRec pODBC3SQLGetDiagRec; 116*cdf0e10cSrcweir extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges; 117*cdf0e10cSrcweir extern T3SQLColumns pODBC3SQLColumns; 118*cdf0e10cSrcweir extern T3SQLForeignKeys pODBC3SQLForeignKeys; 119*cdf0e10cSrcweir extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys; 120*cdf0e10cSrcweir extern T3SQLProcedureColumns pODBC3SQLProcedureColumns; 121*cdf0e10cSrcweir extern T3SQLProcedures pODBC3SQLProcedures; 122*cdf0e10cSrcweir extern T3SQLSpecialColumns pODBC3SQLSpecialColumns; 123*cdf0e10cSrcweir extern T3SQLStatistics pODBC3SQLStatistics; 124*cdf0e10cSrcweir extern T3SQLTablePrivileges pODBC3SQLTablePrivileges; 125*cdf0e10cSrcweir extern T3SQLTables pODBC3SQLTables; 126*cdf0e10cSrcweir extern T3SQLFreeStmt pODBC3SQLFreeStmt; 127*cdf0e10cSrcweir extern T3SQLCloseCursor pODBC3SQLCloseCursor; 128*cdf0e10cSrcweir extern T3SQLCancel pODBC3SQLCancel; 129*cdf0e10cSrcweir extern T3SQLEndTran pODBC3SQLEndTran; 130*cdf0e10cSrcweir extern T3SQLDisconnect pODBC3SQLDisconnect; 131*cdf0e10cSrcweir extern T3SQLFreeHandle pODBC3SQLFreeHandle; 132*cdf0e10cSrcweir extern T3SQLGetCursorName pODBC3SQLGetCursorName; 133*cdf0e10cSrcweir extern T3SQLNativeSql pODBC3SQLNativeSql; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 136*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 137*cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 138*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 139*cdf0e10cSrcweir using namespace ::com::sun::star::container; 140*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 141*cdf0e10cSrcweir using namespace utl; 142*cdf0e10cSrcweir using namespace osl; 143*cdf0e10cSrcweir using namespace vos; 144*cdf0e10cSrcweir using namespace ::dbtools; 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir sal_Bool LoadFunctions(oslModule pODBCso); 147*cdf0e10cSrcweir sal_Bool LoadLibrary_ADABAS(::rtl::OUString &_rPath); 148*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 149*cdf0e10cSrcweir void ODriver::fillInfo(const Sequence< PropertyValue >& info, TDatabaseStruct& _rDBInfo) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir const PropertyValue* pIter = info.getConstArray(); 152*cdf0e10cSrcweir const PropertyValue* pEnd = pIter + info.getLength(); 153*cdf0e10cSrcweir for(;pIter != pEnd;++pIter) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseName")))) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sDBName; 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser")))) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sControlUser; 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword")))) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sControlPassword; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement")))) 168*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.nDataIncrement; 169*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase")))) 170*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.bShutDown; 171*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("User")))) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sSysUser; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Password")))) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sSysPassword; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DomainPassword")))) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sDomainPassword; 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CacheSize")))) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sCacheSize; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RestoreDatabase")))) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.bRestoreDatabase; 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Backup")))) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sBackupFile; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataDevSpace")))) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sDataDevName; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSDEVSPACE")))) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sSysDevSpace; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TRANSACTION_LOG")))) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.sTransLogName; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataDevSize")))) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.nDataSize; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LogDevSize")))) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir pIter->Value >>= _rDBInfo.nLogSize; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 220*cdf0e10cSrcweir ODriver::ODriver(const Reference< XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir osl_incrementInterlockedCount(&m_refCount); 223*cdf0e10cSrcweir fillEnvironmentVariables(); 224*cdf0e10cSrcweir Reference< XComponent > xComponent(m_xORB, UNO_QUERY); 225*cdf0e10cSrcweir if (xComponent.is()) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY); 228*cdf0e10cSrcweir xComponent->addEventListener(xEvtL); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir osl_decrementInterlockedCount(&m_refCount); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir //------------------------------------------------------------------------------ 233*cdf0e10cSrcweir void ODriver::disposing() 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 236*cdf0e10cSrcweir ODriver_BASE::disposing(); 237*cdf0e10cSrcweir Reference< XComponent > xComponent(m_xORB, UNO_QUERY); 238*cdf0e10cSrcweir if (xComponent.is()) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir Reference< XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY); 241*cdf0e10cSrcweir xComponent->removeEventListener(xEvtL); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir m_xORB.clear(); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir // static ServiceInfo 247*cdf0e10cSrcweir //------------------------------------------------------------------------------ 248*cdf0e10cSrcweir rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sdbcx.adabas.ODriver")); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir //------------------------------------------------------------------------------ 253*cdf0e10cSrcweir Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSNS( 2 ); 256*cdf0e10cSrcweir aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.Driver")); 257*cdf0e10cSrcweir aSNS[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbcx.Driver")); 258*cdf0e10cSrcweir return aSNS; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir //------------------------------------------------------------------ 261*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir return getImplementationName_Static(); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir //------------------------------------------------------------------ 267*cdf0e10cSrcweir sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir const Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); 270*cdf0e10cSrcweir const ::rtl::OUString* pSupported = aSupported.getConstArray(); 271*cdf0e10cSrcweir const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 272*cdf0e10cSrcweir for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) 273*cdf0e10cSrcweir ; 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir return pSupported != pEnd; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir //------------------------------------------------------------------ 278*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir return getSupportedServiceNames_Static(); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir //------------------------------------------------------------------ 283*cdf0e10cSrcweir Any SAL_CALL ODriver::queryInterface( const Type & rType ) throw(RuntimeException) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir Any aRet = ::cppu::queryInterface(rType, static_cast<XDataDefinitionSupplier*>(this)); 286*cdf0e10cSrcweir if ( !aRet.hasValue() ) 287*cdf0e10cSrcweir aRet = ODriver_BASE::queryInterface(rType); 288*cdf0e10cSrcweir return aRet.hasValue() ? aRet : ODriver_BASE2::queryInterface(rType); 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir //------------------------------------------------------------------ 291*cdf0e10cSrcweir Reference< XInterface > SAL_CALL ODriver_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFac) throw( Exception ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir return *(new ODriver(_rxFac)); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 296*cdf0e10cSrcweir void SAL_CALL ODriver::disposing( const EventObject& Source ) throw(RuntimeException) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir if(m_xORB.is() && Reference< XMultiServiceFactory >(Source.Source,UNO_QUERY) == m_xORB) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir TDatabaseMap::iterator aIter = m_aDatabaseMap.begin(); 303*cdf0e10cSrcweir for(;aIter != m_aDatabaseMap.end();++aIter) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir if(aIter->second.bShutDown) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir ::rtl::OUString sName; 308*cdf0e10cSrcweir if(getDBName(aIter->first,sName)) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN QUICK")),sName,aIter->second.sControlUser,aIter->second.sControlPassword); 311*cdf0e10cSrcweir X_STOP(sName); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir m_xORB.clear(); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 319*cdf0e10cSrcweir Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir if ( ! acceptsURL(url) ) 322*cdf0e10cSrcweir return NULL; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 325*cdf0e10cSrcweir if (ODriver_BASE::rBHelper.bDisposed) 326*cdf0e10cSrcweir throw DisposedException(); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir TDatabaseStruct aDBInfo; 329*cdf0e10cSrcweir aDBInfo.bShutDown = sal_False; 330*cdf0e10cSrcweir fillInfo(info,aDBInfo); 331*cdf0e10cSrcweir aDBInfo.sControlUser = aDBInfo.sControlUser.toAsciiUpperCase(); 332*cdf0e10cSrcweir aDBInfo.sControlPassword = aDBInfo.sControlPassword.toAsciiUpperCase(); 333*cdf0e10cSrcweir aDBInfo.sSysUser = aDBInfo.sSysUser.toAsciiUpperCase(); 334*cdf0e10cSrcweir aDBInfo.sSysPassword = aDBInfo.sSysPassword.toAsciiUpperCase(); 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir TDatabaseMap::iterator aFind = m_aDatabaseMap.find(url); 338*cdf0e10cSrcweir if(aFind == m_aDatabaseMap.end()) // only when not found yet 339*cdf0e10cSrcweir m_aDatabaseMap[url] = aDBInfo; 340*cdf0e10cSrcweir else 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir if(aFind->second.bShutDown != aDBInfo.bShutDown) 343*cdf0e10cSrcweir aFind->second.bShutDown &= aDBInfo.bShutDown; 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir ::rtl::OUString sName; 347*cdf0e10cSrcweir if(aDBInfo.sControlPassword.getLength() && aDBInfo.sControlUser.getLength() && getDBName(url,sName)) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir // check if we have to add a new data dev space 350*cdf0e10cSrcweir checkAndInsertNewDevSpace(sName,aDBInfo); 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir convertOldVersion(sName,aDBInfo); 353*cdf0e10cSrcweir // check if we must restart the database 354*cdf0e10cSrcweir checkAndRestart(sName,aDBInfo); 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir if(!m_pDriverHandle) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir ::rtl::OUString aPath; 361*cdf0e10cSrcweir if(!EnvironmentHandle(aPath)) 362*cdf0e10cSrcweir throw SQLException(aPath,*this,::rtl::OUString(),1000,Any()); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir OAdabasConnection* pCon = new OAdabasConnection(m_pDriverHandle,this); 365*cdf0e10cSrcweir Reference< XConnection > xCon = pCon; 366*cdf0e10cSrcweir SQLRETURN nSQLRETURN = pCon->Construct(url,info); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir odbc::OTools::ThrowException(pCon,nSQLRETURN,pCon->getConnection(),SQL_HANDLE_DBC,*this); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir m_xConnections.push_back(WeakReferenceHelper(*pCon)); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir return xCon; 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 378*cdf0e10cSrcweir sal_Bool ODriver::getDBName(const ::rtl::OUString& _rName,::rtl::OUString& sDBName) const 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir sDBName = ::rtl::OUString(); 381*cdf0e10cSrcweir ::rtl::OUString sName = _rName.copy(12); 382*cdf0e10cSrcweir sal_Int32 nPos = sName.indexOf(':'); 383*cdf0e10cSrcweir if(nPos != -1 && nPos < 1) 384*cdf0e10cSrcweir sDBName = sName.copy(1); 385*cdf0e10cSrcweir return (nPos != -1 && nPos < 1); 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 388*cdf0e10cSrcweir sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) 389*cdf0e10cSrcweir throw(SQLException, RuntimeException) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir return (!url.compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:adabas:")),12)); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 394*cdf0e10cSrcweir Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/) throw(SQLException, RuntimeException) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir if ( acceptsURL(url) ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir ::std::vector< DriverPropertyInfo > aDriverInfo; 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir aDriverInfo.push_back(DriverPropertyInfo( 401*cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase")) 402*cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Shut down service when closing.")) 403*cdf0e10cSrcweir ,sal_False 404*cdf0e10cSrcweir ,::rtl::OUString() 405*cdf0e10cSrcweir ,Sequence< ::rtl::OUString >()) 406*cdf0e10cSrcweir ); 407*cdf0e10cSrcweir aDriverInfo.push_back(DriverPropertyInfo( 408*cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser")) 409*cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control user name.")) 410*cdf0e10cSrcweir ,sal_False 411*cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0")) 412*cdf0e10cSrcweir ,Sequence< ::rtl::OUString >()) 413*cdf0e10cSrcweir ); 414*cdf0e10cSrcweir aDriverInfo.push_back(DriverPropertyInfo( 415*cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword")) 416*cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control password.")) 417*cdf0e10cSrcweir ,sal_False 418*cdf0e10cSrcweir ,::rtl::OUString() 419*cdf0e10cSrcweir ,Sequence< ::rtl::OUString >()) 420*cdf0e10cSrcweir ); 421*cdf0e10cSrcweir aDriverInfo.push_back(DriverPropertyInfo( 422*cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement")) 423*cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data increment (MB).")) 424*cdf0e10cSrcweir ,sal_False 425*cdf0e10cSrcweir ,::rtl::OUString() 426*cdf0e10cSrcweir ,Sequence< ::rtl::OUString >()) 427*cdf0e10cSrcweir ); 428*cdf0e10cSrcweir aDriverInfo.push_back(DriverPropertyInfo( 429*cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet")) 430*cdf0e10cSrcweir ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database.")) 431*cdf0e10cSrcweir ,sal_False 432*cdf0e10cSrcweir ,::rtl::OUString() 433*cdf0e10cSrcweir ,Sequence< ::rtl::OUString >()) 434*cdf0e10cSrcweir ); 435*cdf0e10cSrcweir return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size()); 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir SharedResources aResources; 439*cdf0e10cSrcweir const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); 440*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sMessage ,*this); 441*cdf0e10cSrcweir return Sequence< DriverPropertyInfo >(); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 444*cdf0e10cSrcweir sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir return 1; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 449*cdf0e10cSrcweir sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir return 0; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 454*cdf0e10cSrcweir // XCreateCatalog 455*cdf0e10cSrcweir void SAL_CALL ODriver::createCatalog( const Sequence< PropertyValue >& info ) throw(SQLException, ElementExistException, RuntimeException) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 458*cdf0e10cSrcweir if (ODriver_BASE::rBHelper.bDisposed) 459*cdf0e10cSrcweir throw DisposedException(); 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir try 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir TDatabaseStruct aDBInfo; 464*cdf0e10cSrcweir fillInfo(info,aDBInfo); 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir ::rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("DBSERVICE")); 467*cdf0e10cSrcweir ::rtl::OUString envData(RTL_CONSTASCII_USTRINGPARAM("0")); 468*cdf0e10cSrcweir osl_setEnvironment(envVar.pData, envData.pData); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir m_sDbRunDir = m_sDbWorkURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/wrk/")) + aDBInfo.sDBName; 471*cdf0e10cSrcweir String sTemp; 472*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(m_sDbRunDir,sTemp); 473*cdf0e10cSrcweir m_sDbRunDir = sTemp; 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir createNeededDirs(aDBInfo.sDBName); 476*cdf0e10cSrcweir if(CreateFiles(aDBInfo)) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 479*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( 480*cdf0e10cSrcweir STR_NO_DISK_SPACE, 481*cdf0e10cSrcweir "$filename$",aDBInfo.sDBName 482*cdf0e10cSrcweir ) ); 483*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sError,*this); 484*cdf0e10cSrcweir } // if(CreateFiles(aDBInfo)) 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir createDb(aDBInfo); 487*cdf0e10cSrcweir } 488*cdf0e10cSrcweir catch( SQLException&) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir throw; 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir catch(Exception&) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir throw SQLException(); 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 499*cdf0e10cSrcweir // XDropCatalog 500*cdf0e10cSrcweir void SAL_CALL ODriver::dropCatalog( const ::rtl::OUString& /*catalogName*/, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, NoSuchElementException, RuntimeException) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 503*cdf0e10cSrcweir if (ODriver_BASE::rBHelper.bDisposed) 504*cdf0e10cSrcweir throw DisposedException(); 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "!XDropCatalog::dropCatalog", *this ); 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir //----------------------------------------------------------------------------- 509*cdf0e10cSrcweir // ODBC Environment (gemeinsam fuer alle Connections): 510*cdf0e10cSrcweir SQLHANDLE ODriver::EnvironmentHandle(::rtl::OUString &_rPath) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir // Ist (fuer diese Instanz) bereits ein Environment erzeugt worden? 513*cdf0e10cSrcweir if (!m_pDriverHandle) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir SQLHANDLE h = SQL_NULL_HANDLE; 516*cdf0e10cSrcweir // Environment allozieren 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir // ODBC-DLL jetzt laden: 519*cdf0e10cSrcweir if (! LoadLibrary_ADABAS(_rPath)) 520*cdf0e10cSrcweir return SQL_NULL_HANDLE; 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir if (N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS) 523*cdf0e10cSrcweir return SQL_NULL_HANDLE; 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir // In globaler Struktur merken ... 526*cdf0e10cSrcweir m_pDriverHandle = h; 527*cdf0e10cSrcweir SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER); 528*cdf0e10cSrcweir OSL_UNUSED( nError ); 529*cdf0e10cSrcweir //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir return m_pDriverHandle; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 535*cdf0e10cSrcweir // XDataDefinitionSupplier 536*cdf0e10cSrcweir Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 539*cdf0e10cSrcweir if (ODriver_BASE::rBHelper.bDisposed) 540*cdf0e10cSrcweir throw DisposedException(); 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir Reference< XTablesSupplier > xTab; 543*cdf0e10cSrcweir Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY); 544*cdf0e10cSrcweir if ( xTunnel.is() ) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir OAdabasConnection* pConnection = NULL; 548*cdf0e10cSrcweir OAdabasConnection* pSearchConnection = reinterpret_cast< OAdabasConnection* >( xTunnel->getSomething(OAdabasConnection::getUnoTunnelImplementationId()) ); 549*cdf0e10cSrcweir for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir if ( (OAdabasConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection ) 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir pConnection = pSearchConnection; 554*cdf0e10cSrcweir break; 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir if ( pConnection ) 560*cdf0e10cSrcweir xTab = pConnection->createCatalog(); 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir return xTab; 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir // -------------------------------------------------------------------------------- 566*cdf0e10cSrcweir Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir if ( ! acceptsURL(url) ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir SharedResources aResources; 571*cdf0e10cSrcweir const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR); 572*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sMessage ,*this); 573*cdf0e10cSrcweir } // if ( ! acceptsURL(url) ) 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir return getDataDefinitionByConnection(connect(url,info)); 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 578*cdf0e10cSrcweir void SAL_CALL ODriver::acquire() throw() 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir ODriver_BASE::acquire(); 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 583*cdf0e10cSrcweir void SAL_CALL ODriver::release() throw() 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir ODriver_BASE::release(); 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir ODriver::~ODriver() 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 591*cdf0e10cSrcweir oslGenericFunction ODriver::getOdbcFunction(sal_Int32 _nIndex) const 592*cdf0e10cSrcweir { 593*cdf0e10cSrcweir oslGenericFunction pFunction = NULL; 594*cdf0e10cSrcweir switch(_nIndex) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir case ODBC3SQLAllocHandle: 597*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLAllocHandle;; 598*cdf0e10cSrcweir break; 599*cdf0e10cSrcweir case ODBC3SQLConnect: 600*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLConnect; 601*cdf0e10cSrcweir break; 602*cdf0e10cSrcweir case ODBC3SQLDriverConnect: 603*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLDriverConnect; 604*cdf0e10cSrcweir break; 605*cdf0e10cSrcweir case ODBC3SQLBrowseConnect: 606*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLBrowseConnect; 607*cdf0e10cSrcweir break; 608*cdf0e10cSrcweir case ODBC3SQLDataSources: 609*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLDataSources; 610*cdf0e10cSrcweir break; 611*cdf0e10cSrcweir case ODBC3SQLDrivers: 612*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLDrivers; 613*cdf0e10cSrcweir break; 614*cdf0e10cSrcweir case ODBC3SQLGetInfo: 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetInfo; 617*cdf0e10cSrcweir break; 618*cdf0e10cSrcweir case ODBC3SQLGetFunctions: 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetFunctions; 621*cdf0e10cSrcweir break; 622*cdf0e10cSrcweir case ODBC3SQLGetTypeInfo: 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetTypeInfo; 625*cdf0e10cSrcweir break; 626*cdf0e10cSrcweir case ODBC3SQLSetConnectAttr: 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLSetConnectAttr; 629*cdf0e10cSrcweir break; 630*cdf0e10cSrcweir case ODBC3SQLGetConnectAttr: 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetConnectAttr; 633*cdf0e10cSrcweir break; 634*cdf0e10cSrcweir case ODBC3SQLSetEnvAttr: 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLSetEnvAttr; 637*cdf0e10cSrcweir break; 638*cdf0e10cSrcweir case ODBC3SQLGetEnvAttr: 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetEnvAttr; 641*cdf0e10cSrcweir break; 642*cdf0e10cSrcweir case ODBC3SQLSetStmtAttr: 643*cdf0e10cSrcweir 644*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLSetStmtAttr; 645*cdf0e10cSrcweir break; 646*cdf0e10cSrcweir case ODBC3SQLGetStmtAttr: 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetStmtAttr; 649*cdf0e10cSrcweir break; 650*cdf0e10cSrcweir case ODBC3SQLPrepare: 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLPrepare; 653*cdf0e10cSrcweir break; 654*cdf0e10cSrcweir case ODBC3SQLBindParameter: 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLBindParameter; 657*cdf0e10cSrcweir break; 658*cdf0e10cSrcweir case ODBC3SQLSetCursorName: 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLSetCursorName; 661*cdf0e10cSrcweir break; 662*cdf0e10cSrcweir case ODBC3SQLExecute: 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLExecute; 665*cdf0e10cSrcweir break; 666*cdf0e10cSrcweir case ODBC3SQLExecDirect: 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLExecDirect; 669*cdf0e10cSrcweir break; 670*cdf0e10cSrcweir case ODBC3SQLDescribeParam: 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLDescribeParam; 673*cdf0e10cSrcweir break; 674*cdf0e10cSrcweir case ODBC3SQLNumParams: 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLNumParams; 677*cdf0e10cSrcweir break; 678*cdf0e10cSrcweir case ODBC3SQLParamData: 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLParamData; 681*cdf0e10cSrcweir break; 682*cdf0e10cSrcweir case ODBC3SQLPutData: 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLPutData; 685*cdf0e10cSrcweir break; 686*cdf0e10cSrcweir case ODBC3SQLRowCount: 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLRowCount; 689*cdf0e10cSrcweir break; 690*cdf0e10cSrcweir case ODBC3SQLNumResultCols: 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLNumResultCols; 693*cdf0e10cSrcweir break; 694*cdf0e10cSrcweir case ODBC3SQLDescribeCol: 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLDescribeCol; 697*cdf0e10cSrcweir break; 698*cdf0e10cSrcweir case ODBC3SQLColAttribute: 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLColAttribute; 701*cdf0e10cSrcweir break; 702*cdf0e10cSrcweir case ODBC3SQLBindCol: 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLBindCol; 705*cdf0e10cSrcweir break; 706*cdf0e10cSrcweir case ODBC3SQLFetch: 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLFetch; 709*cdf0e10cSrcweir break; 710*cdf0e10cSrcweir case ODBC3SQLFetchScroll: 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLFetchScroll; 713*cdf0e10cSrcweir break; 714*cdf0e10cSrcweir case ODBC3SQLGetData: 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetData; 717*cdf0e10cSrcweir break; 718*cdf0e10cSrcweir case ODBC3SQLSetPos: 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLSetPos; 721*cdf0e10cSrcweir break; 722*cdf0e10cSrcweir case ODBC3SQLBulkOperations: 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLBulkOperations; 725*cdf0e10cSrcweir break; 726*cdf0e10cSrcweir case ODBC3SQLMoreResults: 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLMoreResults; 729*cdf0e10cSrcweir break; 730*cdf0e10cSrcweir case ODBC3SQLGetDiagRec: 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetDiagRec; 733*cdf0e10cSrcweir break; 734*cdf0e10cSrcweir case ODBC3SQLColumnPrivileges: 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLColumnPrivileges; 737*cdf0e10cSrcweir break; 738*cdf0e10cSrcweir case ODBC3SQLColumns: 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLColumns; 741*cdf0e10cSrcweir break; 742*cdf0e10cSrcweir case ODBC3SQLForeignKeys: 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLForeignKeys; 745*cdf0e10cSrcweir break; 746*cdf0e10cSrcweir case ODBC3SQLPrimaryKeys: 747*cdf0e10cSrcweir 748*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLPrimaryKeys; 749*cdf0e10cSrcweir break; 750*cdf0e10cSrcweir case ODBC3SQLProcedureColumns: 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLProcedureColumns; 753*cdf0e10cSrcweir break; 754*cdf0e10cSrcweir case ODBC3SQLProcedures: 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLProcedures; 757*cdf0e10cSrcweir break; 758*cdf0e10cSrcweir case ODBC3SQLSpecialColumns: 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLSpecialColumns; 761*cdf0e10cSrcweir break; 762*cdf0e10cSrcweir case ODBC3SQLStatistics: 763*cdf0e10cSrcweir 764*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLStatistics; 765*cdf0e10cSrcweir break; 766*cdf0e10cSrcweir case ODBC3SQLTablePrivileges: 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLTablePrivileges; 769*cdf0e10cSrcweir break; 770*cdf0e10cSrcweir case ODBC3SQLTables: 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLTables; 773*cdf0e10cSrcweir break; 774*cdf0e10cSrcweir case ODBC3SQLFreeStmt: 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLFreeStmt; 777*cdf0e10cSrcweir break; 778*cdf0e10cSrcweir case ODBC3SQLCloseCursor: 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLCloseCursor; 781*cdf0e10cSrcweir break; 782*cdf0e10cSrcweir case ODBC3SQLCancel: 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLCancel; 785*cdf0e10cSrcweir break; 786*cdf0e10cSrcweir case ODBC3SQLEndTran: 787*cdf0e10cSrcweir 788*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLEndTran; 789*cdf0e10cSrcweir break; 790*cdf0e10cSrcweir case ODBC3SQLDisconnect: 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLDisconnect; 793*cdf0e10cSrcweir break; 794*cdf0e10cSrcweir case ODBC3SQLFreeHandle: 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLFreeHandle; 797*cdf0e10cSrcweir break; 798*cdf0e10cSrcweir case ODBC3SQLGetCursorName: 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLGetCursorName; 801*cdf0e10cSrcweir break; 802*cdf0e10cSrcweir case ODBC3SQLNativeSql: 803*cdf0e10cSrcweir 804*cdf0e10cSrcweir pFunction = (oslGenericFunction)pODBC3SQLNativeSql; 805*cdf0e10cSrcweir break; 806*cdf0e10cSrcweir default: 807*cdf0e10cSrcweir OSL_ENSURE(0,"Function unknown!"); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir return pFunction; 810*cdf0e10cSrcweir } 811*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 812*cdf0e10cSrcweir void ODriver::createNeededDirs(const ::rtl::OUString& sDBName) 813*cdf0e10cSrcweir { 814*cdf0e10cSrcweir ::rtl::OUString sDbWork,sDBConfig,sTemp; 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir if(m_sDbWork.getLength()) 817*cdf0e10cSrcweir { 818*cdf0e10cSrcweir sDbWork = m_sDbWorkURL; 819*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(m_sDbWorkURL)) 820*cdf0e10cSrcweir UCBContentHelper::MakeFolder(m_sDbWorkURL); 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); 823*cdf0e10cSrcweir sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("wrk")); 824*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sDbWork)) 825*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sDbWork); 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir sTemp = sDbWork; 830*cdf0e10cSrcweir sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("config")); 831*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sTemp)) 832*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sTemp); 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir sTemp = sDbWork; 835*cdf0e10cSrcweir sTemp += sDBName; 836*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sTemp)) 837*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sTemp); 838*cdf0e10cSrcweir } 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir if(m_sDbConfig.getLength()) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir sDBConfig = m_sDbConfigURL; 843*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sDBConfig)) 844*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sDBConfig); 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir sDBConfig += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); 847*cdf0e10cSrcweir sTemp = sDBConfig; 848*cdf0e10cSrcweir sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("config")); 849*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sTemp)) 850*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sTemp); 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); 853*cdf0e10cSrcweir sTemp += sDBName; 854*cdf0e10cSrcweir if(UCBContentHelper::Exists(sTemp)) 855*cdf0e10cSrcweir UCBContentHelper::Kill(sTemp); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir #if !(defined(WNT)) 858*cdf0e10cSrcweir sTemp = sDBConfig; 859*cdf0e10cSrcweir sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diag")); 860*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sTemp)) 861*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sTemp); 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir sTemp = sDBConfig; 864*cdf0e10cSrcweir sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ipc")); 865*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sTemp)) 866*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sTemp); 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir sTemp = sDBConfig; 869*cdf0e10cSrcweir sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spool")); 870*cdf0e10cSrcweir if(!UCBContentHelper::IsFolder(sTemp)) 871*cdf0e10cSrcweir UCBContentHelper::MakeFolder(sTemp); 872*cdf0e10cSrcweir #endif 873*cdf0e10cSrcweir } 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 876*cdf0e10cSrcweir void ODriver::clearDatabase(const ::rtl::OUString& sDBName) 877*cdf0e10cSrcweir { // stop the database 878*cdf0e10cSrcweir ::rtl::OUString sCommand; 879*cdf0e10cSrcweir #if defined(WNT) 880*cdf0e10cSrcweir ::rtl::OUString sStop = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("stop")); 881*cdf0e10cSrcweir OArgumentList aArgs(2,&sDBName,&sStop); 882*cdf0e10cSrcweir sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_cons.exe")); 883*cdf0e10cSrcweir #else 884*cdf0e10cSrcweir OArgumentList aArgs(1,&sDBName); 885*cdf0e10cSrcweir sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_clear")); 886*cdf0e10cSrcweir #endif 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir OProcess aApp( sCommand,m_sDbWorkURL); 889*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 890*cdf0e10cSrcweir OProcess::TProcessError eError = 891*cdf0e10cSrcweir #endif 892*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption) OPROCESS_ADABAS, aArgs ); 893*cdf0e10cSrcweir OSL_ENSURE( eError == OProcess::E_None, "ODriver::clearDatabase: calling the executable failed!" ); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 896*cdf0e10cSrcweir void ODriver::createDb( const TDatabaseStruct& _aInfo) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir clearDatabase(_aInfo.sDBName); 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir X_PARAM(_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword,String::CreateFromAscii("BINIT")); 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir String sTemp; 904*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(_aInfo.sSysDevSpace,sTemp); 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSDEVSPACE")),sTemp); 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir sTemp.Erase(); 909*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(_aInfo.sTransLogName,sTemp); 910*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TRANSACTION_LOG")),sTemp); 911*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXUSERTASKS")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("3"))); 912*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDEVSPACES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("7"))); 913*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDATADEVSPACES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("5"))); 914*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDATAPAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("25599"))); 915*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXBACKUPDEVS")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"))); 916*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXSERVERDB")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"))); 917*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA_CACHE_PAGES")),_aInfo.sCacheSize); 918*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONV_CACHE_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("23"))); 919*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PROC_DATA_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("40"))); 920*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RUNDIRECTORY")),m_sDbRunDir); 921*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KERNELTRACESIZE")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("100"))); 922*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOG_QUEUE_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10"))); 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir #if !defined(WNT) 925*cdf0e10cSrcweir PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OPMSG1")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/dev/null"))); 926*cdf0e10cSrcweir #endif 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir X_PARAM(_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK"))); 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir X_START(_aInfo.sDBName); 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir // SHOW_STATE() 933*cdf0e10cSrcweir // %m_sDbRoot%\bin\xutil -d %_aInfo.sDBName% -u %CONUSR%,%CONPWD% -b %INITCMD% 934*cdf0e10cSrcweir ::rtl::OUString aBatch2 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-b ")); 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir // if(!bBsp && INITCMD.Len() >= 40) 937*cdf0e10cSrcweir // { 938*cdf0e10cSrcweir // DirEntry aTmp(INITCMD); 939*cdf0e10cSrcweir // aTmp.CopyTo(aInitFile, FSYS_ACTION_COPYFILE); 940*cdf0e10cSrcweir // INITCMD = aInitFile.GetFull(); 941*cdf0e10cSrcweir // } 942*cdf0e10cSrcweir // generate the init file for the database 943*cdf0e10cSrcweir String sInitFile = getDatabaseInitFile(_aInfo); 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(sInitFile,sTemp); 946*cdf0e10cSrcweir aBatch2 += sTemp; 947*cdf0e10cSrcweir XUTIL(aBatch2,_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword); 948*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 949*cdf0e10cSrcweir if(UCBContentHelper::Exists(sInitFile)) 950*cdf0e10cSrcweir UCBContentHelper::Kill(sInitFile); 951*cdf0e10cSrcweir #endif 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir // install system tables 954*cdf0e10cSrcweir installSystemTables(_aInfo); 955*cdf0e10cSrcweir // now we have to make our SYSDBA user "NOT EXCLUSIVE" 956*cdf0e10cSrcweir { 957*cdf0e10cSrcweir String sExt; 958*cdf0e10cSrcweir sExt.AssignAscii(".sql"); 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 961*cdf0e10cSrcweir ::utl::TempFile aInitFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl); 962*cdf0e10cSrcweir aInitFile.EnableKillingFile(); 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(aInitFile.GetURL(),STREAM_WRITE) ); 965*cdf0e10cSrcweir (*pFileStream) << "ALTER USER \"" 966*cdf0e10cSrcweir << ::rtl::OString(_aInfo.sSysUser,_aInfo.sSysUser.getLength(),gsl_getSystemTextEncoding()) 967*cdf0e10cSrcweir << "\" NOT EXCLUSIVE " 968*cdf0e10cSrcweir << sNewLine; 969*cdf0e10cSrcweir pFileStream->Flush(); 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir { // just to get sure that the tempfile still lives 972*cdf0e10cSrcweir sTemp.Erase(); 973*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(aInitFile.GetURL(),sTemp); 974*cdf0e10cSrcweir LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp); 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir } 978*cdf0e10cSrcweir 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------- 981*cdf0e10cSrcweir int ODriver::X_PARAM(const ::rtl::OUString& _DBNAME, 982*cdf0e10cSrcweir const ::rtl::OUString& _USR, 983*cdf0e10cSrcweir const ::rtl::OUString& _PWD, 984*cdf0e10cSrcweir const ::rtl::OUString& _CMD) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir // %XPARAM% -u %CONUSR%,%CONPWD% BINIT 987*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 988*cdf0e10cSrcweir { 989*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 990*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 991*cdf0e10cSrcweir (*pFileStream) << "x_param" 992*cdf0e10cSrcweir #if defined(WNT) 993*cdf0e10cSrcweir << ".exe" 994*cdf0e10cSrcweir #endif 995*cdf0e10cSrcweir << " -d " 996*cdf0e10cSrcweir << ::rtl::OString(_DBNAME,_DBNAME.getLength(),gsl_getSystemTextEncoding()) 997*cdf0e10cSrcweir << " -u " 998*cdf0e10cSrcweir << ::rtl::OString(_USR,_USR.getLength(),gsl_getSystemTextEncoding()) 999*cdf0e10cSrcweir << "," 1000*cdf0e10cSrcweir << ::rtl::OString(_PWD,_PWD.getLength(),gsl_getSystemTextEncoding()) 1001*cdf0e10cSrcweir << " " 1002*cdf0e10cSrcweir << ::rtl::OString(_CMD,_CMD.getLength(),gsl_getSystemTextEncoding()) 1003*cdf0e10cSrcweir #if defined(WNT) 1004*cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL) 1005*cdf0e10cSrcweir << " >> %DBWORK%\\create.log 2>&1" 1006*cdf0e10cSrcweir #endif 1007*cdf0e10cSrcweir #else 1008*cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL) 1009*cdf0e10cSrcweir << " >> /tmp/kstart.log" 1010*cdf0e10cSrcweir #else 1011*cdf0e10cSrcweir << " > /dev/null" 1012*cdf0e10cSrcweir #endif 1013*cdf0e10cSrcweir #endif 1014*cdf0e10cSrcweir << " " 1015*cdf0e10cSrcweir << sNewLine 1016*cdf0e10cSrcweir << sNewLine; 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir pFileStream->Flush(); 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1022*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 1023*cdf0e10cSrcweir OProcess::TProcessError eError = 1024*cdf0e10cSrcweir #endif 1025*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait)); 1026*cdf0e10cSrcweir OSL_ENSURE( eError == OProcess::E_None, "ODriver::X_PARAM: calling the executable failed!" ); 1027*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1028*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1029*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1030*cdf0e10cSrcweir #endif 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir return 0; 1033*cdf0e10cSrcweir } 1034*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1035*cdf0e10cSrcweir sal_Int32 ODriver::CreateFiles(const TDatabaseStruct& _aInfo) 1036*cdf0e10cSrcweir { 1037*cdf0e10cSrcweir int nRet = CreateFile(_aInfo.sSysDevSpace,_aInfo.nDataSize/50) ? 0 : -9; 1038*cdf0e10cSrcweir if(!nRet) 1039*cdf0e10cSrcweir nRet = CreateFile(_aInfo.sTransLogName,_aInfo.nLogSize) ? 0 : -10; 1040*cdf0e10cSrcweir if(!nRet) 1041*cdf0e10cSrcweir nRet = CreateFile(_aInfo.sDataDevName,_aInfo.nDataSize) ? 0 : -11; 1042*cdf0e10cSrcweir 1043*cdf0e10cSrcweir return nRet; 1044*cdf0e10cSrcweir 1045*cdf0e10cSrcweir } 1046*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1047*cdf0e10cSrcweir void ODriver::PutParam(const ::rtl::OUString& sDBName, 1048*cdf0e10cSrcweir const ::rtl::OUString& rWhat, 1049*cdf0e10cSrcweir const ::rtl::OUString& rHow) 1050*cdf0e10cSrcweir { 1051*cdf0e10cSrcweir OArgumentList aArgs(3,&sDBName,&rWhat,&rHow); 1052*cdf0e10cSrcweir ::rtl::OUString sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("putparam")); 1053*cdf0e10cSrcweir #if defined(WNT) 1054*cdf0e10cSrcweir sCommand += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".exe")); 1055*cdf0e10cSrcweir #endif 1056*cdf0e10cSrcweir 1057*cdf0e10cSrcweir OProcess aApp(sCommand,m_sDbWorkURL); 1058*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 1059*cdf0e10cSrcweir OProcess::TProcessError eError = 1060*cdf0e10cSrcweir #endif 1061*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS,aArgs ); 1062*cdf0e10cSrcweir OSL_ENSURE( eError == OProcess::E_None, "ODriver::PutParam: calling the executable failed!" ); 1063*cdf0e10cSrcweir } 1064*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1065*cdf0e10cSrcweir sal_Bool ODriver::CreateFile(const ::rtl::OUString &_FileName, 1066*cdf0e10cSrcweir sal_Int32 _nSize) 1067*cdf0e10cSrcweir { 1068*cdf0e10cSrcweir OSL_TRACE("CreateFile %d",_nSize); 1069*cdf0e10cSrcweir sal_Bool bOK = sal_True; 1070*cdf0e10cSrcweir try 1071*cdf0e10cSrcweir { 1072*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(_FileName,STREAM_WRITE)); 1073*cdf0e10cSrcweir if( !pFileStream.get()) 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 1076*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( 1077*cdf0e10cSrcweir STR_NO_DISK_SPACE, 1078*cdf0e10cSrcweir "$filename$",_FileName 1079*cdf0e10cSrcweir ) ); 1080*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sError,*this); 1081*cdf0e10cSrcweir } 1082*cdf0e10cSrcweir (*pFileStream).SetFiller('\0'); 1083*cdf0e10cSrcweir sal_Int32 nNewSize = 0; 1084*cdf0e10cSrcweir sal_Int32 nCount = _nSize /2; 1085*cdf0e10cSrcweir for(sal_Int32 i=0; bOK && i < nCount; ++i) 1086*cdf0e10cSrcweir { 1087*cdf0e10cSrcweir nNewSize += 8192;//4096; 1088*cdf0e10cSrcweir bOK = (*pFileStream).SetStreamSize(nNewSize); 1089*cdf0e10cSrcweir pFileStream->Flush(); 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir 1092*cdf0e10cSrcweir bOK = bOK && static_cast<sal_Int32>(pFileStream->Seek(STREAM_SEEK_TO_END)) == nNewSize; 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir catch(Exception&) 1095*cdf0e10cSrcweir { 1096*cdf0e10cSrcweir OSL_TRACE("Exception"); 1097*cdf0e10cSrcweir } 1098*cdf0e10cSrcweir if(!bOK) 1099*cdf0e10cSrcweir { 1100*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 1101*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( 1102*cdf0e10cSrcweir STR_NO_DISK_SPACE, 1103*cdf0e10cSrcweir "$filename$",_FileName 1104*cdf0e10cSrcweir ) ); 1105*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sError,*this); 1106*cdf0e10cSrcweir } 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir return bOK; 1109*cdf0e10cSrcweir // dd if=/dev/zero bs=4k of=$DEV_NAME count=$2 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1112*cdf0e10cSrcweir int ODriver::X_START(const ::rtl::OUString& sDBName) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir ::rtl::OUString sCommand; 1115*cdf0e10cSrcweir #if defined(WNT) 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir ::rtl::OUString sArg1 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-d")); 1118*cdf0e10cSrcweir ::rtl::OUString sArg3 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBService")); 1119*cdf0e10cSrcweir ::rtl::OUString sArg4 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBWindow")); 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir OArgumentList aArgs(4,&sArg1,&sDBName,&sArg3,&sArg4); 1122*cdf0e10cSrcweir sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("strt.exe")); 1123*cdf0e10cSrcweir #else 1124*cdf0e10cSrcweir OArgumentList aArgs(1,&sDBName); 1125*cdf0e10cSrcweir sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_start")); 1126*cdf0e10cSrcweir #endif 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir OProcess aApp( sCommand ,m_sDbWorkURL); 1129*cdf0e10cSrcweir OProcess::TProcessError eError = aApp.execute((OProcess::TProcessOption)OPROCESS_ADABAS,aArgs); 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir if(eError == OProcess::E_NotFound) 1132*cdf0e10cSrcweir { 1133*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 1134*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( 1135*cdf0e10cSrcweir STR_COMMAND_NOT_FOUND, 1136*cdf0e10cSrcweir "$databasename$",sDBName, 1137*cdf0e10cSrcweir "$progname$",sCommand 1138*cdf0e10cSrcweir ) ); 1139*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sError,*this); 1140*cdf0e10cSrcweir } 1141*cdf0e10cSrcweir OSL_ASSERT(eError == OProcess::E_None); 1142*cdf0e10cSrcweir 1143*cdf0e10cSrcweir OProcess::TProcessInfo aInfo; 1144*cdf0e10cSrcweir if(aApp.getInfo(OProcess::TData_ExitCode,&aInfo) == OProcess::E_None && aInfo.Code) 1145*cdf0e10cSrcweir return aInfo.Code; 1146*cdf0e10cSrcweir 1147*cdf0e10cSrcweir return 0; 1148*cdf0e10cSrcweir } 1149*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1150*cdf0e10cSrcweir int ODriver::X_STOP(const ::rtl::OUString& sDBName) 1151*cdf0e10cSrcweir { 1152*cdf0e10cSrcweir ::rtl::OUString sCommand; 1153*cdf0e10cSrcweir #if defined(WNT) 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir ::rtl::OUString sArg1 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-d")); 1156*cdf0e10cSrcweir ::rtl::OUString sArg2 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBService")); 1157*cdf0e10cSrcweir 1158*cdf0e10cSrcweir OArgumentList aArgs(3,&sArg1,&sDBName,&sArg2); 1159*cdf0e10cSrcweir sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("stp.exe")); 1160*cdf0e10cSrcweir #else 1161*cdf0e10cSrcweir OArgumentList aArgs(1,&sDBName); 1162*cdf0e10cSrcweir sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_stop")); 1163*cdf0e10cSrcweir #endif 1164*cdf0e10cSrcweir OProcess aApp( sCommand ,m_sDbWorkURL); 1165*cdf0e10cSrcweir 1166*cdf0e10cSrcweir OProcess::TProcessError eError = aApp.execute((OProcess::TProcessOption)OPROCESS_ADABAS,aArgs); 1167*cdf0e10cSrcweir 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir OSL_ASSERT(eError == OProcess::E_None); 1170*cdf0e10cSrcweir if(eError != OProcess::E_None) 1171*cdf0e10cSrcweir return 1; 1172*cdf0e10cSrcweir OProcess::TProcessInfo aInfo; 1173*cdf0e10cSrcweir if(aApp.getInfo(OProcess::TData_ExitCode,&aInfo) == OProcess::E_None && aInfo.Code) 1174*cdf0e10cSrcweir return aInfo.Code; 1175*cdf0e10cSrcweir 1176*cdf0e10cSrcweir return 0; 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1179*cdf0e10cSrcweir void ODriver::XUTIL(const ::rtl::OUString& _rParam, 1180*cdf0e10cSrcweir const ::rtl::OUString& _DBNAME, 1181*cdf0e10cSrcweir const ::rtl::OUString& _USRNAME, 1182*cdf0e10cSrcweir const ::rtl::OUString& _USRPWD) 1183*cdf0e10cSrcweir { 1184*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 1185*cdf0e10cSrcweir String sExt = String::CreateFromAscii(".log"); 1186*cdf0e10cSrcweir ::utl::TempFile aCmdFile(String::CreateFromAscii("xutil"),&sExt,&sWorkUrl); 1187*cdf0e10cSrcweir aCmdFile.EnableKillingFile(); 1188*cdf0e10cSrcweir 1189*cdf0e10cSrcweir String sPhysicalPath; 1190*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath); 1191*cdf0e10cSrcweir 1192*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir { 1195*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 1196*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 1197*cdf0e10cSrcweir (*pFileStream) << 1198*cdf0e10cSrcweir #if defined(WNT) 1199*cdf0e10cSrcweir "xutil.exe" 1200*cdf0e10cSrcweir #else 1201*cdf0e10cSrcweir "utility" 1202*cdf0e10cSrcweir #endif 1203*cdf0e10cSrcweir << " -u " 1204*cdf0e10cSrcweir << ::rtl::OString(_USRNAME,_USRNAME.getLength(),gsl_getSystemTextEncoding()) 1205*cdf0e10cSrcweir << "," 1206*cdf0e10cSrcweir << ::rtl::OString(_USRPWD,_USRPWD.getLength(),gsl_getSystemTextEncoding()) 1207*cdf0e10cSrcweir << " -d " 1208*cdf0e10cSrcweir << ::rtl::OString(_DBNAME,_DBNAME.getLength(),gsl_getSystemTextEncoding()) 1209*cdf0e10cSrcweir << " " 1210*cdf0e10cSrcweir << ::rtl::OString(_rParam,_rParam.getLength(),gsl_getSystemTextEncoding()) 1211*cdf0e10cSrcweir << " > " 1212*cdf0e10cSrcweir << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding()) 1213*cdf0e10cSrcweir << " 2>&1" 1214*cdf0e10cSrcweir << sNewLine; 1215*cdf0e10cSrcweir pFileStream->Flush(); 1216*cdf0e10cSrcweir } 1217*cdf0e10cSrcweir 1218*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1219*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 1220*cdf0e10cSrcweir OProcess::TProcessError eError = 1221*cdf0e10cSrcweir #endif 1222*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait)); 1223*cdf0e10cSrcweir OSL_ENSURE( eError == OProcess::E_None, "ODriver::XUTIL: calling the executable failed!" ); 1224*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1225*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1226*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1227*cdf0e10cSrcweir #endif 1228*cdf0e10cSrcweir } 1229*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1230*cdf0e10cSrcweir void ODriver::LoadBatch(const ::rtl::OUString& sDBName, 1231*cdf0e10cSrcweir const ::rtl::OUString& _rUSR, 1232*cdf0e10cSrcweir const ::rtl::OUString& _rPWD, 1233*cdf0e10cSrcweir const ::rtl::OUString& _rBatch) 1234*cdf0e10cSrcweir { 1235*cdf0e10cSrcweir OSL_ENSURE(_rBatch.getLength(),"No batch file given!"); 1236*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 1237*cdf0e10cSrcweir String sExt = String::CreateFromAscii(".log"); 1238*cdf0e10cSrcweir ::utl::TempFile aCmdFile(String::CreateFromAscii("LoadBatch"),&sExt,&sWorkUrl); 1239*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1240*cdf0e10cSrcweir aCmdFile.EnableKillingFile(); 1241*cdf0e10cSrcweir #endif 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir String sPhysicalPath; 1244*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath); 1245*cdf0e10cSrcweir 1246*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 1247*cdf0e10cSrcweir { 1248*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 1249*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 1250*cdf0e10cSrcweir (*pFileStream) << "xload" 1251*cdf0e10cSrcweir #if defined(WNT) 1252*cdf0e10cSrcweir << ".exe" 1253*cdf0e10cSrcweir #endif 1254*cdf0e10cSrcweir << " -d " 1255*cdf0e10cSrcweir << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding()) 1256*cdf0e10cSrcweir << " -u " 1257*cdf0e10cSrcweir << ::rtl::OString(_rUSR,_rUSR.getLength(),gsl_getSystemTextEncoding()) 1258*cdf0e10cSrcweir << "," 1259*cdf0e10cSrcweir << ::rtl::OString(_rPWD,_rPWD.getLength(),gsl_getSystemTextEncoding()); 1260*cdf0e10cSrcweir 1261*cdf0e10cSrcweir if ( !isKernelVersion(CURRENT_DB_VERSION) ) 1262*cdf0e10cSrcweir (*pFileStream) << " -S adabas -b "; 1263*cdf0e10cSrcweir else 1264*cdf0e10cSrcweir (*pFileStream) << " -S NATIVE -b "; 1265*cdf0e10cSrcweir 1266*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString(_rBatch,_rBatch.getLength(),gsl_getSystemTextEncoding()) 1267*cdf0e10cSrcweir << " > " 1268*cdf0e10cSrcweir << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding()) 1269*cdf0e10cSrcweir << " 2>&1" 1270*cdf0e10cSrcweir << sNewLine; 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir pFileStream->Flush(); 1273*cdf0e10cSrcweir } 1274*cdf0e10cSrcweir 1275*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1276*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 1277*cdf0e10cSrcweir OProcess::TProcessError eError = 1278*cdf0e10cSrcweir #endif 1279*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait)); 1280*cdf0e10cSrcweir OSL_ENSURE( eError == OProcess::E_None, "ODriver::LoadBatch: calling the executable failed!" ); 1281*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1282*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1283*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1284*cdf0e10cSrcweir #endif 1285*cdf0e10cSrcweir } 1286*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1287*cdf0e10cSrcweir void ODriver::fillEnvironmentVariables() 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir // read the environment vars 1290*cdf0e10cSrcweir struct env_data 1291*cdf0e10cSrcweir { 1292*cdf0e10cSrcweir const sal_Char* pAsciiEnvName; 1293*cdf0e10cSrcweir ::rtl::OUString* pValue; 1294*cdf0e10cSrcweir ::rtl::OUString* pValueURL; 1295*cdf0e10cSrcweir } EnvData[] = { 1296*cdf0e10cSrcweir { "DBWORK", &m_sDbWork, &m_sDbWorkURL }, 1297*cdf0e10cSrcweir { "DBCONFIG", &m_sDbConfig, &m_sDbConfigURL }, 1298*cdf0e10cSrcweir { "DBROOT", &m_sDbRoot, &m_sDbRootURL } 1299*cdf0e10cSrcweir }; 1300*cdf0e10cSrcweir 1301*cdf0e10cSrcweir for ( size_t i = 0; i < sizeof( EnvData ) / sizeof( EnvData[0] ); ++i ) 1302*cdf0e10cSrcweir { 1303*cdf0e10cSrcweir ::rtl::OUString sVarName = ::rtl::OUString::createFromAscii( EnvData[i].pAsciiEnvName ); 1304*cdf0e10cSrcweir ::rtl::OUString sEnvValue; 1305*cdf0e10cSrcweir if(osl_getEnvironment( sVarName.pData, &sEnvValue.pData ) == osl_Process_E_None ) 1306*cdf0e10cSrcweir { 1307*cdf0e10cSrcweir *EnvData[i].pValue = sEnvValue; 1308*cdf0e10cSrcweir String sURL; 1309*cdf0e10cSrcweir LocalFileHelper::ConvertPhysicalNameToURL( *EnvData[i].pValue, sURL ); 1310*cdf0e10cSrcweir *EnvData[i].pValueURL = sURL; 1311*cdf0e10cSrcweir } 1312*cdf0e10cSrcweir } 1313*cdf0e10cSrcweir 1314*cdf0e10cSrcweir m_sDelimit = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); 1315*cdf0e10cSrcweir } 1316*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1317*cdf0e10cSrcweir ::rtl::OUString ODriver::generateInitFile() const 1318*cdf0e10cSrcweir { 1319*cdf0e10cSrcweir String sExt; 1320*cdf0e10cSrcweir #if !defined(WNT) 1321*cdf0e10cSrcweir sExt = String::CreateFromAscii(".sh"); 1322*cdf0e10cSrcweir #else 1323*cdf0e10cSrcweir sExt = String::CreateFromAscii(".bat"); 1324*cdf0e10cSrcweir #endif 1325*cdf0e10cSrcweir 1326*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 1327*cdf0e10cSrcweir ::utl::TempFile aCmdFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl); 1328*cdf0e10cSrcweir #if !defined(WNT) 1329*cdf0e10cSrcweir String sPhysicalPath; 1330*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath); 1331*cdf0e10cSrcweir chmod(ByteString(sPhysicalPath,gsl_getSystemTextEncoding()).GetBuffer(),S_IRUSR|S_IWUSR|S_IXUSR); 1332*cdf0e10cSrcweir #endif 1333*cdf0e10cSrcweir 1334*cdf0e10cSrcweir #if !defined(WNT) 1335*cdf0e10cSrcweir SvStream* pFileStream = aCmdFile.GetStream(STREAM_WRITE); 1336*cdf0e10cSrcweir (*pFileStream) << "#!/bin/sh" 1337*cdf0e10cSrcweir << sNewLine 1338*cdf0e10cSrcweir << "cd \"$DBWORK\"" 1339*cdf0e10cSrcweir << sNewLine 1340*cdf0e10cSrcweir << sNewLine; 1341*cdf0e10cSrcweir pFileStream->Flush(); 1342*cdf0e10cSrcweir #endif 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir return aCmdFile.GetURL(); 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1347*cdf0e10cSrcweir ::rtl::OUString ODriver::getDatabaseInitFile( const TDatabaseStruct& _aDBInfo) 1348*cdf0e10cSrcweir { 1349*cdf0e10cSrcweir String sExt; 1350*cdf0e10cSrcweir sExt.AssignAscii(".ins"); 1351*cdf0e10cSrcweir 1352*cdf0e10cSrcweir 1353*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 1354*cdf0e10cSrcweir ::utl::TempFile aInitFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl); 1355*cdf0e10cSrcweir { 1356*cdf0e10cSrcweir SvStream* pFileStream = aInitFile.GetStream(STREAM_WRITE); 1357*cdf0e10cSrcweir (*pFileStream) << "* @(#)init.cmd 6.1.1 1994-11-10\n"; 1358*cdf0e10cSrcweir (*pFileStream) << "init config\n"; 1359*cdf0e10cSrcweir (*pFileStream) << "* default code:\n"; 1360*cdf0e10cSrcweir (*pFileStream) << "ascii\n"; 1361*cdf0e10cSrcweir (*pFileStream) << "* date time format\n"; 1362*cdf0e10cSrcweir (*pFileStream) << "internal\n"; 1363*cdf0e10cSrcweir (*pFileStream) << "* command timeout:\n"; 1364*cdf0e10cSrcweir (*pFileStream) << "900\n"; 1365*cdf0e10cSrcweir (*pFileStream) << "* lock timeout:\n"; 1366*cdf0e10cSrcweir (*pFileStream) << "360\n"; 1367*cdf0e10cSrcweir (*pFileStream) << "* request timeout:\n"; 1368*cdf0e10cSrcweir (*pFileStream) << "180\n"; 1369*cdf0e10cSrcweir (*pFileStream) << "* log mode:\n"; 1370*cdf0e10cSrcweir (*pFileStream) << "demo\n"; 1371*cdf0e10cSrcweir (*pFileStream) << "* log segment size:\n"; 1372*cdf0e10cSrcweir (*pFileStream) << "0\n"; 1373*cdf0e10cSrcweir (*pFileStream) << "* no of archive logs:\n"; 1374*cdf0e10cSrcweir (*pFileStream) << "0\n"; 1375*cdf0e10cSrcweir (*pFileStream) << "* no of data devspaces:\n"; 1376*cdf0e10cSrcweir (*pFileStream) << "1\n"; 1377*cdf0e10cSrcweir (*pFileStream) << "* mirror devspaces:\n"; 1378*cdf0e10cSrcweir (*pFileStream) << "n\n"; 1379*cdf0e10cSrcweir (*pFileStream) << "if $rc <> 0 then stop\n"; 1380*cdf0e10cSrcweir (*pFileStream) << "*--- device description ---\n"; 1381*cdf0e10cSrcweir (*pFileStream) << "* sys devspace name:\n"; 1382*cdf0e10cSrcweir { 1383*cdf0e10cSrcweir String sTemp; 1384*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sSysDevSpace,sTemp); 1385*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding()); 1386*cdf0e10cSrcweir } 1387*cdf0e10cSrcweir (*pFileStream) << "\n* log devspace size:\n"; 1388*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString::valueOf(_aDBInfo.nLogSize); 1389*cdf0e10cSrcweir (*pFileStream) << "\n* log devspace name:\n"; 1390*cdf0e10cSrcweir { 1391*cdf0e10cSrcweir String sTemp; 1392*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sTransLogName,sTemp); 1393*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding()); 1394*cdf0e10cSrcweir } 1395*cdf0e10cSrcweir (*pFileStream) << "\n* data devspace size:\n"; 1396*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString::valueOf(_aDBInfo.nDataSize); 1397*cdf0e10cSrcweir (*pFileStream) << "\n* data devspace name:\n"; 1398*cdf0e10cSrcweir { 1399*cdf0e10cSrcweir String sTemp; 1400*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sDataDevName,sTemp); 1401*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding()); 1402*cdf0e10cSrcweir } 1403*cdf0e10cSrcweir 1404*cdf0e10cSrcweir (*pFileStream) << "\n* END INIT CONFIG\n"; 1405*cdf0e10cSrcweir (*pFileStream) << "if $rc <> 0 then stop\n"; 1406*cdf0e10cSrcweir if(_aDBInfo.bRestoreDatabase) 1407*cdf0e10cSrcweir { 1408*cdf0e10cSrcweir (*pFileStream) << "RESTORE DATA QUICK FROM '"; 1409*cdf0e10cSrcweir { 1410*cdf0e10cSrcweir String sTemp; 1411*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sBackupFile,sTemp); 1412*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding()); 1413*cdf0e10cSrcweir } 1414*cdf0e10cSrcweir (*pFileStream) << "' BLOCKSIZE 8\n"; 1415*cdf0e10cSrcweir (*pFileStream) << "if $rc <> 0 then stop\n"; 1416*cdf0e10cSrcweir (*pFileStream) << "RESTART\n"; 1417*cdf0e10cSrcweir 1418*cdf0e10cSrcweir } 1419*cdf0e10cSrcweir else 1420*cdf0e10cSrcweir { 1421*cdf0e10cSrcweir (*pFileStream) << "ACTIVATE SERVERDB SYSDBA \""; 1422*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString(_aDBInfo.sSysUser,_aDBInfo.sSysUser.getLength(),gsl_getSystemTextEncoding()); 1423*cdf0e10cSrcweir (*pFileStream) << "\" PASSWORD \""; 1424*cdf0e10cSrcweir (*pFileStream) << ::rtl::OString(_aDBInfo.sSysPassword,_aDBInfo.sSysPassword.getLength(),gsl_getSystemTextEncoding()); 1425*cdf0e10cSrcweir (*pFileStream) << "\"\n"; 1426*cdf0e10cSrcweir } 1427*cdf0e10cSrcweir (*pFileStream) << "if $rc <> 0 then stop\n"; 1428*cdf0e10cSrcweir (*pFileStream) << "exit\n"; 1429*cdf0e10cSrcweir } 1430*cdf0e10cSrcweir return aInitFile.GetURL(); 1431*cdf0e10cSrcweir } 1432*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1433*cdf0e10cSrcweir void ODriver::X_CONS(const ::rtl::OUString& sDBName,const ::rtl::OString& _ACTION,const ::rtl::OUString& _FILENAME) 1434*cdf0e10cSrcweir { 1435*cdf0e10cSrcweir String sPhysicalPath; 1436*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(_FILENAME,sPhysicalPath); 1437*cdf0e10cSrcweir 1438*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 1439*cdf0e10cSrcweir { 1440*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 1441*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 1442*cdf0e10cSrcweir 1443*cdf0e10cSrcweir (*pFileStream) << "x_cons" 1444*cdf0e10cSrcweir #if defined(WNT) 1445*cdf0e10cSrcweir << ".exe" 1446*cdf0e10cSrcweir #endif 1447*cdf0e10cSrcweir << " " 1448*cdf0e10cSrcweir << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding()) 1449*cdf0e10cSrcweir << " SHOW " 1450*cdf0e10cSrcweir << _ACTION 1451*cdf0e10cSrcweir << " > " 1452*cdf0e10cSrcweir << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding()) 1453*cdf0e10cSrcweir << sNewLine; 1454*cdf0e10cSrcweir pFileStream->Flush(); 1455*cdf0e10cSrcweir } 1456*cdf0e10cSrcweir 1457*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1458*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait)); 1459*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1460*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1461*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1462*cdf0e10cSrcweir #endif 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1465*cdf0e10cSrcweir void ODriver::checkAndRestart(const ::rtl::OUString& sDBName,const TDatabaseStruct& _rDbInfo) 1466*cdf0e10cSrcweir { 1467*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 1468*cdf0e10cSrcweir String sExt = String::CreateFromAscii(".st"); 1469*cdf0e10cSrcweir ::utl::TempFile aCmdFile(String::CreateFromAscii("State"),&sExt,&sWorkUrl); 1470*cdf0e10cSrcweir aCmdFile.EnableKillingFile(); 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir X_CONS(sDBName,"STATE",aCmdFile.GetURL()); 1473*cdf0e10cSrcweir SvStream* pFileStream = aCmdFile.GetStream(STREAM_SHARE_DENYALL); 1474*cdf0e10cSrcweir if ( pFileStream ) 1475*cdf0e10cSrcweir { 1476*cdf0e10cSrcweir ByteString sStateLine; 1477*cdf0e10cSrcweir sal_Bool bRead = sal_True; 1478*cdf0e10cSrcweir sal_Int32 nStart = 2; 1479*cdf0e10cSrcweir while(bRead && !pFileStream->IsEof()) 1480*cdf0e10cSrcweir { 1481*cdf0e10cSrcweir String aLine; 1482*cdf0e10cSrcweir bRead = pFileStream->ReadLine(sStateLine); 1483*cdf0e10cSrcweir if(bRead) 1484*cdf0e10cSrcweir { 1485*cdf0e10cSrcweir if(sStateLine.Search("WARM") != STRING_NOTFOUND) 1486*cdf0e10cSrcweir { // nothing to do 1487*cdf0e10cSrcweir nStart = 0; 1488*cdf0e10cSrcweir break; 1489*cdf0e10cSrcweir } 1490*cdf0e10cSrcweir else if(sStateLine.Search("COLD") != STRING_NOTFOUND) 1491*cdf0e10cSrcweir { 1492*cdf0e10cSrcweir nStart = 1; 1493*cdf0e10cSrcweir break; 1494*cdf0e10cSrcweir } 1495*cdf0e10cSrcweir } 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir switch(nStart) 1498*cdf0e10cSrcweir { 1499*cdf0e10cSrcweir case 2: 1500*cdf0e10cSrcweir clearDatabase(sDBName); 1501*cdf0e10cSrcweir X_START(sDBName); 1502*cdf0e10cSrcweir // don't break here 1503*cdf0e10cSrcweir case 1: 1504*cdf0e10cSrcweir XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RESTART")),sDBName,_rDbInfo.sControlUser,_rDbInfo.sControlPassword); 1505*cdf0e10cSrcweir case 0: 1506*cdf0e10cSrcweir break; 1507*cdf0e10cSrcweir } 1508*cdf0e10cSrcweir } 1509*cdf0e10cSrcweir } 1510*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1511*cdf0e10cSrcweir sal_Bool ODriver::isVersion(const ::rtl::OUString& sDBName, const char* _pVersion) 1512*cdf0e10cSrcweir { 1513*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 1514*cdf0e10cSrcweir String sExt = String::CreateFromAscii(".st"); 1515*cdf0e10cSrcweir ::utl::TempFile aCmdFile(String::CreateFromAscii("DevSpaces"),&sExt,&sWorkUrl); 1516*cdf0e10cSrcweir aCmdFile.EnableKillingFile(); 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir String sPhysicalPath; 1519*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath); 1520*cdf0e10cSrcweir 1521*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 1522*cdf0e10cSrcweir { 1523*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 1524*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 1525*cdf0e10cSrcweir 1526*cdf0e10cSrcweir (*pFileStream) << "getparam" 1527*cdf0e10cSrcweir #if defined(WNT) 1528*cdf0e10cSrcweir << ".exe" 1529*cdf0e10cSrcweir #endif 1530*cdf0e10cSrcweir << " " 1531*cdf0e10cSrcweir << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding()) 1532*cdf0e10cSrcweir << " KERNELVERSION > " 1533*cdf0e10cSrcweir << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding()) 1534*cdf0e10cSrcweir << sNewLine; 1535*cdf0e10cSrcweir } 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1538*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS); 1539*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1540*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1541*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1542*cdf0e10cSrcweir #endif 1543*cdf0e10cSrcweir SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE); 1544*cdf0e10cSrcweir ByteString sStateLine; 1545*cdf0e10cSrcweir sal_Bool bRead = sal_True; 1546*cdf0e10cSrcweir sal_Bool bIsVersion = sal_False; 1547*cdf0e10cSrcweir while ( pFileStream && bRead && !pFileStream->IsEof() ) 1548*cdf0e10cSrcweir { 1549*cdf0e10cSrcweir bRead = pFileStream->ReadLine(sStateLine); 1550*cdf0e10cSrcweir if ( bRead ) 1551*cdf0e10cSrcweir { 1552*cdf0e10cSrcweir bIsVersion = sStateLine.GetToken(1,' ').Equals(_pVersion) != 0; 1553*cdf0e10cSrcweir break; 1554*cdf0e10cSrcweir } 1555*cdf0e10cSrcweir } 1556*cdf0e10cSrcweir return bIsVersion; 1557*cdf0e10cSrcweir } 1558*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1559*cdf0e10cSrcweir void ODriver::checkAndInsertNewDevSpace(const ::rtl::OUString& sDBName, 1560*cdf0e10cSrcweir const TDatabaseStruct& _rDBInfo) 1561*cdf0e10cSrcweir { 1562*cdf0e10cSrcweir // %DBROOT%\pgm\getparam %2 DATA_CACHE_PAGES > %3 1563*cdf0e10cSrcweir String sWorkUrl(m_sDbWorkURL); 1564*cdf0e10cSrcweir String sExt = String::CreateFromAscii(".st"); 1565*cdf0e10cSrcweir ::utl::TempFile aCmdFile(String::CreateFromAscii("DevSpaces"),&sExt,&sWorkUrl); 1566*cdf0e10cSrcweir aCmdFile.EnableKillingFile(); 1567*cdf0e10cSrcweir 1568*cdf0e10cSrcweir String sPhysicalPath; 1569*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath); 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 1572*cdf0e10cSrcweir { 1573*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 1574*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 1575*cdf0e10cSrcweir 1576*cdf0e10cSrcweir (*pFileStream) << "getparam" 1577*cdf0e10cSrcweir #if defined(WNT) 1578*cdf0e10cSrcweir << ".exe" 1579*cdf0e10cSrcweir #endif 1580*cdf0e10cSrcweir << " " 1581*cdf0e10cSrcweir << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding()) 1582*cdf0e10cSrcweir << " DATA_CACHE_PAGES > " 1583*cdf0e10cSrcweir << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding()) 1584*cdf0e10cSrcweir << sNewLine; 1585*cdf0e10cSrcweir } 1586*cdf0e10cSrcweir 1587*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1588*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS); 1589*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1590*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1591*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1592*cdf0e10cSrcweir #endif 1593*cdf0e10cSrcweir SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE); 1594*cdf0e10cSrcweir ByteString sStateLine; 1595*cdf0e10cSrcweir sal_Bool bRead = sal_True; 1596*cdf0e10cSrcweir sal_Int32 nDataPages = 0; 1597*cdf0e10cSrcweir while(pFileStream && bRead && !pFileStream->IsEof()) 1598*cdf0e10cSrcweir { 1599*cdf0e10cSrcweir bRead = pFileStream->ReadLine(sStateLine); 1600*cdf0e10cSrcweir if(bRead) 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir nDataPages = sStateLine.ToInt32(); 1603*cdf0e10cSrcweir if(nDataPages && nDataPages < 100) 1604*cdf0e10cSrcweir { 1605*cdf0e10cSrcweir // the space isn't big enough anymore so we increment it 1606*cdf0e10cSrcweir PutParam(sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA_CACHE_PAGES")),::rtl::OUString::valueOf(nDataPages)); 1607*cdf0e10cSrcweir X_PARAM(sDBName,_rDBInfo.sControlUser,_rDBInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK"))); 1608*cdf0e10cSrcweir } 1609*cdf0e10cSrcweir } 1610*cdf0e10cSrcweir } 1611*cdf0e10cSrcweir } 1612*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1613*cdf0e10cSrcweir sal_Bool ODriver::isKernelVersion(const char* _pVersion) 1614*cdf0e10cSrcweir { 1615*cdf0e10cSrcweir ::utl::TempFile aCmdFile(String::CreateFromAscii("KernelVersion")); 1616*cdf0e10cSrcweir aCmdFile.EnableKillingFile(); 1617*cdf0e10cSrcweir 1618*cdf0e10cSrcweir String sPhysicalPath; 1619*cdf0e10cSrcweir LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath); 1620*cdf0e10cSrcweir 1621*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 1622*cdf0e10cSrcweir { 1623*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 1624*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 1625*cdf0e10cSrcweir 1626*cdf0e10cSrcweir (*pFileStream) << "dbversion" 1627*cdf0e10cSrcweir << " > " 1628*cdf0e10cSrcweir << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding()) 1629*cdf0e10cSrcweir << sNewLine; 1630*cdf0e10cSrcweir } 1631*cdf0e10cSrcweir 1632*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1633*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS); 1634*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1635*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1636*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1637*cdf0e10cSrcweir #endif 1638*cdf0e10cSrcweir SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE); 1639*cdf0e10cSrcweir ByteString sStateLine; 1640*cdf0e10cSrcweir sal_Bool bRead = sal_True; 1641*cdf0e10cSrcweir sal_Bool bIsVersion = sal_True; 1642*cdf0e10cSrcweir while ( pFileStream && bRead && !pFileStream->IsEof() ) 1643*cdf0e10cSrcweir { 1644*cdf0e10cSrcweir bRead = pFileStream->ReadLine(sStateLine); 1645*cdf0e10cSrcweir if ( bRead ) 1646*cdf0e10cSrcweir { 1647*cdf0e10cSrcweir // convert a 11.02.00 to a 12.01.30 version 1648*cdf0e10cSrcweir bIsVersion = sStateLine.GetToken(0).Equals(_pVersion) != 0; 1649*cdf0e10cSrcweir break; 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir } 1652*cdf0e10cSrcweir return bIsVersion; 1653*cdf0e10cSrcweir } 1654*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1655*cdf0e10cSrcweir void ODriver::installSystemTables( const TDatabaseStruct& _aInfo) 1656*cdf0e10cSrcweir { 1657*cdf0e10cSrcweir #if defined(WNT) 1658*cdf0e10cSrcweir // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% -b %m_sDbRoot%\env\TERMCHAR.ind 1659*cdf0e10cSrcweir ::rtl::OUString aBatch = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-b ")); 1660*cdf0e10cSrcweir ::rtl::OUString sTemp2 = m_sDbRootURL + m_sDelimit 1661*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")) 1662*cdf0e10cSrcweir + m_sDelimit 1663*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TERMCHAR.ind")); 1664*cdf0e10cSrcweir String sTemp; 1665*cdf0e10cSrcweir sal_Bool bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp); 1666*cdf0e10cSrcweir aBatch += sTemp; 1667*cdf0e10cSrcweir 1668*cdf0e10cSrcweir XUTIL(aBatch,_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword); 1669*cdf0e10cSrcweir 1670*cdf0e10cSrcweir // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% DIAGNOSE TRIGGER OFF 1671*cdf0e10cSrcweir XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DIAGNOSE TRIGGER OFF")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword); 1672*cdf0e10cSrcweir // xload -d %_DBNAME% -u %_SYSDBA_USER%,%_SYSDBA_PWD% -S NATIVE -b %m_sDbRoot%\env\DBS.ins %_DOMAINPWD% 1673*cdf0e10cSrcweir { 1674*cdf0e10cSrcweir sTemp2 = m_sDbRootURL 1675*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")) 1676*cdf0e10cSrcweir + m_sDelimit 1677*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBS.ins")); 1678*cdf0e10cSrcweir sTemp.Erase(); 1679*cdf0e10cSrcweir bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp); 1680*cdf0e10cSrcweir OSL_ENSURE(bOk,"File could be converted into file system path!"); 1681*cdf0e10cSrcweir sTemp.AppendAscii(" "); 1682*cdf0e10cSrcweir sTemp += String(_aInfo.sDomainPassword); 1683*cdf0e10cSrcweir 1684*cdf0e10cSrcweir LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp); 1685*cdf0e10cSrcweir } 1686*cdf0e10cSrcweir // xload -d %_DBNAME% -u DOMAIN,%_DOMAINPWD% -S NATIVE -b %m_sDbRoot%\env\XDD.ins 1687*cdf0e10cSrcweir { 1688*cdf0e10cSrcweir sTemp2 = m_sDbRootURL 1689*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")) 1690*cdf0e10cSrcweir + m_sDelimit 1691*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("XDD.ins")); 1692*cdf0e10cSrcweir sTemp.Erase(); 1693*cdf0e10cSrcweir bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp); 1694*cdf0e10cSrcweir OSL_ENSURE(bOk,"File could be converted into file system path!"); 1695*cdf0e10cSrcweir 1696*cdf0e10cSrcweir LoadBatch(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOMAIN")),_aInfo.sDomainPassword,sTemp); 1697*cdf0e10cSrcweir } 1698*cdf0e10cSrcweir // xload -d %_DBNAME% -u %_SYSDBA_USER%,%_SYSDBA_PWD% -S NATIVE -b %m_sDbRoot%\env\QP.ins 1699*cdf0e10cSrcweir { 1700*cdf0e10cSrcweir sTemp2 = m_sDbRootURL 1701*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")) 1702*cdf0e10cSrcweir + m_sDelimit 1703*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QP.ins")); 1704*cdf0e10cSrcweir sTemp.Erase(); 1705*cdf0e10cSrcweir bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp); 1706*cdf0e10cSrcweir OSL_ENSURE(bOk,"File could be converted into file system path!"); 1707*cdf0e10cSrcweir LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp); 1708*cdf0e10cSrcweir } 1709*cdf0e10cSrcweir // xload -d %_DBNAME% -u DOMAIN,%_DOMAINPWD% -S NATIVE -b %m_sDbRoot%\env\SPROC.ins 1710*cdf0e10cSrcweir { 1711*cdf0e10cSrcweir sTemp2 = m_sDbRootURL 1712*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")) 1713*cdf0e10cSrcweir + m_sDelimit 1714*cdf0e10cSrcweir + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SPROC.ins")); 1715*cdf0e10cSrcweir sTemp.Erase(); 1716*cdf0e10cSrcweir bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp); 1717*cdf0e10cSrcweir OSL_ENSURE(bOk,"File could be converted into file system path!"); 1718*cdf0e10cSrcweir 1719*cdf0e10cSrcweir LoadBatch(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOMAIN")),_aInfo.sDomainPassword,sTemp); 1720*cdf0e10cSrcweir } 1721*cdf0e10cSrcweir 1722*cdf0e10cSrcweir // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% DIAGNOSE TRIGGER ON 1723*cdf0e10cSrcweir XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DIAGNOSE TRIGGER ON")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword); 1724*cdf0e10cSrcweir // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% SET NOLOG OFF 1725*cdf0e10cSrcweir XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET NOLOG OFF")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword); 1726*cdf0e10cSrcweir // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% SHUTDOWN QUICK 1727*cdf0e10cSrcweir XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN QUICK")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword); 1728*cdf0e10cSrcweir // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% RESTART 1729*cdf0e10cSrcweir XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RESTART")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword); 1730*cdf0e10cSrcweir 1731*cdf0e10cSrcweir #else // UNX 1732*cdf0e10cSrcweir String sCommandFile = generateInitFile(); 1733*cdf0e10cSrcweir { 1734*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE)); 1735*cdf0e10cSrcweir pFileStream->Seek(STREAM_SEEK_TO_END); 1736*cdf0e10cSrcweir (*pFileStream) << "x_dbinst" 1737*cdf0e10cSrcweir << " -d " 1738*cdf0e10cSrcweir << ::rtl::OString(_aInfo.sDBName,_aInfo.sDBName.getLength(),gsl_getSystemTextEncoding()) 1739*cdf0e10cSrcweir << " -u " 1740*cdf0e10cSrcweir << ::rtl::OString(_aInfo.sSysUser,_aInfo.sSysUser.getLength(),gsl_getSystemTextEncoding()) 1741*cdf0e10cSrcweir << "," 1742*cdf0e10cSrcweir << ::rtl::OString(_aInfo.sSysPassword,_aInfo.sSysPassword.getLength(),gsl_getSystemTextEncoding()) 1743*cdf0e10cSrcweir << " -w " 1744*cdf0e10cSrcweir << ::rtl::OString(_aInfo.sDomainPassword,_aInfo.sDomainPassword.getLength(),gsl_getSystemTextEncoding()) 1745*cdf0e10cSrcweir << " -b "; 1746*cdf0e10cSrcweir 1747*cdf0e10cSrcweir if ( isKernelVersion(ADABAS_KERNEL_11) ) 1748*cdf0e10cSrcweir (*pFileStream) << "-i all"; 1749*cdf0e10cSrcweir (*pFileStream) 1750*cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL) 1751*cdf0e10cSrcweir << " >> /tmp/kstart.log" 1752*cdf0e10cSrcweir #else 1753*cdf0e10cSrcweir << " > /dev/null" 1754*cdf0e10cSrcweir #endif 1755*cdf0e10cSrcweir << sNewLine 1756*cdf0e10cSrcweir << sNewLine; 1757*cdf0e10cSrcweir pFileStream->Flush(); 1758*cdf0e10cSrcweir } 1759*cdf0e10cSrcweir // now execute the command 1760*cdf0e10cSrcweir OProcess aApp(sCommandFile ,m_sDbWorkURL); 1761*cdf0e10cSrcweir aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait)); 1762*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL < 2 1763*cdf0e10cSrcweir if(UCBContentHelper::Exists(sCommandFile)) 1764*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1765*cdf0e10cSrcweir #endif 1766*cdf0e10cSrcweir 1767*cdf0e10cSrcweir #endif //WNT,UNX 1768*cdf0e10cSrcweir } 1769*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1770*cdf0e10cSrcweir void ODriver::convertOldVersion(const ::rtl::OUString& sDBName,const TDatabaseStruct& _rDbInfo) 1771*cdf0e10cSrcweir { 1772*cdf0e10cSrcweir // first we have to check if this databse is a old version and we have to update the system tables 1773*cdf0e10cSrcweir if ( !isVersion(sDBName,CURRENT_DB_VERSION) && isKernelVersion(CURRENT_DB_VERSION) ) 1774*cdf0e10cSrcweir { 1775*cdf0e10cSrcweir if ( !_rDbInfo.sControlUser.getLength() 1776*cdf0e10cSrcweir || !_rDbInfo.sControlPassword.getLength()) 1777*cdf0e10cSrcweir { 1778*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 1779*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceString(STR_DATABASE_NEEDS_CONVERTING) ); 1780*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sError,*this); 1781*cdf0e10cSrcweir } 1782*cdf0e10cSrcweir String sCommandFile = m_sDbWorkURL; 1783*cdf0e10cSrcweir sCommandFile += String::CreateFromAscii("/xparam.prt"); 1784*cdf0e10cSrcweir if ( UCBContentHelper::Exists(sCommandFile) ) 1785*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1786*cdf0e10cSrcweir X_PARAM(sDBName,_rDbInfo.sControlUser,_rDbInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK"))); 1787*cdf0e10cSrcweir 1788*cdf0e10cSrcweir if ( UCBContentHelper::Exists(sCommandFile) ) 1789*cdf0e10cSrcweir { 1790*cdf0e10cSrcweir { 1791*cdf0e10cSrcweir ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READ) ); 1792*cdf0e10cSrcweir ByteString sStateLine; 1793*cdf0e10cSrcweir sal_Bool bRead = sal_True; 1794*cdf0e10cSrcweir static ByteString s_ErrorId("-21100"); 1795*cdf0e10cSrcweir while ( pFileStream.get() && bRead && !pFileStream->IsEof() ) 1796*cdf0e10cSrcweir { 1797*cdf0e10cSrcweir bRead = pFileStream->ReadLine(sStateLine); 1798*cdf0e10cSrcweir if ( bRead && s_ErrorId == sStateLine.GetToken(0,' ') ) 1799*cdf0e10cSrcweir { 1800*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1801*cdf0e10cSrcweir ::rtl::OUString sError(::rtl::OUString::createFromAscii(sStateLine.GetBuffer())); 1802*cdf0e10cSrcweir throw SQLException(sError,*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")),1000,Any()); 1803*cdf0e10cSrcweir } 1804*cdf0e10cSrcweir } 1805*cdf0e10cSrcweir } 1806*cdf0e10cSrcweir 1807*cdf0e10cSrcweir UCBContentHelper::Kill(sCommandFile); 1808*cdf0e10cSrcweir } 1809*cdf0e10cSrcweir } 1810*cdf0e10cSrcweir } 1811*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1812*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1813*cdf0e10cSrcweir } // namespace adabas 1814*cdf0e10cSrcweir }// namespace connectivity 1815*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1816*cdf0e10cSrcweir 1817*cdf0e10cSrcweir 1818*cdf0e10cSrcweir 1819*cdf0e10cSrcweir 1820