summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/adabas
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/adabas')
-rw-r--r--connectivity/source/drivers/adabas/BCatalog.cxx171
-rw-r--r--connectivity/source/drivers/adabas/BColumns.cxx186
-rw-r--r--connectivity/source/drivers/adabas/BConnection.cxx277
-rw-r--r--connectivity/source/drivers/adabas/BDatabaseMetaData.cxx164
-rw-r--r--connectivity/source/drivers/adabas/BDriver.cxx1822
-rw-r--r--connectivity/source/drivers/adabas/BFunctions.cxx278
-rw-r--r--connectivity/source/drivers/adabas/BGroup.cxx97
-rw-r--r--connectivity/source/drivers/adabas/BGroups.cxx96
-rw-r--r--connectivity/source/drivers/adabas/BIndex.cxx109
-rw-r--r--connectivity/source/drivers/adabas/BIndexColumns.cxx127
-rw-r--r--connectivity/source/drivers/adabas/BIndexes.cxx195
-rw-r--r--connectivity/source/drivers/adabas/BKeys.cxx184
-rw-r--r--connectivity/source/drivers/adabas/BPreparedStatement.cxx79
-rw-r--r--connectivity/source/drivers/adabas/BResultSet.cxx226
-rw-r--r--connectivity/source/drivers/adabas/BResultSetMetaData.cxx90
-rw-r--r--connectivity/source/drivers/adabas/BStatement.cxx82
-rw-r--r--connectivity/source/drivers/adabas/BTable.cxx379
-rw-r--r--connectivity/source/drivers/adabas/BTables.cxx525
-rw-r--r--connectivity/source/drivers/adabas/BUser.cxx335
-rw-r--r--connectivity/source/drivers/adabas/BUsers.cxx131
-rw-r--r--connectivity/source/drivers/adabas/BViews.cxx197
-rw-r--r--connectivity/source/drivers/adabas/Bservices.cxx179
-rw-r--r--connectivity/source/drivers/adabas/adabas.map8
-rw-r--r--connectivity/source/drivers/adabas/adabas.mxp.map148
-rwxr-xr-xconnectivity/source/drivers/adabas/adabas.xcu128
-rw-r--r--connectivity/source/drivers/adabas/adabas.xml27
-rw-r--r--connectivity/source/drivers/adabas/exports.dxp3
-rw-r--r--connectivity/source/drivers/adabas/makefile.mk110
28 files changed, 6353 insertions, 0 deletions
diff --git a/connectivity/source/drivers/adabas/BCatalog.cxx b/connectivity/source/drivers/adabas/BCatalog.cxx
new file mode 100644
index 000000000000..d5204d7ee0f1
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BCatalog.cxx
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BCatalog.cxx,v $
+ * $Revision: 1.16 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BCatalog.hxx"
+#include "adabas/BConnection.hxx"
+#include "adabas/BGroups.hxx"
+#include "adabas/BUsers.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BViews.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <comphelper/types.hxx>
+
+
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -----------------------------------------------------------------------------
+OAdabasCatalog::OAdabasCatalog(SQLHANDLE _aConnectionHdl, OAdabasConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+ ,m_aConnectionHdl(_aConnectionHdl)
+{
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OAdabasCatalog::buildName(const Reference< XRow >& _xRow)
+{
+ ::rtl::OUString sName;
+ sName = _xRow->getString(2);
+ if ( sName.getLength() )
+ sName += OAdabasCatalog::getDot();
+ sName += _xRow->getString(3);
+
+
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void OAdabasCatalog::fillVector(const ::rtl::OUString& _sQuery,TStringVector& _rVector)
+{
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ OSL_ENSURE(xStmt.is(),"OAdabasCatalog::fillVector: Could not create a statement!");
+ Reference< XResultSet > xResult = xStmt->executeQuery(_sQuery);
+
+ fillNames(xResult,_rVector);
+ ::comphelper::disposeComponent(xStmt);
+
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshTables()
+{
+ TStringVector aVector;
+ {
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"));
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ aTypes);
+ fillNames(xResult,aVector);
+ }
+
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshViews()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sView(RTL_CONSTASCII_USTRINGPARAM("SELECT DISTINCT NULL,DOMAIN.VIEWDEFS.OWNER, DOMAIN.VIEWDEFS.VIEWNAME FROM DOMAIN.VIEWDEFS"));
+ fillVector(s_sView,aVector);
+
+ if(m_pViews)
+ m_pViews->reFill(aVector);
+ else
+ m_pViews = new OViews(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshGroups()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sGroup(RTL_CONSTASCII_USTRINGPARAM("SELECT DISTINCT NULL,NULL,GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' '"));
+ fillVector(s_sGroup,aVector);
+ if(m_pGroups)
+ m_pGroups->reFill(aVector);
+ else
+ m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshUsers()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sUsers(RTL_CONSTASCII_USTRINGPARAM("SELECT DISTINCT NULL,NULL,USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL'"));
+ fillVector(s_sUsers,aVector);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+const ::rtl::OUString& OAdabasCatalog::getDot()
+{
+ static const ::rtl::OUString sDot(RTL_CONSTASCII_USTRINGPARAM("."));
+ return sDot;
+}
+// -----------------------------------------------------------------------------
+void OAdabasCatalog::correctColumnProperties(sal_Int32 /*_nPrec*/, sal_Int32& _rnType,::rtl::OUString& _rsTypeName)
+{
+ switch(_rnType)
+ {
+ case DataType::DECIMAL:
+ {
+ static const ::rtl::OUString sDecimal(RTL_CONSTASCII_USTRINGPARAM("DECIMAL"));
+ if(_rnType == DataType::DECIMAL && _rsTypeName == sDecimal)
+ _rnType = DataType::NUMERIC;
+ }
+ break;
+ case DataType::FLOAT:
+ // if(_nPrec >= 16)
+ {
+ static const ::rtl::OUString sDouble(RTL_CONSTASCII_USTRINGPARAM("DOUBLE PRECISION"));
+ _rsTypeName = sDouble;
+ _rnType = DataType::DOUBLE;
+ }
+// else if(_nPrec > 15)
+// {
+// static const ::rtl::OUString sReal = ::rtl::OUString::createFromAscii("REAL");
+// _rsTypeName = sReal;
+// _rnType = DataType::REAL;
+// }
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BColumns.cxx b/connectivity/source/drivers/adabas/BColumns.cxx
new file mode 100644
index 000000000000..b24c6e60397d
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BColumns.cxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BColumns.cxx,v $
+ * $Revision: 1.22 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "adabas/BTable.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BCatalog.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include <comphelper/property.hxx>
+
+using namespace ::comphelper;
+
+
+using namespace connectivity::adabas;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getColumns(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),_rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sal_Int32 nType = xRow->getInt(5);
+ ::rtl::OUString sTypeName = xRow->getString(6);
+ sal_Int32 nPrec = xRow->getInt(7);
+ OAdabasCatalog::correctColumnProperties(nPrec,nType,sTypeName);
+ sal_Bool bAutoIncrement = sal_False;
+ if ( !_rName.equalsAscii("DEFAULT") && !m_pTable->getSchema().equalsAscii("DOMAIN") && !m_pTable->getTableName().equalsAscii("COLUMNS") )
+ {
+ Reference< XStatement > xStmt = m_pTable->getMetaData()->getConnection()->createStatement( );
+ ::rtl::OUString sQuery(RTL_CONSTASCII_USTRINGPARAM("SELECT \"DEFAULT\" FROM DOMAIN.COLUMNS WHERE OWNER = '"));
+ sQuery += m_pTable->getSchema();
+ sQuery += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("' AND TABLENAME = '"));
+ sQuery += m_pTable->getTableName() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("' AND COLUMNNAME = '"));
+ sQuery += _rName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("'"));
+ try
+ {
+ Reference< XResultSet > xResult2 = xStmt->executeQuery(sQuery);
+ Reference< XRow > xRow2(xResult2,UNO_QUERY);
+ if ( xRow2.is() && xResult2->next() )
+ bAutoIncrement = xRow2->getString(1) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DEFAULT STAMP"));
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+
+ xRet = new OColumn(_rName,
+ sTypeName,
+ xRow->getString(13),
+ xRow->getInt(11),
+ nPrec,
+ xRow->getInt(9),
+ nType,
+ bAutoIncrement,sal_False,sal_False,sal_True);
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OColumns::createDescriptor()
+{
+ return new OColumn(sal_True);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OColumns::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ if ( m_pTable->isNew() )
+ return cloneDescriptor( descriptor );
+
+ ::rtl::OUString aSql(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
+ ::rtl::OUString sQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ m_pTable->beginTransAction();
+ try
+ {
+ aSql += ::dbtools::quoteName(sQuote,m_pTable->getSchema()) + sDot + ::dbtools::quoteName(sQuote,m_pTable->getTableName());
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ADD ("));
+ aSql += ::dbtools::quoteName(sQuote,_rForName);
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+ aSql += OTables::getColumnSqlType(descriptor);
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" )"));
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement();
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ m_pTable->alterNotNullValue(getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))),_rForName);
+ }
+ catch(const Exception&)
+ {
+ m_pTable->rollbackTransAction();
+ throw;
+ }
+ m_pTable->endTransAction();
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OColumns::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ OSL_ENSURE(m_pTable,"OColumns::dropByName: Table is null!");
+ if(!m_pTable->isNew())
+ {
+ ::rtl::OUString aSql(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
+ ::rtl::OUString sQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ aSql += ::dbtools::quoteName(sQuote,m_pTable->getSchema()) + sDot + ::dbtools::quoteName(sQuote,m_pTable->getTableName());
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP "));
+ aSql += ::dbtools::quoteName(sQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BConnection.cxx b/connectivity/source/drivers/adabas/BConnection.cxx
new file mode 100644
index 000000000000..11add583ea4a
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BConnection.cxx
@@ -0,0 +1,277 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BConnection.cxx,v $
+ * $Revision: 1.27 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include "adabas/BConnection.hxx"
+#include "adabas/BDriver.hxx"
+#include "adabas/BCatalog.hxx"
+#include "odbc/OFunctions.hxx"
+#include "odbc/OTools.hxx"
+#ifndef _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_
+#include "adabas/BDatabaseMetaData.hxx"
+#endif
+#include "adabas/BStatement.hxx"
+#include "adabas/BPreparedStatement.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <connectivity/dbcharset.hxx>
+#include "connectivity/sqliterator.hxx"
+#include <connectivity/sqlparse.hxx>
+
+#include <string.h>
+
+using namespace connectivity::adabas;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+
+//------------------------------------------------------------------------------
+namespace starlang = ::com::sun::star::lang;
+// --------------------------------------------------------------------------------
+OAdabasConnection::OAdabasConnection(const SQLHANDLE _pDriverHandle, connectivity::odbc::ODBCDriver* _pDriver)
+ : OConnection_BASE2(_pDriverHandle,_pDriver)
+{
+ m_bUseOldDateFormat = sal_True;
+}
+//-----------------------------------------------------------------------------
+SQLRETURN OAdabasConnection::Construct( const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_aConnectionHandle = SQL_NULL_HANDLE;
+ setURL(url);
+ setConnectionInfo(info);
+
+ // Connection allozieren
+ N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle);
+ if(m_aConnectionHandle == SQL_NULL_HANDLE)
+ throw SQLException();
+
+ const PropertyValue *pBegin = info.getConstArray();
+ const PropertyValue *pEnd = pBegin + info.getLength();
+ ::rtl::OUString sHostName;
+
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
+ sal_Int32 nTimeout = 20;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if ( !pBegin->Name.compareToAscii("Timeout") )
+ pBegin->Value >>= nTimeout;
+ else if(!pBegin->Name.compareToAscii("user"))
+ pBegin->Value >>= aUID;
+ else if(!pBegin->Name.compareToAscii("password"))
+ pBegin->Value >>= aPWD;
+ else if(!pBegin->Name.compareToAscii("HostName"))
+ pBegin->Value >>= sHostName;
+ else if(0 == pBegin->Name.compareToAscii("CharSet"))
+ {
+ ::rtl::OUString sIanaName;
+ OSL_VERIFY( pBegin->Value >>= sIanaName );
+
+ ::dbtools::OCharsetMap aLookupIanaName;
+ ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA());
+ if (aLookup != aLookupIanaName.end())
+ m_nTextEncoding = (*aLookup).getEncoding();
+ else
+ m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
+ if(m_nTextEncoding == RTL_TEXTENCODING_DONTKNOW)
+ m_nTextEncoding = osl_getThreadTextEncoding();
+ }
+ }
+ m_sUser = aUID;
+
+ if ( sHostName.getLength() )
+ aDSN = sHostName + ':' + aDSN;
+ SQLRETURN nSQLRETURN = openConnectionWithAuth(aDSN,nTimeout, aUID,aPWD);
+
+ return nSQLRETURN;
+}
+//-----------------------------------------------------------------------------
+SQLRETURN OAdabasConnection::openConnectionWithAuth(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, const ::rtl::OUString& _uid,const ::rtl::OUString& _pwd)
+{
+ if (m_aConnectionHandle == SQL_NULL_HANDLE)
+ return -1;
+
+ SQLRETURN nSQLRETURN = 0;
+ SDB_ODBC_CHAR szDSN[4096];
+ SDB_ODBC_CHAR szUID[20];
+ SDB_ODBC_CHAR szPWD[20];
+
+ memset(szDSN,'\0',4096);
+ memset(szUID,'\0',20);
+ memset(szPWD,'\0',20);
+
+ ::rtl::OString aConStr(::rtl::OUStringToOString(aConnectStr,getTextEncoding()));
+ ::rtl::OString aUID(::rtl::OUStringToOString(_uid,getTextEncoding()));
+ ::rtl::OString aPWD(::rtl::OUStringToOString(_pwd,getTextEncoding()));
+ memcpy(szDSN, (SDB_ODBC_CHAR*) aConStr.getStr(), ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()));
+ memcpy(szUID, (SDB_ODBC_CHAR*) aUID.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength()));
+ memcpy(szPWD, (SDB_ODBC_CHAR*) aPWD.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength()));
+
+
+
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,(SQLPOINTER)nTimeOut,SQL_IS_INTEGER);
+ // Verbindung aufbauen
+
+ nSQLRETURN = N3SQLConnect(m_aConnectionHandle,
+ szDSN,
+ (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()),
+ szUID,
+ (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength()),
+ szPWD,
+ (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength()));
+ if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
+ return nSQLRETURN;
+
+ m_bClosed = sal_False;
+
+ // autocoomit ist immer default
+
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER);
+
+ return nSQLRETURN;
+}
+
+//------------------------------------------------------------------------------
+void OAdabasConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ Reference< XTablesSupplier > xTableSupplier(m_xCatalog);
+ ::comphelper::disposeComponent(xTableSupplier);
+
+ m_xCatalog = WeakReference< XTablesSupplier >();
+
+ OConnection_BASE2::disposing();
+}
+//------------------------------------------------------------------------------
+Reference< XTablesSupplier > OAdabasConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ xTab = new OAdabasCatalog(m_aConnectionHandle,this);
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OAdabasConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OAdabasDatabaseMetaData(m_aConnectionHandle,this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OAdabasConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
+
+ Reference< XStatement > xReturn = new OAdabasStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OAdabasConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
+
+ Reference< XPreparedStatement > xReturn = new OAdabasPreparedStatement(this,sql);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL OAdabasConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OConnection_BASE2::getSomething(rId);
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdabasConnection::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -----------------------------------------------------------------------------
+::connectivity::odbc::OConnection* OAdabasConnection::cloneConnection()
+{
+ return new OAdabasConnection(m_pDriverHandleCopy,m_pDriver);
+}
+// -----------------------------------------------------------------------------
+::vos::ORef<OSQLColumns> OAdabasConnection::createSelectColumns(const ::rtl::OUString& _rSql)
+{
+ ::vos::ORef<OSQLColumns> aRet;
+ OSQLParser aParser(getDriver()->getORB());
+ ::rtl::OUString sErrorMessage;
+ OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_rSql);
+ if(pNode)
+ {
+ Reference< XTablesSupplier> xCata = createCatalog();
+ OSQLParseTreeIterator aParseIter(this, xCata->getTables(),
+ aParser, pNode);
+ aParseIter.traverseAll();
+ aRet = aParseIter.getSelectColumns();
+ }
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx
new file mode 100644
index 000000000000..a2dc2e2f4e22
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BDatabaseMetaData.cxx,v $
+ * $Revision: 1.14 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_BDATABASEMETADATA_HXX_
+#include "adabas/BDatabaseMetaData.hxx"
+#endif
+#include "FDatabaseMetaDataResultSet.hxx"
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+::rtl::OUString SAL_CALL OAdabasDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue(RTL_CONSTASCII_USTRINGPARAM("sdbc:adabas:"));
+ aValue += OAdabasDatabaseMetaData_BASE::getURLImpl();
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > OAdabasDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xNewRes = pResult;
+ static ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ aRows.reserve(19);
+ Reference< XResultSet > xRes = OAdabasDatabaseMetaData_BASE::impl_getTypeInfo_throw();
+
+ if(xRes.is())
+ {
+ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ Reference< XRow> xRow(xRes,UNO_QUERY);
+ while(xRes->next())
+ {
+ sal_Int32 nPos = 1;
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (1));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (2));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (3));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (4));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (5));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (6));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (7));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean (8));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort (9));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean (10));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (11));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean (12));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (13));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort (14));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort (15));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (16));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (17));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator((sal_Int16)xRow->getInt(18));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+
+ // we have to fix some incorrect entries
+ if(!aRow[2]->getValue().isNull())
+ {
+ switch((sal_Int32)aRow[2]->getValue())
+ {
+ case DataType::FLOAT:
+// aRow[3] = sal_Int32(15);
+// break;
+ case DataType::REAL:
+// aRow[3] = sal_Int32(16);
+// break;
+ case DataType::DOUBLE:
+ aRow[2]->setValue(DataType::DOUBLE);
+ aRow[3]->setValue(sal_Int32(18));
+ break;
+ case DataType::TIMESTAMP:
+ aRow[3]->setValue(sal_Int32(27));
+ break;
+ default:
+ break;
+ }
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ pResult->setRows(aRows);
+ return xNewRes;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx
new file mode 100644
index 000000000000..31dd0001fc11
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BDriver.cxx
@@ -0,0 +1,1822 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BDriver.cxx,v $
+ * $Revision: 1.24.56.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <unotools/tempfile.hxx>
+#include "adabas/BDriver.hxx"
+#include "adabas/BConnection.hxx"
+#include "odbc/OFunctions.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "odbc/OTools.hxx"
+#include "connectivity/dbexception.hxx"
+#include "TConnection.hxx"
+#include "diagnose_ex.h"
+#include <vos/process.hxx>
+#include <osl/process.h>
+#include <unotools/ucbhelper.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
+#include "resource/adabas_res.hrc"
+#include "resource/sharedresources.hxx"
+
+
+#include <memory>
+#include <sys/stat.h>
+
+#if defined(MAC)
+const char sNewLine = '\015';
+#elif defined(UNX)
+const char sNewLine = '\012';
+#else
+const char sNewLine[] = "\015\012"; // \015\012 and not \n
+#endif
+#define ADABAS_DB_11 "11.02.00"
+#define ADABAS_KERNEL_11 "11.02"
+#define ADABAS_DB_12 "12.01.00"
+#define ADABAS_KERNEL_12 "12.01"
+#define CURRENT_DB_VERSION "13.01.00"
+#define CURRENT_KERNEL_VERSION "13.01"
+
+#define OPROCESS_ADABAS (OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath)
+#define OPROCESS_ADABAS_DBG (OProcess::TOption_Wait | OProcess::TOption_SearchPath)
+
+
+using namespace connectivity;
+namespace connectivity
+{
+ namespace adabas
+ {
+ // extern declaration of the function pointer
+ extern T3SQLAllocHandle pODBC3SQLAllocHandle;
+ extern T3SQLConnect pODBC3SQLConnect;
+ extern T3SQLDriverConnect pODBC3SQLDriverConnect;
+ extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
+ extern T3SQLDataSources pODBC3SQLDataSources;
+ extern T3SQLDrivers pODBC3SQLDrivers;
+ extern T3SQLGetInfo pODBC3SQLGetInfo;
+ extern T3SQLGetFunctions pODBC3SQLGetFunctions;
+ extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
+ extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
+ extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
+ extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
+ extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
+ extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
+ extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
+ //extern T3SQLSetDescField pODBC3SQLSetDescField;
+ //extern T3SQLGetDescField pODBC3SQLGetDescField;
+ //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
+ //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
+ extern T3SQLPrepare pODBC3SQLPrepare;
+ extern T3SQLBindParameter pODBC3SQLBindParameter;
+ //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+ extern T3SQLSetCursorName pODBC3SQLSetCursorName;
+ extern T3SQLExecute pODBC3SQLExecute;
+ extern T3SQLExecDirect pODBC3SQLExecDirect;
+ //extern T3SQLNativeSql pODBC3SQLNativeSql;
+ extern T3SQLDescribeParam pODBC3SQLDescribeParam;
+ extern T3SQLNumParams pODBC3SQLNumParams;
+ extern T3SQLParamData pODBC3SQLParamData;
+ extern T3SQLPutData pODBC3SQLPutData;
+ extern T3SQLRowCount pODBC3SQLRowCount;
+ extern T3SQLNumResultCols pODBC3SQLNumResultCols;
+ extern T3SQLDescribeCol pODBC3SQLDescribeCol;
+ extern T3SQLColAttribute pODBC3SQLColAttribute;
+ extern T3SQLBindCol pODBC3SQLBindCol;
+ extern T3SQLFetch pODBC3SQLFetch;
+ extern T3SQLFetchScroll pODBC3SQLFetchScroll;
+ extern T3SQLGetData pODBC3SQLGetData;
+ extern T3SQLSetPos pODBC3SQLSetPos;
+ extern T3SQLBulkOperations pODBC3SQLBulkOperations;
+ extern T3SQLMoreResults pODBC3SQLMoreResults;
+ //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
+ extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
+ extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
+ extern T3SQLColumns pODBC3SQLColumns;
+ extern T3SQLForeignKeys pODBC3SQLForeignKeys;
+ extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
+ extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
+ extern T3SQLProcedures pODBC3SQLProcedures;
+ extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
+ extern T3SQLStatistics pODBC3SQLStatistics;
+ extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
+ extern T3SQLTables pODBC3SQLTables;
+ extern T3SQLFreeStmt pODBC3SQLFreeStmt;
+ extern T3SQLCloseCursor pODBC3SQLCloseCursor;
+ extern T3SQLCancel pODBC3SQLCancel;
+ extern T3SQLEndTran pODBC3SQLEndTran;
+ extern T3SQLDisconnect pODBC3SQLDisconnect;
+ extern T3SQLFreeHandle pODBC3SQLFreeHandle;
+ extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+ extern T3SQLNativeSql pODBC3SQLNativeSql;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace utl;
+using namespace osl;
+using namespace vos;
+using namespace ::dbtools;
+
+ sal_Bool LoadFunctions(oslModule pODBCso);
+ sal_Bool LoadLibrary_ADABAS(::rtl::OUString &_rPath);
+ // --------------------------------------------------------------------------------
+void ODriver::fillInfo(const Sequence< PropertyValue >& info, TDatabaseStruct& _rDBInfo)
+{
+ const PropertyValue* pIter = info.getConstArray();
+ const PropertyValue* pEnd = pIter + info.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseName"))))
+ {
+ pIter->Value >>= _rDBInfo.sDBName;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))))
+ {
+ pIter->Value >>= _rDBInfo.sControlUser;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))))
+ {
+ pIter->Value >>= _rDBInfo.sControlPassword;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))))
+ pIter->Value >>= _rDBInfo.nDataIncrement;
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))))
+ pIter->Value >>= _rDBInfo.bShutDown;
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("User"))))
+ {
+ pIter->Value >>= _rDBInfo.sSysUser;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Password"))))
+ {
+ pIter->Value >>= _rDBInfo.sSysPassword;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DomainPassword"))))
+ {
+ pIter->Value >>= _rDBInfo.sDomainPassword;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CacheSize"))))
+ {
+ pIter->Value >>= _rDBInfo.sCacheSize;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RestoreDatabase"))))
+ {
+ pIter->Value >>= _rDBInfo.bRestoreDatabase;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Backup"))))
+ {
+ pIter->Value >>= _rDBInfo.sBackupFile;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataDevSpace"))))
+ {
+ pIter->Value >>= _rDBInfo.sDataDevName;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSDEVSPACE"))))
+ {
+ pIter->Value >>= _rDBInfo.sSysDevSpace;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TRANSACTION_LOG"))))
+ {
+ pIter->Value >>= _rDBInfo.sTransLogName;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataDevSize"))))
+ {
+ pIter->Value >>= _rDBInfo.nDataSize;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LogDevSize"))))
+ {
+ pIter->Value >>= _rDBInfo.nLogSize;
+ }
+ }
+}
+
+
+// --------------------------------------------------------------------------------
+ODriver::ODriver(const Reference< XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory)
+{
+ osl_incrementInterlockedCount(&m_refCount);
+ fillEnvironmentVariables();
+ Reference< XComponent > xComponent(m_xORB, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
+ xComponent->addEventListener(xEvtL);
+ }
+ osl_decrementInterlockedCount(&m_refCount);
+}
+//------------------------------------------------------------------------------
+void ODriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ODriver_BASE::disposing();
+ Reference< XComponent > xComponent(m_xORB, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference< XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
+ xComponent->removeEventListener(xEvtL);
+ }
+ m_xORB.clear();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sdbcx.adabas.ODriver"));
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.Driver"));
+ aSNS[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbcx.Driver"));
+ return aSNS;
+}
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ const Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+//------------------------------------------------------------------
+Any SAL_CALL ODriver::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType, static_cast<XDataDefinitionSupplier*>(this));
+ if ( !aRet.hasValue() )
+ aRet = ODriver_BASE::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ODriver_BASE2::queryInterface(rType);
+}
+//------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODriver_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFac) throw( Exception )
+{
+ return *(new ODriver(_rxFac));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODriver::disposing( const EventObject& Source ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if(m_xORB.is() && Reference< XMultiServiceFactory >(Source.Source,UNO_QUERY) == m_xORB)
+ {
+ TDatabaseMap::iterator aIter = m_aDatabaseMap.begin();
+ for(;aIter != m_aDatabaseMap.end();++aIter)
+ {
+ if(aIter->second.bShutDown)
+ {
+ ::rtl::OUString sName;
+ if(getDBName(aIter->first,sName))
+ {
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN QUICK")),sName,aIter->second.sControlUser,aIter->second.sControlPassword);
+ X_STOP(sName);
+ }
+ }
+ }
+ m_xORB.clear();
+ }
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ TDatabaseStruct aDBInfo;
+ aDBInfo.bShutDown = sal_False;
+ fillInfo(info,aDBInfo);
+ aDBInfo.sControlUser = aDBInfo.sControlUser.toAsciiUpperCase();
+ aDBInfo.sControlPassword = aDBInfo.sControlPassword.toAsciiUpperCase();
+ aDBInfo.sSysUser = aDBInfo.sSysUser.toAsciiUpperCase();
+ aDBInfo.sSysPassword = aDBInfo.sSysPassword.toAsciiUpperCase();
+
+
+ TDatabaseMap::iterator aFind = m_aDatabaseMap.find(url);
+ if(aFind == m_aDatabaseMap.end()) // only when not found yet
+ m_aDatabaseMap[url] = aDBInfo;
+ else
+ {
+ if(aFind->second.bShutDown != aDBInfo.bShutDown)
+ aFind->second.bShutDown &= aDBInfo.bShutDown;
+ }
+
+ ::rtl::OUString sName;
+ if(aDBInfo.sControlPassword.getLength() && aDBInfo.sControlUser.getLength() && getDBName(url,sName))
+ {
+ // check if we have to add a new data dev space
+ checkAndInsertNewDevSpace(sName,aDBInfo);
+
+ convertOldVersion(sName,aDBInfo);
+ // check if we must restart the database
+ checkAndRestart(sName,aDBInfo);
+ }
+
+
+ if(!m_pDriverHandle)
+ {
+ ::rtl::OUString aPath;
+ if(!EnvironmentHandle(aPath))
+ throw SQLException(aPath,*this,::rtl::OUString(),1000,Any());
+ }
+ OAdabasConnection* pCon = new OAdabasConnection(m_pDriverHandle,this);
+ Reference< XConnection > xCon = pCon;
+ SQLRETURN nSQLRETURN = pCon->Construct(url,info);
+
+ if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
+ {
+ odbc::OTools::ThrowException(pCon,nSQLRETURN,pCon->getConnection(),SQL_HANDLE_DBC,*this);
+ }
+
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::getDBName(const ::rtl::OUString& _rName,::rtl::OUString& sDBName) const
+{
+ sDBName = ::rtl::OUString();
+ ::rtl::OUString sName = _rName.copy(12);
+ sal_Int32 nPos = sName.indexOf(':');
+ if(nPos != -1 && nPos < 1)
+ sDBName = sName.copy(1);
+ return (nPos != -1 && nPos < 1);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return (!url.compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:adabas:")),12));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/) throw(SQLException, RuntimeException)
+{
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Shut down service when closing."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control user name."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control password."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data increment (MB)."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
+ }
+
+ SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+// XCreateCatalog
+void SAL_CALL ODriver::createCatalog( const Sequence< PropertyValue >& info ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ try
+ {
+ TDatabaseStruct aDBInfo;
+ fillInfo(info,aDBInfo);
+ static char envName[] = "DBSERVICE=0";
+ putenv( envName );
+
+ m_sDbRunDir = m_sDbWorkURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/wrk/")) + aDBInfo.sDBName;
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(m_sDbRunDir,sTemp);
+ m_sDbRunDir = sTemp;
+
+ createNeededDirs(aDBInfo.sDBName);
+ if(CreateFiles(aDBInfo))
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_DISK_SPACE,
+ "$filename$",aDBInfo.sDBName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if(CreateFiles(aDBInfo))
+
+ createDb(aDBInfo);
+ }
+ catch( SQLException&)
+ {
+ throw;
+ }
+ catch(Exception&)
+ {
+ throw SQLException();
+ }
+
+}
+// -----------------------------------------------------------------------------
+// XDropCatalog
+void SAL_CALL ODriver::dropCatalog( const ::rtl::OUString& /*catalogName*/, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ ::dbtools::throwFeatureNotImplementedException( "!XDropCatalog::dropCatalog", *this );
+}
+//-----------------------------------------------------------------------------
+// ODBC Environment (gemeinsam fuer alle Connections):
+SQLHANDLE ODriver::EnvironmentHandle(::rtl::OUString &_rPath)
+{
+ // Ist (fuer diese Instanz) bereits ein Environment erzeugt worden?
+ if (!m_pDriverHandle)
+ {
+ SQLHANDLE h = SQL_NULL_HANDLE;
+ // Environment allozieren
+
+ // ODBC-DLL jetzt laden:
+ if (! LoadLibrary_ADABAS(_rPath))
+ return SQL_NULL_HANDLE;
+
+ if (N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
+ return SQL_NULL_HANDLE;
+
+ // In globaler Struktur merken ...
+ m_pDriverHandle = h;
+ SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);
+ OSL_UNUSED( nError );
+ //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
+ }
+
+ return m_pDriverHandle;
+}
+// --------------------------------------------------------------------------------
+// XDataDefinitionSupplier
+Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ Reference< XTablesSupplier > xTab;
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
+ if ( xTunnel.is() )
+ {
+
+ OAdabasConnection* pConnection = NULL;
+ OAdabasConnection* pSearchConnection = reinterpret_cast< OAdabasConnection* >( xTunnel->getSomething(OAdabasConnection::getUnoTunnelImplementationId()) );
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ if ( (OAdabasConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection )
+ {
+ pConnection = pSearchConnection;
+ break;
+ }
+ }
+
+
+ if ( pConnection )
+ xTab = pConnection->createCatalog();
+ }
+ return xTab;
+}
+
+// --------------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ if ( ! acceptsURL(url) )
+ {
+ SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( ! acceptsURL(url) )
+
+ return getDataDefinitionByConnection(connect(url,info));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODriver::acquire() throw()
+{
+ ODriver_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODriver::release() throw()
+{
+ ODriver_BASE::release();
+}
+ODriver::~ODriver()
+{
+}
+// -----------------------------------------------------------------------------
+oslGenericFunction ODriver::getOdbcFunction(sal_Int32 _nIndex) const
+{
+ oslGenericFunction pFunction = NULL;
+ switch(_nIndex)
+ {
+ case ODBC3SQLAllocHandle:
+ pFunction = (oslGenericFunction)pODBC3SQLAllocHandle;;
+ break;
+ case ODBC3SQLConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLConnect;
+ break;
+ case ODBC3SQLDriverConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLDriverConnect;
+ break;
+ case ODBC3SQLBrowseConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLBrowseConnect;
+ break;
+ case ODBC3SQLDataSources:
+ pFunction = (oslGenericFunction)pODBC3SQLDataSources;
+ break;
+ case ODBC3SQLDrivers:
+ pFunction = (oslGenericFunction)pODBC3SQLDrivers;
+ break;
+ case ODBC3SQLGetInfo:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetInfo;
+ break;
+ case ODBC3SQLGetFunctions:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetFunctions;
+ break;
+ case ODBC3SQLGetTypeInfo:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetTypeInfo;
+ break;
+ case ODBC3SQLSetConnectAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetConnectAttr;
+ break;
+ case ODBC3SQLGetConnectAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetConnectAttr;
+ break;
+ case ODBC3SQLSetEnvAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetEnvAttr;
+ break;
+ case ODBC3SQLGetEnvAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetEnvAttr;
+ break;
+ case ODBC3SQLSetStmtAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetStmtAttr;
+ break;
+ case ODBC3SQLGetStmtAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetStmtAttr;
+ break;
+ case ODBC3SQLPrepare:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPrepare;
+ break;
+ case ODBC3SQLBindParameter:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBindParameter;
+ break;
+ case ODBC3SQLSetCursorName:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetCursorName;
+ break;
+ case ODBC3SQLExecute:
+
+ pFunction = (oslGenericFunction)pODBC3SQLExecute;
+ break;
+ case ODBC3SQLExecDirect:
+
+ pFunction = (oslGenericFunction)pODBC3SQLExecDirect;
+ break;
+ case ODBC3SQLDescribeParam:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDescribeParam;
+ break;
+ case ODBC3SQLNumParams:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNumParams;
+ break;
+ case ODBC3SQLParamData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLParamData;
+ break;
+ case ODBC3SQLPutData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPutData;
+ break;
+ case ODBC3SQLRowCount:
+
+ pFunction = (oslGenericFunction)pODBC3SQLRowCount;
+ break;
+ case ODBC3SQLNumResultCols:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNumResultCols;
+ break;
+ case ODBC3SQLDescribeCol:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDescribeCol;
+ break;
+ case ODBC3SQLColAttribute:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColAttribute;
+ break;
+ case ODBC3SQLBindCol:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBindCol;
+ break;
+ case ODBC3SQLFetch:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFetch;
+ break;
+ case ODBC3SQLFetchScroll:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFetchScroll;
+ break;
+ case ODBC3SQLGetData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetData;
+ break;
+ case ODBC3SQLSetPos:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetPos;
+ break;
+ case ODBC3SQLBulkOperations:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBulkOperations;
+ break;
+ case ODBC3SQLMoreResults:
+
+ pFunction = (oslGenericFunction)pODBC3SQLMoreResults;
+ break;
+ case ODBC3SQLGetDiagRec:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetDiagRec;
+ break;
+ case ODBC3SQLColumnPrivileges:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColumnPrivileges;
+ break;
+ case ODBC3SQLColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColumns;
+ break;
+ case ODBC3SQLForeignKeys:
+
+ pFunction = (oslGenericFunction)pODBC3SQLForeignKeys;
+ break;
+ case ODBC3SQLPrimaryKeys:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPrimaryKeys;
+ break;
+ case ODBC3SQLProcedureColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLProcedureColumns;
+ break;
+ case ODBC3SQLProcedures:
+
+ pFunction = (oslGenericFunction)pODBC3SQLProcedures;
+ break;
+ case ODBC3SQLSpecialColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSpecialColumns;
+ break;
+ case ODBC3SQLStatistics:
+
+ pFunction = (oslGenericFunction)pODBC3SQLStatistics;
+ break;
+ case ODBC3SQLTablePrivileges:
+
+ pFunction = (oslGenericFunction)pODBC3SQLTablePrivileges;
+ break;
+ case ODBC3SQLTables:
+
+ pFunction = (oslGenericFunction)pODBC3SQLTables;
+ break;
+ case ODBC3SQLFreeStmt:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFreeStmt;
+ break;
+ case ODBC3SQLCloseCursor:
+
+ pFunction = (oslGenericFunction)pODBC3SQLCloseCursor;
+ break;
+ case ODBC3SQLCancel:
+
+ pFunction = (oslGenericFunction)pODBC3SQLCancel;
+ break;
+ case ODBC3SQLEndTran:
+
+ pFunction = (oslGenericFunction)pODBC3SQLEndTran;
+ break;
+ case ODBC3SQLDisconnect:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDisconnect;
+ break;
+ case ODBC3SQLFreeHandle:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFreeHandle;
+ break;
+ case ODBC3SQLGetCursorName:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetCursorName;
+ break;
+ case ODBC3SQLNativeSql:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNativeSql;
+ break;
+ default:
+ OSL_ENSURE(0,"Function unknown!");
+ }
+ return pFunction;
+}
+// -----------------------------------------------------------------------------
+void ODriver::createNeededDirs(const ::rtl::OUString& sDBName)
+{
+ ::rtl::OUString sDbWork,sDBConfig,sTemp;
+
+ if(m_sDbWork.getLength())
+ {
+ sDbWork = m_sDbWorkURL;
+ if(!UCBContentHelper::IsFolder(m_sDbWorkURL))
+ UCBContentHelper::MakeFolder(m_sDbWorkURL);
+
+ sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("wrk"));
+ if(!UCBContentHelper::IsFolder(sDbWork))
+ UCBContentHelper::MakeFolder(sDbWork);
+
+ sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+
+ sTemp = sDbWork;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("config"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp = sDbWork;
+ sTemp += sDBName;
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+ }
+
+ if(m_sDbConfig.getLength())
+ {
+ sDBConfig = m_sDbConfigURL;
+ if(!UCBContentHelper::IsFolder(sDBConfig))
+ UCBContentHelper::MakeFolder(sDBConfig);
+
+ sDBConfig += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("config"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ sTemp += sDBName;
+ if(UCBContentHelper::Exists(sTemp))
+ UCBContentHelper::Kill(sTemp);
+
+#if !(defined(WIN) || defined(WNT))
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diag"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ipc"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spool"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+#endif
+ }
+}
+// -----------------------------------------------------------------------------
+void ODriver::clearDatabase(const ::rtl::OUString& sDBName)
+{ // stop the database
+ ::rtl::OUString sCommand;
+#if defined(WIN) || defined(WNT)
+ ::rtl::OUString sStop = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("stop"));
+ OArgumentList aArgs(2,&sDBName,&sStop);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_cons.exe"));
+#else
+ OArgumentList aArgs(1,&sDBName);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_clear"));
+#endif
+
+ OProcess aApp( sCommand,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption) OPROCESS_ADABAS, aArgs );
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::clearDatabase: calling the executable failed!" );
+}
+// -----------------------------------------------------------------------------
+void ODriver::createDb( const TDatabaseStruct& _aInfo)
+{
+
+ clearDatabase(_aInfo.sDBName);
+
+ X_PARAM(_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword,String::CreateFromAscii("BINIT"));
+
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aInfo.sSysDevSpace,sTemp);
+
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSDEVSPACE")),sTemp);
+
+ sTemp.Erase();
+ LocalFileHelper::ConvertURLToPhysicalName(_aInfo.sTransLogName,sTemp);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TRANSACTION_LOG")),sTemp);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXUSERTASKS")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("3")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDEVSPACES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("7")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDATADEVSPACES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("5")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDATAPAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("25599")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXBACKUPDEVS")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXSERVERDB")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA_CACHE_PAGES")),_aInfo.sCacheSize);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONV_CACHE_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("23")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PROC_DATA_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("40")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RUNDIRECTORY")),m_sDbRunDir);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KERNELTRACESIZE")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("100")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOG_QUEUE_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10")));
+
+#if !(defined(WIN) || defined(WNT))
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OPMSG1")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/dev/null")));
+#endif
+
+ X_PARAM(_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK")));
+
+ X_START(_aInfo.sDBName);
+
+ // SHOW_STATE()
+ // %m_sDbRoot%\bin\xutil -d %_aInfo.sDBName% -u %CONUSR%,%CONPWD% -b %INITCMD%
+ ::rtl::OUString aBatch2 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-b "));
+
+// if(!bBsp && INITCMD.Len() >= 40)
+// {
+// DirEntry aTmp(INITCMD);
+// aTmp.CopyTo(aInitFile, FSYS_ACTION_COPYFILE);
+// INITCMD = aInitFile.GetFull();
+// }
+ // generate the init file for the database
+ String sInitFile = getDatabaseInitFile(_aInfo);
+
+ LocalFileHelper::ConvertURLToPhysicalName(sInitFile,sTemp);
+ aBatch2 += sTemp;
+ XUTIL(aBatch2,_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sInitFile))
+ UCBContentHelper::Kill(sInitFile);
+#endif
+
+ // install system tables
+ installSystemTables(_aInfo);
+ // now we have to make our SYSDBA user "NOT EXCLUSIVE"
+ {
+ String sExt;
+ sExt.AssignAscii(".sql");
+
+ String sWorkUrl(m_sDbWorkURL);
+ ::utl::TempFile aInitFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl);
+ aInitFile.EnableKillingFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(aInitFile.GetURL(),STREAM_WRITE) );
+ (*pFileStream) << "ALTER USER \""
+ << ::rtl::OString(_aInfo.sSysUser,_aInfo.sSysUser.getLength(),gsl_getSystemTextEncoding())
+ << "\" NOT EXCLUSIVE "
+ << sNewLine;
+ pFileStream->Flush();
+ }
+ { // just to get sure that the tempfile still lives
+ sTemp.Erase();
+ LocalFileHelper::ConvertURLToPhysicalName(aInitFile.GetURL(),sTemp);
+ LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp);
+ }
+ }
+}
+
+
+//-------------------------------------------------------------------------------------------------
+int ODriver::X_PARAM(const ::rtl::OUString& _DBNAME,
+ const ::rtl::OUString& _USR,
+ const ::rtl::OUString& _PWD,
+ const ::rtl::OUString& _CMD)
+{
+ // %XPARAM% -u %CONUSR%,%CONPWD% BINIT
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) << "x_param"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " -d "
+ << ::rtl::OString(_DBNAME,_DBNAME.getLength(),gsl_getSystemTextEncoding())
+ << " -u "
+ << ::rtl::OString(_USR,_USR.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_PWD,_PWD.getLength(),gsl_getSystemTextEncoding())
+ << " "
+ << ::rtl::OString(_CMD,_CMD.getLength(),gsl_getSystemTextEncoding())
+#if (defined(WIN) || defined(WNT))
+#if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL)
+ << " >> %DBWORK%\\create.log 2>&1"
+#endif
+#else
+#if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL)
+ << " >> /tmp/kstart.log"
+#else
+ << " > /dev/null"
+#endif
+#endif
+ << " "
+ << sNewLine
+ << sNewLine;
+
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::X_PARAM: calling the executable failed!" );
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODriver::CreateFiles(const TDatabaseStruct& _aInfo)
+{
+ int nRet = CreateFile(_aInfo.sSysDevSpace,_aInfo.nDataSize/50) ? 0 : -9;
+ if(!nRet)
+ nRet = CreateFile(_aInfo.sTransLogName,_aInfo.nLogSize) ? 0 : -10;
+ if(!nRet)
+ nRet = CreateFile(_aInfo.sDataDevName,_aInfo.nDataSize) ? 0 : -11;
+
+ return nRet;
+
+}
+// -----------------------------------------------------------------------------
+void ODriver::PutParam(const ::rtl::OUString& sDBName,
+ const ::rtl::OUString& rWhat,
+ const ::rtl::OUString& rHow)
+{
+ OArgumentList aArgs(3,&sDBName,&rWhat,&rHow);
+ ::rtl::OUString sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("putparam"));
+#if defined(WIN) || defined(WNT)
+ sCommand += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".exe"));
+#endif
+
+ OProcess aApp(sCommand,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS,aArgs );
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::PutParam: calling the executable failed!" );
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::CreateFile(const ::rtl::OUString &_FileName,
+ sal_Int32 _nSize)
+{
+OSL_TRACE("CreateFile %d",_nSize);
+ sal_Bool bOK = sal_True;
+ try
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(_FileName,STREAM_WRITE));
+ if( !pFileStream.get())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_DISK_SPACE,
+ "$filename$",_FileName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ (*pFileStream).SetFiller('\0');
+ sal_Int32 nNewSize = 0;
+ sal_Int32 nCount = _nSize /2;
+ for(sal_Int32 i=0; bOK && i < nCount; ++i)
+ {
+ nNewSize += 8192;//4096;
+ bOK = (*pFileStream).SetStreamSize(nNewSize);
+ pFileStream->Flush();
+ }
+
+ bOK = bOK && static_cast<sal_Int32>(pFileStream->Seek(STREAM_SEEK_TO_END)) == nNewSize;
+ }
+ catch(Exception&)
+ {
+ OSL_TRACE("Exception");
+ }
+ if(!bOK)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_DISK_SPACE,
+ "$filename$",_FileName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+
+ return bOK;
+ // dd if=/dev/zero bs=4k of=$DEV_NAME count=$2
+}
+// -----------------------------------------------------------------------------
+int ODriver::X_START(const ::rtl::OUString& sDBName)
+{
+ ::rtl::OUString sCommand;
+#if defined(WIN) || defined(WNT)
+
+ ::rtl::OUString sArg1 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-d"));
+ ::rtl::OUString sArg3 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBService"));
+ ::rtl::OUString sArg4 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBWindow"));
+
+ OArgumentList aArgs(4,&sArg1,&sDBName,&sArg3,&sArg4);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("strt.exe"));
+#else
+ OArgumentList aArgs(1,&sDBName);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_start"));
+#endif
+
+ OProcess aApp( sCommand ,m_sDbWorkURL);
+ OProcess::TProcessError eError = aApp.execute((OProcess::TProcessOption)OPROCESS_ADABAS,aArgs);
+
+ if(eError == OProcess::E_NotFound)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_COMMAND_NOT_FOUND,
+ "$databasename$",sDBName,
+ "$progname$",sCommand
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ OSL_ASSERT(eError == OProcess::E_None);
+
+ OProcess::TProcessInfo aInfo;
+ if(aApp.getInfo(OProcess::TData_ExitCode,&aInfo) == OProcess::E_None && aInfo.Code)
+ return aInfo.Code;
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+int ODriver::X_STOP(const ::rtl::OUString& sDBName)
+{
+ ::rtl::OUString sCommand;
+#if defined(WIN) || defined(WNT)
+
+ ::rtl::OUString sArg1 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-d"));
+ ::rtl::OUString sArg2 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBService"));
+
+ OArgumentList aArgs(3,&sArg1,&sDBName,&sArg2);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("stp.exe"));
+#else
+ OArgumentList aArgs(1,&sDBName);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_stop"));
+#endif
+ OProcess aApp( sCommand ,m_sDbWorkURL);
+
+ OProcess::TProcessError eError = aApp.execute((OProcess::TProcessOption)OPROCESS_ADABAS,aArgs);
+
+
+ OSL_ASSERT(eError == OProcess::E_None);
+ if(eError != OProcess::E_None)
+ return 1;
+ OProcess::TProcessInfo aInfo;
+ if(aApp.getInfo(OProcess::TData_ExitCode,&aInfo) == OProcess::E_None && aInfo.Code)
+ return aInfo.Code;
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void ODriver::XUTIL(const ::rtl::OUString& _rParam,
+ const ::rtl::OUString& _DBNAME,
+ const ::rtl::OUString& _USRNAME,
+ const ::rtl::OUString& _USRPWD)
+{
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".log");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("xutil"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) <<
+#if defined(WIN) || defined(WNT)
+ "xutil.exe"
+#else
+ "utility"
+#endif
+ << " -u "
+ << ::rtl::OString(_USRNAME,_USRNAME.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_USRPWD,_USRPWD.getLength(),gsl_getSystemTextEncoding())
+ << " -d "
+ << ::rtl::OString(_DBNAME,_DBNAME.getLength(),gsl_getSystemTextEncoding())
+ << " "
+ << ::rtl::OString(_rParam,_rParam.getLength(),gsl_getSystemTextEncoding())
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << " 2>&1"
+ << sNewLine;
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::XUTIL: calling the executable failed!" );
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+}
+// -----------------------------------------------------------------------------
+void ODriver::LoadBatch(const ::rtl::OUString& sDBName,
+ const ::rtl::OUString& _rUSR,
+ const ::rtl::OUString& _rPWD,
+ const ::rtl::OUString& _rBatch)
+{
+ OSL_ENSURE(_rBatch.getLength(),"No batch file given!");
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".log");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("LoadBatch"),&sExt,&sWorkUrl);
+#if OSL_DEBUG_LEVEL < 2
+ aCmdFile.EnableKillingFile();
+#endif
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) << "xload"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " -d "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " -u "
+ << ::rtl::OString(_rUSR,_rUSR.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_rPWD,_rPWD.getLength(),gsl_getSystemTextEncoding());
+
+ if ( !isKernelVersion(CURRENT_DB_VERSION) )
+ (*pFileStream) << " -S adabas -b ";
+ else
+ (*pFileStream) << " -S NATIVE -b ";
+
+ (*pFileStream) << ::rtl::OString(_rBatch,_rBatch.getLength(),gsl_getSystemTextEncoding())
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << " 2>&1"
+ << sNewLine;
+
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::LoadBatch: calling the executable failed!" );
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+}
+// -----------------------------------------------------------------------------
+void ODriver::fillEnvironmentVariables()
+{
+ // read the environment vars
+ struct env_data
+ {
+ const sal_Char* pAsciiEnvName;
+ ::rtl::OUString* pValue;
+ ::rtl::OUString* pValueURL;
+ } EnvData[] = {
+ { "DBWORK", &m_sDbWork, &m_sDbWorkURL },
+ { "DBCONFIG", &m_sDbConfig, &m_sDbConfigURL },
+ { "DBROOT", &m_sDbRoot, &m_sDbRootURL }
+ };
+
+ for ( size_t i = 0; i < sizeof( EnvData ) / sizeof( EnvData[0] ); ++i )
+ {
+ ::rtl::OUString sVarName = ::rtl::OUString::createFromAscii( EnvData[i].pAsciiEnvName );
+ ::rtl::OUString sEnvValue;
+ if(osl_getEnvironment( sVarName.pData, &sEnvValue.pData ) == osl_Process_E_None )
+ {
+ *EnvData[i].pValue = sEnvValue;
+ String sURL;
+ LocalFileHelper::ConvertPhysicalNameToURL( *EnvData[i].pValue, sURL );
+ *EnvData[i].pValueURL = sURL;
+ }
+ }
+
+ m_sDelimit = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODriver::generateInitFile() const
+{
+ String sExt;
+#if !(defined(WIN) || defined(WNT))
+ sExt = String::CreateFromAscii(".sh");
+#else
+ sExt = String::CreateFromAscii(".bat");
+#endif
+
+ String sWorkUrl(m_sDbWorkURL);
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl);
+#if !(defined(WIN) || defined(WNT))
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+ chmod(ByteString(sPhysicalPath,gsl_getSystemTextEncoding()).GetBuffer(),S_IRUSR|S_IWUSR|S_IXUSR);
+#endif
+
+#if !(defined(WIN) || defined(WNT))
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_WRITE);
+ (*pFileStream) << "#!/bin/sh"
+ << sNewLine
+ << "cd \"$DBWORK\""
+ << sNewLine
+ << sNewLine;
+ pFileStream->Flush();
+#endif
+
+ return aCmdFile.GetURL();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODriver::getDatabaseInitFile( const TDatabaseStruct& _aDBInfo)
+{
+ String sExt;
+ sExt.AssignAscii(".ins");
+
+
+ String sWorkUrl(m_sDbWorkURL);
+ ::utl::TempFile aInitFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl);
+ {
+ SvStream* pFileStream = aInitFile.GetStream(STREAM_WRITE);
+ (*pFileStream) << "* @(#)init.cmd 6.1.1 1994-11-10\n";
+ (*pFileStream) << "init config\n";
+ (*pFileStream) << "* default code:\n";
+ (*pFileStream) << "ascii\n";
+ (*pFileStream) << "* date time format\n";
+ (*pFileStream) << "internal\n";
+ (*pFileStream) << "* command timeout:\n";
+ (*pFileStream) << "900\n";
+ (*pFileStream) << "* lock timeout:\n";
+ (*pFileStream) << "360\n";
+ (*pFileStream) << "* request timeout:\n";
+ (*pFileStream) << "180\n";
+ (*pFileStream) << "* log mode:\n";
+ (*pFileStream) << "demo\n";
+ (*pFileStream) << "* log segment size:\n";
+ (*pFileStream) << "0\n";
+ (*pFileStream) << "* no of archive logs:\n";
+ (*pFileStream) << "0\n";
+ (*pFileStream) << "* no of data devspaces:\n";
+ (*pFileStream) << "1\n";
+ (*pFileStream) << "* mirror devspaces:\n";
+ (*pFileStream) << "n\n";
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ (*pFileStream) << "*--- device description ---\n";
+ (*pFileStream) << "* sys devspace name:\n";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sSysDevSpace,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+ (*pFileStream) << "\n* log devspace size:\n";
+ (*pFileStream) << ::rtl::OString::valueOf(_aDBInfo.nLogSize);
+ (*pFileStream) << "\n* log devspace name:\n";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sTransLogName,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+ (*pFileStream) << "\n* data devspace size:\n";
+ (*pFileStream) << ::rtl::OString::valueOf(_aDBInfo.nDataSize);
+ (*pFileStream) << "\n* data devspace name:\n";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sDataDevName,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+
+ (*pFileStream) << "\n* END INIT CONFIG\n";
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ if(_aDBInfo.bRestoreDatabase)
+ {
+ (*pFileStream) << "RESTORE DATA QUICK FROM '";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sBackupFile,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+ (*pFileStream) << "' BLOCKSIZE 8\n";
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ (*pFileStream) << "RESTART\n";
+
+ }
+ else
+ {
+ (*pFileStream) << "ACTIVATE SERVERDB SYSDBA \"";
+ (*pFileStream) << ::rtl::OString(_aDBInfo.sSysUser,_aDBInfo.sSysUser.getLength(),gsl_getSystemTextEncoding());
+ (*pFileStream) << "\" PASSWORD \"";
+ (*pFileStream) << ::rtl::OString(_aDBInfo.sSysPassword,_aDBInfo.sSysPassword.getLength(),gsl_getSystemTextEncoding());
+ (*pFileStream) << "\"\n";
+ }
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ (*pFileStream) << "exit\n";
+ }
+ return aInitFile.GetURL();
+}
+// -----------------------------------------------------------------------------
+void ODriver::X_CONS(const ::rtl::OUString& sDBName,const ::rtl::OString& _ACTION,const ::rtl::OUString& _FILENAME)
+{
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(_FILENAME,sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "x_cons"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " SHOW "
+ << _ACTION
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+}
+// -----------------------------------------------------------------------------
+void ODriver::checkAndRestart(const ::rtl::OUString& sDBName,const TDatabaseStruct& _rDbInfo)
+{
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".st");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("State"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ X_CONS(sDBName,"STATE",aCmdFile.GetURL());
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_SHARE_DENYALL);
+ if ( pFileStream )
+ {
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Int32 nStart = 2;
+ while(bRead && !pFileStream->IsEof())
+ {
+ String aLine;
+ bRead = pFileStream->ReadLine(sStateLine);
+ if(bRead)
+ {
+ if(sStateLine.Search("WARM") != STRING_NOTFOUND)
+ { // nothing to do
+ nStart = 0;
+ break;
+ }
+ else if(sStateLine.Search("COLD") != STRING_NOTFOUND)
+ {
+ nStart = 1;
+ break;
+ }
+ }
+ }
+ switch(nStart)
+ {
+ case 2:
+ clearDatabase(sDBName);
+ X_START(sDBName);
+ // don't break here
+ case 1:
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RESTART")),sDBName,_rDbInfo.sControlUser,_rDbInfo.sControlPassword);
+ case 0:
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::isVersion(const ::rtl::OUString& sDBName, const char* _pVersion)
+{
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".st");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("DevSpaces"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "getparam"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " KERNELVERSION > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE);
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Bool bIsVersion = sal_False;
+ while ( pFileStream && bRead && !pFileStream->IsEof() )
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if ( bRead )
+ {
+ bIsVersion = sStateLine.GetToken(1,' ').Equals(_pVersion) != 0;
+ break;
+ }
+ }
+ return bIsVersion;
+}
+// -----------------------------------------------------------------------------
+void ODriver::checkAndInsertNewDevSpace(const ::rtl::OUString& sDBName,
+ const TDatabaseStruct& _rDBInfo)
+{
+ // %DBROOT%\pgm\getparam %2 DATA_CACHE_PAGES > %3
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".st");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("DevSpaces"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "getparam"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " DATA_CACHE_PAGES > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE);
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Int32 nDataPages = 0;
+ while(pFileStream && bRead && !pFileStream->IsEof())
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if(bRead)
+ {
+ nDataPages = sStateLine.ToInt32();
+ if(nDataPages && nDataPages < 100)
+ {
+ // the space isn't big enough anymore so we increment it
+ PutParam(sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA_CACHE_PAGES")),::rtl::OUString::valueOf(nDataPages));
+ X_PARAM(sDBName,_rDBInfo.sControlUser,_rDBInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK")));
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::isKernelVersion(const char* _pVersion)
+{
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("KernelVersion"));
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "dbversion"
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE);
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Bool bIsVersion = sal_True;
+ while ( pFileStream && bRead && !pFileStream->IsEof() )
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if ( bRead )
+ {
+ // convert a 11.02.00 to a 12.01.30 version
+ bIsVersion = sStateLine.GetToken(0).Equals(_pVersion) != 0;
+ break;
+ }
+ }
+ return bIsVersion;
+}
+// -----------------------------------------------------------------------------
+void ODriver::installSystemTables( const TDatabaseStruct& _aInfo)
+{
+#if defined(WIN) || defined(WNT)
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% -b %m_sDbRoot%\env\TERMCHAR.ind
+ ::rtl::OUString aBatch = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-b "));
+ ::rtl::OUString sTemp2 = m_sDbRootURL + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TERMCHAR.ind"));
+ String sTemp;
+ sal_Bool bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ aBatch += sTemp;
+
+ XUTIL(aBatch,_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% DIAGNOSE TRIGGER OFF
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DIAGNOSE TRIGGER OFF")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xload -d %_DBNAME% -u %_SYSDBA_USER%,%_SYSDBA_PWD% -S NATIVE -b %m_sDbRoot%\env\DBS.ins %_DOMAINPWD%
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBS.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+ sTemp.AppendAscii(" ");
+ sTemp += String(_aInfo.sDomainPassword);
+
+ LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp);
+ }
+ // xload -d %_DBNAME% -u DOMAIN,%_DOMAINPWD% -S NATIVE -b %m_sDbRoot%\env\XDD.ins
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("XDD.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+
+ LoadBatch(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOMAIN")),_aInfo.sDomainPassword,sTemp);
+ }
+ // xload -d %_DBNAME% -u %_SYSDBA_USER%,%_SYSDBA_PWD% -S NATIVE -b %m_sDbRoot%\env\QP.ins
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QP.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+ LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp);
+ }
+ // xload -d %_DBNAME% -u DOMAIN,%_DOMAINPWD% -S NATIVE -b %m_sDbRoot%\env\SPROC.ins
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SPROC.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+
+ LoadBatch(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOMAIN")),_aInfo.sDomainPassword,sTemp);
+ }
+
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% DIAGNOSE TRIGGER ON
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DIAGNOSE TRIGGER ON")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% SET NOLOG OFF
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET NOLOG OFF")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% SHUTDOWN QUICK
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN QUICK")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% RESTART
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RESTART")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+
+#else // UNX
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) << "x_dbinst"
+ << " -d "
+ << ::rtl::OString(_aInfo.sDBName,_aInfo.sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " -u "
+ << ::rtl::OString(_aInfo.sSysUser,_aInfo.sSysUser.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_aInfo.sSysPassword,_aInfo.sSysPassword.getLength(),gsl_getSystemTextEncoding())
+ << " -w "
+ << ::rtl::OString(_aInfo.sDomainPassword,_aInfo.sDomainPassword.getLength(),gsl_getSystemTextEncoding())
+ << " -b ";
+
+ if ( isKernelVersion(ADABAS_KERNEL_11) )
+ (*pFileStream) << "-i all";
+ (*pFileStream)
+#if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL)
+ << " >> /tmp/kstart.log"
+#else
+ << " > /dev/null"
+#endif
+ << sNewLine
+ << sNewLine;
+ pFileStream->Flush();
+ }
+ // now execute the command
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+
+#endif //WNT,UNX
+}
+// -----------------------------------------------------------------------------
+void ODriver::convertOldVersion(const ::rtl::OUString& sDBName,const TDatabaseStruct& _rDbInfo)
+{
+ // first we have to check if this databse is a old version and we have to update the system tables
+ if ( !isVersion(sDBName,CURRENT_DB_VERSION) && isKernelVersion(CURRENT_DB_VERSION) )
+ {
+ if ( !_rDbInfo.sControlUser.getLength()
+ || !_rDbInfo.sControlPassword.getLength())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_DATABASE_NEEDS_CONVERTING) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ String sCommandFile = m_sDbWorkURL;
+ sCommandFile += String::CreateFromAscii("/xparam.prt");
+ if ( UCBContentHelper::Exists(sCommandFile) )
+ UCBContentHelper::Kill(sCommandFile);
+ X_PARAM(sDBName,_rDbInfo.sControlUser,_rDbInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK")));
+
+ if ( UCBContentHelper::Exists(sCommandFile) )
+ {
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READ) );
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ static ByteString s_ErrorId("-21100");
+ while ( pFileStream.get() && bRead && !pFileStream->IsEof() )
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if ( bRead && s_ErrorId == sStateLine.GetToken(0,' ') )
+ {
+ UCBContentHelper::Kill(sCommandFile);
+ ::rtl::OUString sError(::rtl::OUString::createFromAscii(sStateLine.GetBuffer()));
+ throw SQLException(sError,*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")),1000,Any());
+ }
+ }
+ }
+
+ UCBContentHelper::Kill(sCommandFile);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+ } // namespace adabas
+}// namespace connectivity
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/connectivity/source/drivers/adabas/BFunctions.cxx b/connectivity/source/drivers/adabas/BFunctions.cxx
new file mode 100644
index 000000000000..35be739588fe
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BFunctions.cxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BFunctions.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+//--------------------------------------------------------------------------
+#include "odbc/OFunctions.hxx"
+#include <osl/process.h>
+
+// Implib-Definitionen fuer ODBC-DLL/shared library:
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ T3SQLAllocHandle pODBC3SQLAllocHandle;
+T3SQLConnect pODBC3SQLConnect;
+T3SQLDriverConnect pODBC3SQLDriverConnect;
+T3SQLBrowseConnect pODBC3SQLBrowseConnect;
+T3SQLDataSources pODBC3SQLDataSources;
+T3SQLDrivers pODBC3SQLDrivers;
+T3SQLGetInfo pODBC3SQLGetInfo;
+T3SQLGetFunctions pODBC3SQLGetFunctions;
+T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
+T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
+T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
+T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
+T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
+T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
+T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
+//T3SQLSetDescField pODBC3SQLSetDescField;
+//T3SQLGetDescField pODBC3SQLGetDescField;
+//T3SQLGetDescRec pODBC3SQLGetDescRec;
+//T3SQLSetDescRec pODBC3SQLSetDescRec;
+T3SQLPrepare pODBC3SQLPrepare;
+T3SQLBindParameter pODBC3SQLBindParameter;
+//T3SQLGetCursorName pODBC3SQLGetCursorName;
+T3SQLSetCursorName pODBC3SQLSetCursorName;
+T3SQLExecute pODBC3SQLExecute;
+T3SQLExecDirect pODBC3SQLExecDirect;
+//T3SQLNativeSql pODBC3SQLNativeSql;
+T3SQLDescribeParam pODBC3SQLDescribeParam;
+T3SQLNumParams pODBC3SQLNumParams;
+T3SQLParamData pODBC3SQLParamData;
+T3SQLPutData pODBC3SQLPutData;
+T3SQLRowCount pODBC3SQLRowCount;
+T3SQLNumResultCols pODBC3SQLNumResultCols;
+T3SQLDescribeCol pODBC3SQLDescribeCol;
+T3SQLColAttribute pODBC3SQLColAttribute;
+T3SQLBindCol pODBC3SQLBindCol;
+T3SQLFetch pODBC3SQLFetch;
+T3SQLFetchScroll pODBC3SQLFetchScroll;
+T3SQLGetData pODBC3SQLGetData;
+T3SQLSetPos pODBC3SQLSetPos;
+T3SQLBulkOperations pODBC3SQLBulkOperations;
+T3SQLMoreResults pODBC3SQLMoreResults;
+//T3SQLGetDiagField pODBC3SQLGetDiagField;
+T3SQLGetDiagRec pODBC3SQLGetDiagRec;
+T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
+T3SQLColumns pODBC3SQLColumns;
+T3SQLForeignKeys pODBC3SQLForeignKeys;
+T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
+T3SQLProcedureColumns pODBC3SQLProcedureColumns;
+T3SQLProcedures pODBC3SQLProcedures;
+T3SQLSpecialColumns pODBC3SQLSpecialColumns;
+T3SQLStatistics pODBC3SQLStatistics;
+T3SQLTablePrivileges pODBC3SQLTablePrivileges;
+T3SQLTables pODBC3SQLTables;
+T3SQLFreeStmt pODBC3SQLFreeStmt;
+T3SQLCloseCursor pODBC3SQLCloseCursor;
+T3SQLCancel pODBC3SQLCancel;
+T3SQLEndTran pODBC3SQLEndTran;
+T3SQLDisconnect pODBC3SQLDisconnect;
+T3SQLFreeHandle pODBC3SQLFreeHandle;
+T3SQLGetCursorName pODBC3SQLGetCursorName;
+T3SQLNativeSql pODBC3SQLNativeSql;
+
+
+sal_Bool LoadFunctions(oslModule pODBCso);
+// -------------------------------------------------------------------------
+sal_Bool LoadLibrary_ADABAS(::rtl::OUString &_rPath)
+{
+ static sal_Bool bLoaded = sal_False;
+ static oslModule pODBCso = NULL;
+
+ if (bLoaded)
+ return sal_True;
+
+ rtl_uString* pPath = NULL;
+ ::rtl::OUString sTemp(RTL_CONSTASCII_USTRINGPARAM("DBROOT"));
+ if ( osl_getEnvironment(sTemp.pData,&pPath) == osl_Process_E_None && pPath )
+ {
+
+#if ( defined(SOLARIS) && defined(SPARC)) || defined(LINUX) || defined(MACOSX)
+ _rPath = ::rtl::OUString(pPath);
+ _rPath += ::rtl::OUString::createFromAscii("/lib/");
+#endif
+ rtl_uString_release(pPath);
+ }
+ else
+ {
+ _rPath = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The variable DBROOT is not set."));
+ return sal_False;
+ }
+ const sal_Char* pLibraryAsciiName = NULL;
+
+#if defined(WIN) || defined(WNT)
+ pLibraryAsciiName = "SQLOD32.DLL";
+#elif ( defined(SOLARIS) && defined(SPARC)) || defined(LINUX)
+ pLibraryAsciiName = "odbclib.so";
+#elif defined(MACOSX)
+ pLibraryAsciiName = "odbclib.dylib";
+#endif
+ if ( !pLibraryAsciiName )
+ return sal_False;
+
+ _rPath += ::rtl::OUString::createFromAscii( pLibraryAsciiName );
+ pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
+ if( !pODBCso)
+ return sal_False;
+
+
+ return bLoaded = LoadFunctions(pODBCso);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool LoadFunctions(oslModule pODBCso)
+{
+
+ if( ( pODBC3SQLAllocHandle = (T3SQLAllocHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLAllocHandle").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLConnect = (T3SQLConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDriverConnect = (T3SQLDriverConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDriverConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBrowseConnect = (T3SQLBrowseConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBrowseConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetInfo = (T3SQLGetInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetInfo").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetTypeInfo = (T3SQLGetTypeInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetTypeInfo").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetConnectAttr = (T3SQLSetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetConnectAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetConnectAttr = (T3SQLGetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetConnectAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetEnvAttr = (T3SQLSetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetEnvAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetEnvAttr = (T3SQLGetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetEnvAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetStmtAttr = (T3SQLSetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetStmtAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetStmtAttr = (T3SQLGetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetStmtAttr").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLSetDescField = (T3SQLSetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescField").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetDescField = (T3SQLGetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescField").pData )) == NULL )
+ return sal_False;*/
+ /*if( ( pODBC3SQLGetDescRec = (T3SQLGetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescRec").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetDescRec = (T3SQLSetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescRec").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLPrepare = (T3SQLPrepare)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrepare").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBindParameter = (T3SQLBindParameter)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindParameter").pData )) == NULL )
+ return sal_False;
+// if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
+// return sal_False;
+ if( ( pODBC3SQLSetCursorName = (T3SQLSetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetCursorName").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLExecute = (T3SQLExecute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecute").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLExecDirect = (T3SQLExecDirect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecDirect").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLDescribeParam = (T3SQLDescribeParam)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeParam").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNumParams = (T3SQLNumParams)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumParams").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLParamData = (T3SQLParamData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLParamData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLPutData = (T3SQLPutData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPutData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLRowCount = (T3SQLRowCount)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLRowCount").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNumResultCols = (T3SQLNumResultCols)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumResultCols").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDescribeCol = (T3SQLDescribeCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeCol").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColAttribute = (T3SQLColAttribute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColAttribute").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBindCol = (T3SQLBindCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindCol").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFetch = (T3SQLFetch)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetch").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFetchScroll = (T3SQLFetchScroll)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetchScroll").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetData = (T3SQLGetData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetPos = (T3SQLSetPos)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetPos").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLMoreResults = (T3SQLMoreResults)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLMoreResults").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLGetDiagField = (T3SQLGetDiagField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagField").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLGetDiagRec = (T3SQLGetDiagRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagRec").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColumnPrivileges = (T3SQLColumnPrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumnPrivileges").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColumns = (T3SQLColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLForeignKeys = (T3SQLForeignKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLForeignKeys").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLPrimaryKeys = (T3SQLPrimaryKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrimaryKeys").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLProcedureColumns = (T3SQLProcedureColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedureColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLProcedures = (T3SQLProcedures)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedures").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSpecialColumns = (T3SQLSpecialColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSpecialColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLStatistics = (T3SQLStatistics)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLStatistics").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLTablePrivileges = (T3SQLTablePrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTablePrivileges").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLTables = (T3SQLTables)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTables").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFreeStmt = (T3SQLFreeStmt)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeStmt").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLCloseCursor = (T3SQLCloseCursor)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCloseCursor").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLCancel = (T3SQLCancel)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCancel").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLEndTran = (T3SQLEndTran)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLEndTran").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDisconnect = (T3SQLDisconnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDisconnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFreeHandle = (T3SQLFreeHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeHandle").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
+ return sal_False;
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+ }
+}
+
diff --git a/connectivity/source/drivers/adabas/BGroup.cxx b/connectivity/source/drivers/adabas/BGroup.cxx
new file mode 100644
index 000000000000..c4bf6c1f0463
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BGroup.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BGroup.cxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_
+#include "adabas/BGroup.hxx"
+#endif
+#include "adabas/BUsers.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "adabas/BConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection) : connectivity::sdbcx::OGroup(sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ TStringVector aVector;
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection,
+ const ::rtl::OUString& _Name
+ ) : connectivity::sdbcx::OGroup(_Name,sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ refreshUsers();
+}
+// -------------------------------------------------------------------------
+void OAdabasGroup::refreshUsers()
+{
+ if(!m_pConnection)
+ return;
+
+ TStringVector aVector;
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL' AND GROUPNAME = '");
+ aSql += getName( );
+ aSql += ::rtl::OUString::createFromAscii("'");
+
+ Reference< XResultSet > xResult = xStmt->executeQuery(aSql);
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(1));
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
+}
+
+
diff --git a/connectivity/source/drivers/adabas/BGroups.cxx b/connectivity/source/drivers/adabas/BGroups.cxx
new file mode 100644
index 000000000000..a74de5cd8fe2
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BGroups.cxx
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BGroups.cxx,v $
+ * $Revision: 1.14 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BGroups.hxx"
+#include "adabas/BGroup.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OGroups::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdabasGroup(m_pConnection,_rName);
+}
+// -------------------------------------------------------------------------
+void OGroups::impl_refresh() throw(RuntimeException)
+{
+ m_pParent->refreshGroups();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OGroups::createDescriptor()
+{
+ // OAdabasGroup* pNew =
+ return new OAdabasGroup(m_pConnection);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OGroups::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& /*descriptor*/ )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USERGROUP ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+
+ aSql = aSql + aQuote + _rForName + aQuote;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OGroups::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USERGROUP ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+
+ aSql = aSql + aQuote + _sElementName + aQuote;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BIndex.cxx b/connectivity/source/drivers/adabas/BIndex.cxx
new file mode 100644
index 000000000000..f796700c6aab
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BIndex.cxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BIndex.cxx,v $
+ * $Revision: 1.15 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BIndex.hxx"
+#ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+#include "adabas/BIndexColumns.hxx"
+#endif
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "adabas/BTable.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OAdabasIndex::OAdabasIndex( OAdabasTable* _pTable,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Catalog,
+ sal_Bool _isUnique,
+ sal_Bool _isPrimaryKeyIndex,
+ sal_Bool _isClustered
+ ) : connectivity::sdbcx::OIndex(_Name,
+ _Catalog,
+ _isUnique,
+ _isPrimaryKeyIndex,
+ _isClustered,sal_True)
+ ,m_pTable(_pTable)
+{
+ construct();
+ refreshColumns();
+}
+// -------------------------------------------------------------------------
+OAdabasIndex::OAdabasIndex(OAdabasTable* _pTable)
+ : connectivity::sdbcx::OIndex(sal_True)
+ ,m_pTable(_pTable)
+{
+ construct();
+}
+// -----------------------------------------------------------------------------
+
+void OAdabasIndex::refreshColumns()
+{
+ if(!m_pTable)
+ return;
+
+ TStringVector aVector;
+ if(!isNew())
+ {
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),sal_False,sal_False);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aColName;
+ while(xResult->next())
+ {
+ if(xRow->getString(6) == m_Name)
+ {
+ aColName = xRow->getString(9);
+ if(!xRow->wasNull())
+ aVector.push_back(aColName);
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ }
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OIndexColumns(this,m_aMutex,aVector);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BIndexColumns.cxx b/connectivity/source/drivers/adabas/BIndexColumns.cxx
new file mode 100644
index 000000000000..5ce192077661
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BIndexColumns.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BIndexColumns.cxx,v $
+ * $Revision: 1.13 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+#include "adabas/BIndexColumns.hxx"
+#endif
+#include "connectivity/sdbcx/VIndexColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "adabas/BTable.hxx"
+#include "adabas/BCatalog.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+
+using namespace connectivity::adabas;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(Any(),
+ m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),sal_False,sal_False);
+
+ sal_Bool bAsc = sal_True;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aD(::rtl::OUString::createFromAscii("D"));
+ while(xResult->next())
+ {
+ if(xRow->getString(9) == _rName)
+ bAsc = xRow->getString(10) != aD;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(Any(),
+ m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),_rName);
+
+ ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sal_Int32 nType = xRow->getInt(5);
+ ::rtl::OUString sTypeName = xRow->getString(6);
+ sal_Int32 nPrec = xRow->getInt(7);
+ OAdabasCatalog::correctColumnProperties(nPrec,nType,sTypeName);
+
+ OIndexColumn* pRet = new OIndexColumn(bAsc,
+ _rName,
+ sTypeName,
+ xRow->getString(13),
+ xRow->getInt(11),
+ nPrec,
+ xRow->getInt(9),
+ nType,
+ sal_False,sal_False,sal_False,sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexColumns::createDescriptor()
+{
+ return new OIndexColumn(sal_True);
+}
+// -----------------------------------------------------------------------------
+void OIndexColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
+{
+ m_pIndex->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+ObjectType OIndexColumns::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor )
+{
+ return cloneDescriptor( descriptor );
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BIndexes.cxx b/connectivity/source/drivers/adabas/BIndexes.cxx
new file mode 100644
index 000000000000..86dbf8662a04
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BIndexes.cxx
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BIndexes.cxx,v $
+ * $Revision: 1.24 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BIndexes.hxx"
+#include "adabas/BIndex.hxx"
+#include "adabas/BTable.hxx"
+#include "connectivity/sdbcx/VIndex.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/IndexType.hpp>
+#include <comphelper/types.hxx>
+#include <comphelper/types.hxx>
+#include "adabas/BCatalog.hxx"
+#include "connectivity/dbexception.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aQualifier;
+ sal_Int32 nLen = _rName.indexOf('.');
+ if(nLen != -1)
+ {
+ aQualifier = _rName.copy(0,nLen);
+ aName = _rName.copy(nLen+1);
+ }
+ else
+ aName = _rName;
+
+
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),sal_False,sal_False);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(6) == aName && (!aQualifier.getLength() || xRow->getString(5) == aQualifier ))
+ {
+ OAdabasIndex* pRet = new OAdabasIndex(m_pTable,aName,aQualifier,!xRow->getBoolean(4),
+ aName == ::rtl::OUString::createFromAscii("SYSPRIMARYKEYINDEX"),
+ xRow->getShort(7) == IndexType::CLUSTERED);
+ xRet = pRet;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OIndexes::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshIndexes();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexes::createDescriptor()
+{
+ return new OAdabasIndex(m_pTable);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ if ( m_pTable->isNew() )
+ ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(this));
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE ");
+ ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ if(getBOOL(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))))
+ aSql = aSql + ::rtl::OUString::createFromAscii("UNIQUE ");
+ aSql = aSql + ::rtl::OUString::createFromAscii("INDEX ");
+
+
+ if(_rForName.getLength())
+ {
+ aSql = aSql + aQuote + _rForName + aQuote
+ + ::rtl::OUString::createFromAscii(" ON ")
+ + aQuote + m_pTable->getSchema() + aQuote + sDot
+ + aQuote + m_pTable->getTableName() + aQuote
+ + ::rtl::OUString::createFromAscii(" ( ");
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ sal_Int32 nCount = xColumns->getCount();
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql = aSql + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote;
+ aSql = aSql + (getBOOL(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING)))
+ ?
+ ::rtl::OUString::createFromAscii(" ASC")
+ :
+ ::rtl::OUString::createFromAscii(" DESC"))
+ + ::rtl::OUString::createFromAscii(",");
+ }
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ }
+ else
+ {
+ aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + sDot + aQuote + m_pTable->getTableName() + aQuote;
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ if(xColumns->getCount() != 1)
+ throw SQLException();
+
+ xColumns->getByIndex(0) >>= xColProp;
+
+ aSql = aSql + sDot + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote;
+ }
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OIndexes::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ if(!m_pTable->isNew())
+ {
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
+ ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ if (aSchema.getLength())
+ (((aSql += aQuote) += aSchema) += aQuote) += sDot;
+
+ (((aSql += aQuote) += aName) += aQuote) += ::rtl::OUString::createFromAscii(" ON ");
+
+ (((aSql += aQuote) += m_pTable->getSchema()) += aQuote) += sDot;
+ ((aSql += aQuote) += m_pTable->getTableName()) += aQuote;
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BKeys.cxx b/connectivity/source/drivers/adabas/BKeys.cxx
new file mode 100644
index 000000000000..c2df7d3de803
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BKeys.cxx
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BKeys.cxx,v $
+ * $Revision: 1.25 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BKeys.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <comphelper/types.hxx>
+#include "adabas/BCatalog.hxx"
+#include <comphelper/property.hxx>
+#include <connectivity/TKeys.hxx>
+#include <connectivity/dbtools.hxx>
+
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef OKeysHelper OCollection_TYPE;
+
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OKeys::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ if ( getTable()->isNew() )
+ {
+ Reference< XPropertySet > xNewDescriptor( cloneDescriptor( descriptor ) );
+ OKeysHelper::cloneDescriptorColumns( descriptor, xNewDescriptor );
+ return xNewDescriptor;
+ }
+
+ sal_Int32 nKeyType = getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ const ::rtl::OUString aQuote = getTable()->getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ aSql += composeTableName( getTable()->getConnection()->getMetaData(), getTable(), ::dbtools::eInTableDefinitions, false, false, true );
+
+ if(nKeyType == KeyType::PRIMARY)
+ {
+ aSql = aSql + ::rtl::OUString::createFromAscii(" ALTER PRIMARY KEY (");
+ }
+ else if(nKeyType == KeyType::FOREIGN)
+ {
+ aSql = aSql + ::rtl::OUString::createFromAscii(" FOREIGN KEY (");
+ }
+ else
+ throw SQLException();
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ Reference< XPropertySet > xColProp;
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql = aSql + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ sal_Int32 nUpdateRule = 0, nDeleteRule = 0;
+ ::rtl::OUString sReferencedName;
+
+ if(nKeyType == KeyType::FOREIGN)
+ {
+ nDeleteRule = getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE)));
+
+ ::rtl::OUString aName,aSchema;
+ sReferencedName = getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)));
+ sal_Int32 nLen = sReferencedName.indexOf('.');
+ aSchema = sReferencedName.copy(0,nLen);
+ aName = sReferencedName.copy(nLen+1);
+ aSql += ::rtl::OUString::createFromAscii(" REFERENCES ")
+ + aQuote + aSchema + aQuote + sDot + aQuote + aName + aQuote;
+ aSql += ::rtl::OUString::createFromAscii(" (");
+
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ Reference< XPropertySet > xColProp;
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql = aSql + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RELATEDCOLUMN))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ switch(nDeleteRule)
+ {
+ case KeyRule::CASCADE:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE ");
+ break;
+ case KeyRule::RESTRICT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT ");
+ break;
+ case KeyRule::SET_NULL:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL ");
+ break;
+ case KeyRule::SET_DEFAULT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT ");
+ break;
+ default:
+ ;
+ }
+ }
+
+ Reference< XStatement > xStmt = getTable()->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ // find the name which the database gave the new key
+ ::rtl::OUString sNewName( _rForName );
+ if(nKeyType == KeyType::FOREIGN)
+ {
+ const ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+ Reference< XResultSet > xResult = getTable()->getMetaData()->getImportedKeys( getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))
+ ,aSchema
+ ,aTable);
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ ::rtl::OUString sName = xRow->getString(12);
+ if ( !m_pElements->exists(sName) ) // this name wasn't inserted yet so it must be te new one
+ {
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sName));
+ sNewName = sName;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ }
+
+ getTable()->addKey(sNewName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(sReferencedName,nKeyType,nUpdateRule,nDeleteRule)));
+ return createObject( sNewName );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OKeys::getDropForeignKey() const
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP FOREIGN KEY "));
+}
+
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BPreparedStatement.cxx b/connectivity/source/drivers/adabas/BPreparedStatement.cxx
new file mode 100644
index 000000000000..900c50da2b6a
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BPreparedStatement.cxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BPreparedStatement.cxx,v $
+ * $Revision: 1.9.56.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BPreparedStatement.hxx"
+#include "adabas/BResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace connectivity::odbc;
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+OAdabasPreparedStatement::OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::rtl::OUString& sql)
+: ::connectivity::odbc::OPreparedStatement( _pConnection,sql)
+{
+ m_aSelectColumns = _pConnection->createSelectColumns(sql);
+}
+// -----------------------------------------------------------------------------
+OResultSet* OAdabasPreparedStatement::createResulSet()
+{
+ return new OAdabasResultSet(m_aStatementHandle,this,m_aSelectColumns);
+}
+// -----------------------------------------------------------------------------
+void OAdabasPreparedStatement::setUsingBookmarks(sal_Bool /*_bUseBookmark*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "bookmarks", *this );
+ // adabas doesn't support bookmarks
+}
+// -----------------------------------------------------------------------------
+void OAdabasPreparedStatement::setResultSetConcurrency(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetConcurrency", *this );
+}
+// -----------------------------------------------------------------------------
+void OAdabasPreparedStatement::setResultSetType(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetType", *this );
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BResultSet.cxx b/connectivity/source/drivers/adabas/BResultSet.cxx
new file mode 100644
index 000000000000..bca29a8f89ec
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BResultSet.cxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BResultSet.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BResultSet.hxx"
+#include "adabas/BResultSetMetaData.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "odbc/OTools.hxx"
+
+using namespace connectivity::adabas;
+using namespace connectivity::odbc;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+// comment: all this movement methods are needed because adabas doesn't support a SQLGetData call when
+// the cursor was moved with a call of SQLFetchScroll. So when this is fixed by adabas we can remove this damn thing.
+
+
+sal_Bool SAL_CALL OAdabasResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ // m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+
+ if(m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO)
+ ++m_nRowPos;
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ // don't ask why !
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
+ if ( bRet )
+ m_nRowPos = 1;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OAdabasResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ m_bEOF = sal_True;
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ // here I know definitely that I stand on the last record
+ return m_bLastRecord = (m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ if(bRet)
+ m_nRowPos = row;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ if(bRet)
+ m_nRowPos += row;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ if(bRet || m_nCurrentFetchState == SQL_NO_DATA)
+ --m_nRowPos;
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdabasResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSetMetaData > SAL_CALL OAdabasResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OAdabasResultSetMetaData(m_pStatement->getOwnConnection(),m_aStatementHandle,m_aSelectColumns);
+ return m_xMetaData;
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
diff --git a/connectivity/source/drivers/adabas/BResultSetMetaData.cxx b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx
new file mode 100644
index 000000000000..bad8b2b3e386
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BResultSetMetaData.cxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_BRESULTSETMETADATA_HXX_
+#include "adabas/BResultSetMetaData.hxx"
+#endif
+#include "adabas/BCatalog.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::uno;
+using namespace connectivity::adabas;
+using namespace connectivity;
+
+OAdabasResultSetMetaData::OAdabasResultSetMetaData(odbc::OConnection* _pConnection, SQLHANDLE _pStmt,const ::vos::ORef<OSQLColumns>& _rSelectColumns )
+: OAdabasResultSetMetaData_BASE(_pConnection,_pStmt)
+,m_aSelectColumns(_rSelectColumns)
+{
+}
+// -------------------------------------------------------------------------
+OAdabasResultSetMetaData::~OAdabasResultSetMetaData()
+{
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nType = OAdabasResultSetMetaData_BASE::getColumnType( column);
+ // special handling for float values which could be doubles
+ ::rtl::OUString sTypeName;
+ OAdabasCatalog::correctColumnProperties(getPrecision(column),nType,sTypeName);
+
+ return nType;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0;
+ sal_Bool bFound = sal_False;
+ if ( m_aSelectColumns.isValid() && column > 0 && column <= (sal_Int32)m_aSelectColumns->get().size() )
+ bFound = (m_aSelectColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nValue;
+
+ if ( !bFound )
+ nValue = getNumColAttrib(column,SQL_DESC_NULLABLE);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if ( m_aSelectColumns.isValid() && column > 0 && column <= (sal_Int32)m_aSelectColumns->get().size() )
+ {
+ sal_Bool bAutoIncrement = sal_False;
+ (m_aSelectColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
+ return bAutoIncrement;
+ }
+
+ return getNumColAttrib(column,SQL_DESC_AUTO_UNIQUE_VALUE) == SQL_TRUE;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BStatement.cxx b/connectivity/source/drivers/adabas/BStatement.cxx
new file mode 100644
index 000000000000..9454a25020d8
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BStatement.cxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BStatement.cxx,v $
+ * $Revision: 1.9.56.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BStatement.hxx"
+#include "adabas/BResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <connectivity/dbexception.hxx>
+
+
+using namespace connectivity::adabas;
+using namespace connectivity::odbc;
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+typedef ::connectivity::odbc::OStatement OAdabasStatement_BASE;
+// -----------------------------------------------------------------------------
+OResultSet* OAdabasStatement::createResulSet()
+{
+ return new OAdabasResultSet(m_aStatementHandle,this,m_aSelectColumns);
+}
+// -----------------------------------------------------------------------------
+void OAdabasStatement::setUsingBookmarks(sal_Bool /*_bUseBookmark*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "bookmarks", *this );
+ // adabas doesn't support bookmarks
+}
+// -----------------------------------------------------------------------------
+void OAdabasStatement::setResultSetConcurrency(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetConcurrency", *this );
+}
+// -----------------------------------------------------------------------------
+void OAdabasStatement::setResultSetType(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetType", *this );
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasStatement::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ m_aSelectColumns = m_pOwnConnection->createSelectColumns(sql);
+ return OAdabasStatement_BASE::execute(sql);
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BTable.cxx b/connectivity/source/drivers/adabas/BTable.cxx
new file mode 100644
index 000000000000..43d897c6f8b1
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BTable.cxx
@@ -0,0 +1,379 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BTable.cxx,v $
+ * $Revision: 1.36.56.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BTable.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BIndexes.hxx"
+#include "adabas/BColumns.hxx"
+#include "adabas/BKeys.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "adabas/BCatalog.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity::adabas;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OAdabasTable::OAdabasTable( sdbcx::OCollection* _pTables,
+ OAdabasConnection* _pConnection)
+ :OTable_TYPEDEF(_pTables,_pConnection,sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OAdabasTable::OAdabasTable( sdbcx::OCollection* _pTables,
+ OAdabasConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OTableHelper( _pTables,
+ _pConnection,
+ sal_True,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OAdabasTable::createColumns(const TStringVector& _rNames)
+{
+ return new OColumns(this,m_aMutex,_rNames);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OAdabasTable::createKeys(const TStringVector& _rNames)
+{
+ return new OKeys(this,m_aMutex,_rNames);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OAdabasTable::createIndexes(const TStringVector& _rNames)
+{
+ return new OIndexes(this,m_aMutex,_rNames);
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdabasTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdabasTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OTable_TYPEDEF::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+// XAlterTable
+void SAL_CALL OAdabasTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(
+#ifdef GCC
+ ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
+#else
+ rBHelper.bDisposed
+#endif
+ );
+
+ if(m_pColumns && !m_pColumns->hasByName(colName))
+ throw NoSuchElementException(colName,*this);
+
+
+ if(!isNew())
+ {
+ beginTransAction();
+
+ try
+ {
+ // first we have to check what should be altered
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByName(colName) >>= xProp;
+ // first check the types
+ sal_Int32 nOldType = 0,nNewType = 0,nOldPrec = 0,nNewPrec = 0,nOldScale = 0,nNewScale = 0;
+
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nOldType;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nNewType;
+ // and precsions and scale
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nOldPrec;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))>>= nNewPrec;
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nOldScale;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nNewScale;
+
+ if(nOldType != nNewType || nOldPrec != nNewPrec || nOldScale != nNewScale)
+ alterColumnType(colName,descriptor);
+
+ // second: check the "is nullable" value
+ sal_Int32 nOldNullable = 0,nNewNullable = 0;
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nOldNullable;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNewNullable;
+ if(nNewNullable != nOldNullable)
+ alterNotNullValue(nNewNullable,colName);
+
+ // third: check the default values
+ ::rtl::OUString sNewDefault,sOldDefault;
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sOldDefault;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sNewDefault;
+
+ if(sOldDefault.getLength())
+ {
+ if(sNewDefault.getLength() && sOldDefault != sNewDefault)
+ alterDefaultValue(sNewDefault,colName);
+ else if(!sNewDefault.getLength())
+ dropDefaultValue(colName);
+ }
+ else if(!sOldDefault.getLength() && sNewDefault.getLength())
+ addDefaultValue(sNewDefault,colName);
+
+ // now we should look if the name of the column changed
+ ::rtl::OUString sNewColumnName;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName;
+ if(!sNewColumnName.equalsIgnoreAsciiCase(colName))
+ {
+ const ::rtl::OUString sQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("RENAME COLUMN ") ;
+ sSql += ::dbtools::quoteName(sQuote,m_SchemaName) + sDot + ::dbtools::quoteName(sQuote,m_Name);
+ sSql += sDot + ::dbtools::quoteName(sQuote,colName);
+ sSql += ::rtl::OUString::createFromAscii(" TO ");
+ sSql += ::dbtools::quoteName(sQuote,sNewColumnName);
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ m_pColumns->refresh();
+ }
+ catch(const SQLException&)
+ {
+ rollbackTransAction();
+ throw;
+ }
+ endTransAction();
+ }
+ else
+ {
+ if(m_pColumns)
+ {
+ m_pColumns->dropByName(colName);
+ m_pColumns->appendByDescriptor(descriptor);
+ }
+ }
+
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OAdabasTable::getName() throw(::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sName = m_SchemaName;
+ if(m_SchemaName.getLength())
+ {
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ sName += sDot;
+ }
+ sName += m_Name;
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::alterColumnType(const ::rtl::OUString& _rColName, const Reference<XPropertySet>& _xDescriptor)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" ");
+ sSql += OTables::getColumnSqlType(_xDescriptor);
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::alterNotNullValue(sal_Int32 _nNewNullable,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+
+ if(_nNewNullable == ColumnValue::NO_NULLS)
+ {
+ sSql += ::rtl::OUString::createFromAscii(" NOT NULL");
+ }
+ else
+ {
+ sSql += ::rtl::OUString::createFromAscii(" DEFAULT NULL");
+ }
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" ALTER ") + _sNewDefault;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::dropDefaultValue(const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" DROP DEFAULT");
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::addDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" ADD ") + _sNewDefault;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::beginTransAction()
+{
+ try
+ {
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(::rtl::OUString::createFromAscii("SUBTRANS BEGIN") );
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::endTransAction()
+{
+ try
+ {
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(::rtl::OUString::createFromAscii("SUBTRANS END") );
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::rollbackTransAction()
+{
+ try
+ {
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(::rtl::OUString::createFromAscii("SUBTRANS ROLLBACK") );
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OAdabasTable::getAlterTableColumnPart(const ::rtl::OUString& _rsColumnName )
+{
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ const ::rtl::OUString sQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ sSql += ::dbtools::quoteName(sQuote,m_SchemaName) + sDot + ::dbtools::quoteName(sQuote,m_Name)
+ + ::rtl::OUString::createFromAscii(" COLUMN ")
+ + ::dbtools::quoteName(sQuote,_rsColumnName);
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx
new file mode 100644
index 000000000000..86b8df2fd795
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BTables.cxx
@@ -0,0 +1,525 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BTables.cxx,v $
+ * $Revision: 1.36 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BViews.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "adabas/BCatalog.hxx"
+#include "adabas/BConnection.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _rName.indexOf('.');
+ aSchema = _rName.copy(0,nLen);
+ aName = _rName.copy(nLen+1);
+
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString::createFromAscii("%");
+ // aTypes[0] = ::rtl::OUString::createFromAscii("TABLE");
+ // aTypes[1] = ::rtl::OUString::createFromAscii("SYSTEMTABLE");
+
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next()) // there can be only one table with this name
+ {
+ OAdabasTable* pRet = new OAdabasTable(this, static_cast<OAdabasCatalog&>(m_rParent).getConnection(),
+ aName,xRow->getString(4),xRow->getString(5),aSchema);
+ xRet = pRet;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OAdabasCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OTables::createDescriptor()
+{
+ return new OAdabasTable(this,static_cast<OAdabasCatalog&>(m_rParent).getConnection());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createTable(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+void OTables::setComments(const Reference< XPropertySet >& descriptor ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE ");
+ ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+ aSql = ::rtl::OUString::createFromAscii("COMMENT ON TABLE ");
+ ::rtl::OUString sSchema;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+
+ aSql += aQuote + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(" '")
+ + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)))
+ + ::rtl::OUString::createFromAscii("'");
+ xStmt->execute(aSql);
+
+ // columns
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+
+ aSql = ::rtl::OUString::createFromAscii("COMMENT ON COLUMN ");
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+ aSql += aQuote + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote + sDot
+ + aQuote;
+
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ ::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
+ if(xColProp.is())
+ {
+ ::rtl::OUString aDescription = getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)));
+ if(aDescription.getLength())
+ {
+ ::rtl::OUString aCom = aSql + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(" '")
+ + aDescription
+ + ::rtl::OUString::createFromAscii("'");
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ }
+ ::comphelper::disposeComponent(xStmt);
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP ");
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ Reference<XPropertySet> xProp(xObject,UNO_QUERY);
+ sal_Bool bIsView;
+ if((bIsView = (xProp.is() && ::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) == ::rtl::OUString::createFromAscii("VIEW")))) // here we have a view
+ aSql += ::rtl::OUString::createFromAscii("VIEW ");
+ else
+ aSql += ::rtl::OUString::createFromAscii("TABLE ");
+
+ aSql += m_xMetaData->getIdentifierQuoteString( ) + aSchema + m_xMetaData->getIdentifierQuoteString( );
+ aSql += sDot;
+ aSql += m_xMetaData->getIdentifierQuoteString( ) + aName + m_xMetaData->getIdentifierQuoteString( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ // if no exception was thrown we must delete it from the views
+ if(bIsView)
+ {
+ OViews* pViews = static_cast<OViews*>(static_cast<OAdabasCatalog&>(m_rParent).getPrivateViews());
+ if(pViews && pViews->hasByName(_sElementName))
+ pViews->dropByNameImpl(_sElementName);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void OTables::createTable( const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE ");
+ ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ ::rtl::OUString sSchema;
+
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+ else
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),makeAny(static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getUserName().
+ toAsciiUpperCase()
+ ));
+
+ aSql += ::dbtools::quoteName(aQuote, getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))))
+ + ::rtl::OUString::createFromAscii(" (");
+
+ // columns
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+
+ Any aTypeName;
+ sal_Int32 nCount = xColumns->getCount();
+ if(!nCount)
+ ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(this));
+
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(i)) && xColProp.is())
+ {
+
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote;
+
+ aSql += ::rtl::OUString::createFromAscii(" ");
+ aSql += OTables::getColumnSqlType(xColProp);
+ aSql += OTables::getColumnSqlNotNullDefault(xColProp);
+ aSql += ::rtl::OUString::createFromAscii(",");
+ }
+ }
+
+ // keys
+
+ Reference<XKeysSupplier> xKeySup(descriptor,UNO_QUERY);
+
+ Reference<XIndexAccess> xKeys = xKeySup->getKeys();
+ if(xKeys.is())
+ {
+ sal_Bool bPKey = sal_False;
+ for( sal_Int32 key=0; key<xKeys->getCount(); ++key )
+ {
+ if(::cppu::extractInterface(xColProp,xKeys->getByIndex(key)) && xColProp.is())
+ {
+
+ sal_Int32 nKeyType = getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+
+ if(nKeyType == KeyType::PRIMARY)
+ {
+ if(bPKey)
+ throw SQLException();
+
+ bPKey = sal_True;
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns->getCount())
+ throw SQLException();
+
+ aSql += ::rtl::OUString::createFromAscii(" PRIMARY KEY (");
+ for( sal_Int32 column=0; column<xColumns->getCount(); ++column )
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ }
+ else if(nKeyType == KeyType::UNIQUE)
+ {
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns->getCount())
+ throw SQLException();
+
+ aSql += ::rtl::OUString::createFromAscii(" UNIQUE (");
+ for( sal_Int32 column=0; column<xColumns->getCount(); ++column )
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ }
+ else if(nKeyType == KeyType::FOREIGN)
+ {
+ sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE)));
+
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns->getCount())
+ throw SQLException();
+
+ aSql += ::rtl::OUString::createFromAscii(" FOREIGN KEY ");
+ ::rtl::OUString aName,aSchema,aRefTable = getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)));
+ sal_Int32 nLen = aRefTable.indexOf('.');
+ aSchema = aRefTable.copy(0,nLen);
+ aName = aRefTable.copy(nLen+1);
+
+ aSql += aQuote + aSchema + aQuote + sDot
+ + aQuote + aName + aQuote
+ + ::rtl::OUString::createFromAscii(" (");
+
+ for ( sal_Int32 column=0; column<xColumns->getCount(); ++column )
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ switch(nDeleteRule)
+ {
+ case KeyRule::CASCADE:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE ");
+ break;
+ case KeyRule::RESTRICT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT ");
+ break;
+ case KeyRule::SET_NULL:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL ");
+ break;
+ case KeyRule::SET_DEFAULT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT ");
+ break;
+ default:
+ ;
+ }
+ }
+ }
+ }
+ }
+
+ if(aSql.lastIndexOf(',') == (aSql.getLength()-1))
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ else
+ aSql += ::rtl::OUString::createFromAscii(")");
+
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ if(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION))).getLength())
+ setComments(descriptor);
+}
+// -----------------------------------------------------------------------------
+void OTables::appendNew(const ::rtl::OUString& _rsNewTable)
+{
+ insertElement(_rsNewTable,NULL);
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
+ OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getColumnSqlType(const Reference<XPropertySet>& _rxColProp)
+{
+ ::rtl::OUString sSql;
+ sal_Int32 nDataType = 0;
+ _rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nDataType;
+ switch(nDataType)
+ {
+ case DataType::VARBINARY:
+ sSql += ::rtl::OUString::createFromAscii("VAR");
+ /* run through*/
+ case DataType::BINARY:
+ sSql += ::rtl::OUString::createFromAscii("CHAR");
+ break;
+ default:
+ {
+ Any aTypeName = _rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
+ if(aTypeName.hasValue() && getString(aTypeName).getLength())
+ sSql += getString(aTypeName);
+ else
+ sSql += OTables::getTypeString(_rxColProp) + ::rtl::OUString::createFromAscii(" ");
+ }
+ }
+
+ switch(nDataType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ sSql += ::rtl::OUString::createFromAscii("(")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
+ + ::rtl::OUString::createFromAscii(")");
+ break;
+
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ sSql += ::rtl::OUString::createFromAscii("(")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
+ + ::rtl::OUString::createFromAscii(",")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))))
+ + ::rtl::OUString::createFromAscii(")");
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ sSql += ::rtl::OUString::createFromAscii("(")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
+ + ::rtl::OUString::createFromAscii(") BYTE");
+ break;
+ }
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getColumnSqlNotNullDefault(const Reference<XPropertySet>& _rxColProp)
+{
+ OSL_ENSURE(_rxColProp.is(),"OTables::getColumnSqlNotNullDefault: Column is null!");
+ ::rtl::OUString sSql;
+ ::rtl::OUString aDefault = getString(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)));
+ if(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS)
+ {
+ sSql += ::rtl::OUString::createFromAscii(" NOT NULL");
+ if(aDefault.getLength())
+ sSql += ::rtl::OUString::createFromAscii(" WITH DEFAULT");
+ }
+ else if(aDefault.getLength())
+ {
+ sSql +=::rtl::OUString::createFromAscii(" DEFAULT '") + aDefault;
+ sSql += ::rtl::OUString::createFromAscii("'");
+ }
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getTypeString(const Reference< XPropertySet >& _rxColProp)
+{
+ ::rtl::OUString aValue;
+ switch(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ {
+ case DataType::BIT:
+ aValue = ::rtl::OUString::createFromAscii("BOOLEAN");
+ break;
+ case DataType::TINYINT:
+ aValue = ::rtl::OUString::createFromAscii("SMALLINT");
+ break;
+ case DataType::SMALLINT:
+ aValue = ::rtl::OUString::createFromAscii("SMALLINT");
+ break;
+ case DataType::INTEGER:
+ aValue = ::rtl::OUString::createFromAscii("INT");
+ break;
+ case DataType::FLOAT:
+ aValue = ::rtl::OUString::createFromAscii("FLOAT");
+ break;
+ case DataType::REAL:
+ aValue = ::rtl::OUString::createFromAscii("REAL");
+ break;
+ case DataType::DOUBLE:
+ aValue = ::rtl::OUString::createFromAscii("DOUBLE");
+ break;
+ case DataType::NUMERIC:
+ aValue = ::rtl::OUString::createFromAscii("DECIMAL");
+ break;
+ case DataType::DECIMAL:
+ aValue = ::rtl::OUString::createFromAscii("DECIMAL");
+ break;
+ case DataType::CHAR:
+ aValue = ::rtl::OUString::createFromAscii("CHAR");
+ break;
+ case DataType::VARCHAR:
+ aValue = ::rtl::OUString::createFromAscii("VARCHAR");
+ break;
+ case DataType::LONGVARCHAR:
+ aValue = ::rtl::OUString::createFromAscii("LONG VARCHAR");
+ break;
+ case DataType::DATE:
+ aValue = ::rtl::OUString::createFromAscii("DATE");
+ break;
+ case DataType::TIME:
+ aValue = ::rtl::OUString::createFromAscii("TIME");
+ break;
+ case DataType::TIMESTAMP:
+ aValue = ::rtl::OUString::createFromAscii("TIMESTAMP");
+ break;
+ case DataType::BINARY:
+ aValue = ::rtl::OUString::createFromAscii("CHAR () BYTE");
+ break;
+ case DataType::VARBINARY:
+ aValue = ::rtl::OUString::createFromAscii("VARCHAR () BYTE");
+ break;
+ case DataType::LONGVARBINARY:
+ aValue = ::rtl::OUString::createFromAscii("LONG BYTE");
+ break;
+ }
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
+{
+ OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
+ ::rtl::OUString sName,sTemp;
+ _xObject->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sName;
+ if( sName.getLength() )
+ {
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ sName += sDot;
+ }
+
+ _xObject->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sTemp;
+ sName += sTemp;
+
+ return sName;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/adabas/BUser.cxx b/connectivity/source/drivers/adabas/BUser.cxx
new file mode 100644
index 000000000000..f2b2e010f710
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BUser.cxx
@@ -0,0 +1,335 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BUser.cxx,v $
+ * $Revision: 1.17.56.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BUser.hxx"
+#include "adabas/BGroups.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "adabas/BConnection.hxx"
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include "resource/adabas_res.hrc"
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection) : connectivity::sdbcx::OUser(sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection,
+ const ::rtl::OUString& _Name
+ ) : connectivity::sdbcx::OUser(_Name,sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OAdabasUser::refreshGroups()
+{
+ if(!m_pConnection)
+ return;
+
+ TStringVector aVector;
+ aVector.reserve(7); // we don't know the excatly count of users but this should fit the normal need
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' ' AND USERNAME = '");
+ aSql += getName( );
+ aSql += ::rtl::OUString::createFromAscii("'");
+
+ Reference< XResultSet > xResult = xStmt->executeQuery(aSql);
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(1));
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ if(m_pGroups)
+ m_pGroups->reFill(aVector);
+ else
+ m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+OUserExtend::OUserExtend( OAdabasConnection* _pConnection) : OAdabasUser(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+void OUserExtend::construct()
+{
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+ return *OUserExtend_PROP::getArrayHelper();
+}
+typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ return 0;
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ getAnyTablePrivileges(objName,nRights,nRightsWithGrant);
+ return nRights;
+}
+// -----------------------------------------------------------------------------
+void OAdabasUser::getAnyTablePrivileges(const ::rtl::OUString& objName, sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(SQLException, RuntimeException)
+{
+ nRightsWithGrant = nRights = 0;
+ // first we need to create the sql stmt to select the privs
+ Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ Reference<XStatement> xStmt = m_pConnection->createStatement();
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("SELECT REFTABLENAME,PRIVILEGES FROM DOMAIN.USR_USES_TAB WHERE REFOBJTYPE <> 'SYSTEM' AND DEFUSERNAME = '");
+ sSql += m_Name;
+ sSql += ::rtl::OUString::createFromAscii("' AND REFTABLENAME = '");
+ sSql += sTable;
+ sSql += ::rtl::OUString::createFromAscii("'");
+ if(xStmt.is())
+ {
+ Reference<XResultSet> xRes = xStmt->executeQuery(sSql);
+ if(xRes.is())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if(xRow.is() && xRes->next())
+ {
+ ::rtl::OUString sPrivs = xRow->getString(2);
+
+ struct _priv_nam
+ {
+ const sal_Char* pAsciiName;
+ sal_Int32 nNumericValue;
+ } privileges[] =
+ {
+ { "INS", Privilege::INSERT },
+ { "DEL", Privilege::DELETE },
+ { "UPD", Privilege::UPDATE },
+ { "ALT", Privilege::ALTER },
+ { "SEL", Privilege::SELECT },
+ { "REF", Privilege::REFERENCE }
+ };
+ for ( size_t i = 0; i < sizeof( privileges ) / sizeof( privileges[0] ); ++i )
+ {
+ sal_Int32 nIndex = sPrivs.indexOf( ::rtl::OUString::createFromAscii( privileges[i].pAsciiName ) );
+ if ( nIndex == -1 )
+ continue;
+
+ nRights |= privileges[i].nNumericValue;
+ if ( sPrivs.copy( nIndex + 2, 1 ).equalsAscii( "+" ) )
+ nRightsWithGrant |= privileges[i].nNumericValue;
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ }
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ return 0;
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ getAnyTablePrivileges(objName,nRights,nRightsWithGrant);
+ return nRightsWithGrant;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdabasUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ m_pConnection->throwGenericSQLException(STR_PRIVILEGE_NOT_GRANTED,*this);
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("GRANT ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" TO ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdabasUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ m_pConnection->throwGenericSQLException(STR_PRIVILEGE_NOT_REVOKED,*this);
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("REVOKE ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" FROM ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+// XUser
+void SAL_CALL OAdabasUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sAlterPwd;
+ sAlterPwd = ::rtl::OUString::createFromAscii("ALTER PASSWORD \"");
+ sAlterPwd += objPassword.toAsciiUpperCase();
+ sAlterPwd += ::rtl::OUString::createFromAscii("\" TO \"") ;
+ sAlterPwd += newPassword.toAsciiUpperCase();
+ sAlterPwd += ::rtl::OUString::createFromAscii("\"") ;
+
+ sal_Bool bDisposeConnection = sal_False;
+ Reference<XConnection> xConnection = m_pConnection;
+ if(m_pConnection->getMetaData()->getUserName() != m_Name)
+ {
+ OAdabasConnection* pNewConnection = new OAdabasConnection(m_pConnection->getDriverHandle(),m_pConnection->getDriver());
+ xConnection = pNewConnection;
+ if(pNewConnection)
+ {
+ Sequence< PropertyValue> aSeq(2);
+ aSeq.getArray()[0].Name = ::rtl::OUString::createFromAscii("user") ;
+ aSeq.getArray()[0].Value <<= m_Name;
+ aSeq.getArray()[1].Name = ::rtl::OUString::createFromAscii("password") ;
+ aSeq.getArray()[1].Value <<= objPassword;
+ pNewConnection->Construct(m_pConnection->getMetaData()->getURL(),aSeq);
+ }
+ bDisposeConnection = sal_True;
+ }
+ if(xConnection.is())
+ {
+ Reference<XStatement> xStmt = xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sAlterPwd);
+ ::comphelper::disposeComponent(xStmt);
+ if(bDisposeConnection)
+ ::comphelper::disposeComponent(xConnection);
+ }
+ else
+ ::dbtools::throwFunctionSequenceException(*this);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OAdabasUser::getPrivilegeString(sal_Int32 nRights) const
+{
+ ::rtl::OUString sPrivs;
+ if((nRights & Privilege::INSERT) == Privilege::INSERT)
+ sPrivs += ::rtl::OUString::createFromAscii("INSERT");
+
+ if((nRights & Privilege::DELETE) == Privilege::DELETE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("DELETE");
+ }
+
+ if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("UPDATE");
+ }
+
+ if((nRights & Privilege::ALTER) == Privilege::ALTER)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("ALTER");
+ }
+
+ if((nRights & Privilege::SELECT) == Privilege::SELECT)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("SELECT");
+ }
+
+ if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("REFERENCES");
+ }
+
+ return sPrivs;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BUsers.cxx b/connectivity/source/drivers/adabas/BUsers.cxx
new file mode 100644
index 000000000000..4af1d463e5ae
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BUsers.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BUsers.cxx,v $
+ * $Revision: 1.19.56.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BUsers.hxx"
+#include "adabas/BUser.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include "resource/adabas_res.hrc"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OUsers::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdabasUser(m_pConnection,_rName);
+}
+// -------------------------------------------------------------------------
+void OUsers::impl_refresh() throw(RuntimeException)
+{
+ m_pParent->refreshUsers();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OUsers::createDescriptor()
+{
+ OUserExtend* pNew = new OUserExtend(m_pConnection);
+ return pNew;
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OUsers::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USER ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+
+ ::rtl::OUString sUserName( _rForName );
+ sUserName = sUserName.toAsciiUpperCase();
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sUserName));
+ aSql += ::dbtools::quoteName(aQuote,sUserName)
+ + ::rtl::OUString::createFromAscii(" PASSWORD ")
+ + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)));
+ aSql += ::rtl::OUString::createFromAscii(" RESOURCE NOT EXCLUSIVE");
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OUsers::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ {
+ // first we have to check if this user is live relevaant for the database
+ // which means with out these users the database will miss more than one important system table
+ ::rtl::OUString sUsers = ::rtl::OUString::createFromAscii("SELECT USERMODE,USERNAME FROM DOMAIN.USERS WHERE USERNAME = '");
+ sUsers += _sElementName + ::rtl::OUString::createFromAscii("'");
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ Reference<XResultSet> xRes = xStmt->executeQuery(sUsers);
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if(xRes.is() && xRow.is() && xRes->next()) // there can only be one user with this name
+ {
+ static const ::rtl::OUString sDbaUser = ::rtl::OUString::createFromAscii("DBA");
+ if(xRow->getString(1) == sDbaUser)
+ {
+ ::comphelper::disposeComponent(xStmt);
+ m_pConnection->throwGenericSQLException(STR_USER_NO_DELETE,static_cast< XDrop* >( this ));
+ }
+ }
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+
+ {
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USER ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+ aSql += ::dbtools::quoteName(aQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/adabas/BViews.cxx b/connectivity/source/drivers/adabas/BViews.cxx
new file mode 100644
index 000000000000..5a7fda021701
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BViews.cxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: BViews.cxx,v $
+ * $Revision: 1.21 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BViews.hxx"
+#include "adabas/BTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/CheckOption.hpp>
+#include "adabas/BCatalog.hxx"
+#include "adabas/BConnection.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include "connectivity/sdbcx/VView.hxx"
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+using namespace ::cppu;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OViews::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _rName.indexOf('.');
+ aSchema = _rName.copy(0,nLen);
+ aName = _rName.copy(nLen+1);
+
+ ::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT DISTINCT * FROM DOMAIN.SHOW_VIEW WHERE ");
+ if(aSchema.getLength())
+ {
+ sStmt += ::rtl::OUString::createFromAscii("OWNER = '");
+ sStmt += aSchema;
+ sStmt += ::rtl::OUString::createFromAscii("' AND ");
+ }
+ sStmt += ::rtl::OUString::createFromAscii("VIEWNAME = '");
+ sStmt += aName;
+ sStmt += ::rtl::OUString::createFromAscii("'");
+ Reference<XConnection> xConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ Reference< XResultSet > xResult = xStmt->executeQuery(sStmt);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next()) // there can be only one table with this name
+ {
+ connectivity::sdbcx::OView* pRet = new connectivity::sdbcx::OView(sal_True,
+ aName,
+ xConnection->getMetaData(),
+ CheckOption::NONE,
+ xRow->getString(3),
+ aSchema);
+ xRet = pRet;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OViews::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OAdabasCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OViews::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OViews::createDescriptor()
+{
+ Reference<XConnection> xConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ return new connectivity::sdbcx::OView(sal_True,xConnection->getMetaData());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createView(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OViews::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ if(m_bInDrop)
+ return;
+
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP VIEW");
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aSchema + m_xMetaData->getIdentifierQuoteString( );
+ aSql = aSql + sDot;
+ aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aName + m_xMetaData->getIdentifierQuoteString( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OViews::dropByNameImpl(const ::rtl::OUString& elementName)
+{
+ m_bInDrop = sal_True;
+ OCollection_TYPE::dropByName(elementName);
+ m_bInDrop = sal_False;
+}
+// -----------------------------------------------------------------------------
+void OViews::createView( const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE VIEW ");
+ ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ ::rtl::OUString sSchema,sCommand;
+
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+ else
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),makeAny(sSchema = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getUserName()));
+
+ aSql += ::dbtools::quoteName(aQuote, getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))))
+ + ::rtl::OUString::createFromAscii(" AS ");
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand;
+ aSql += sCommand;
+
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ // insert the new view also in the tables collection
+ OTables* pTables = static_cast<OTables*>(static_cast<OAdabasCatalog&>(m_rParent).getPrivateTables());
+ if(pTables)
+ {
+ ::rtl::OUString sName = sSchema;
+ sName += sDot;
+ sName += getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
+ pTables->appendNew(sName);
+ }
+}
diff --git a/connectivity/source/drivers/adabas/Bservices.cxx b/connectivity/source/drivers/adabas/Bservices.cxx
new file mode 100644
index 000000000000..268313285512
--- /dev/null
+++ b/connectivity/source/drivers/adabas/Bservices.cxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Bservices.cxx,v $
+ * $Revision: 1.7 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::adabas;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "ADABAS::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/adabas/adabas.map b/connectivity/source/drivers/adabas/adabas.map
new file mode 100644
index 000000000000..7ce4c703e6b3
--- /dev/null
+++ b/connectivity/source/drivers/adabas/adabas.map
@@ -0,0 +1,8 @@
+ADABAS_2_0 {
+ global:
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
+ local:
+ *;
+};
diff --git a/connectivity/source/drivers/adabas/adabas.mxp.map b/connectivity/source/drivers/adabas/adabas.mxp.map
new file mode 100644
index 000000000000..2ce9f111412b
--- /dev/null
+++ b/connectivity/source/drivers/adabas/adabas.mxp.map
@@ -0,0 +1,148 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+__mh_dylib_header
+___builtin_delete
+___builtin_vec_delete
+___builtin_vec_new
+___check_eh_spec
+___cp_pop_exception
+___cp_push_exception
+___eh_alloc
+___get_eh_context
+___pure_virtual
+___rtti_class
+___rtti_si
+___rtti_user
+___sjthrow
+___start_cp_handler
+___terminate
+_terminate__Fv
+dyld_stub_binding_helper
+rest_world
+save_world
+___eh_rtime_match
+__floatdisf
+___builtin_new
+___rtti_ptr
+___tf9bad_alloc
+__._10bad_typeid
+__._8bad_cast
+___get_eh_info
+___is_pointer__FPv
+___throw_type_match_rtti
+___vt_10bad_typeid
+___vt_8bad_cast
+__keymgr_get_per_thread_data
+__keymgr_set_per_thread_data
+___tf9exception
+___ti9exception
+___vt_9exception
+_what__C9exception
+__._9bad_alloc
+___vt_9bad_alloc
+__._9type_info
+___eq__C9type_infoRCB0
+___tf16__user_type_info
+___tf9type_info
+___ti9type_info
+___vt_9type_info
+_release__Q312connectivity6adabas7ODriver
+_acquire__Q312connectivity6adabas7ODriver
+___Q312connectivity6adabas7ODriver
+_refreshUsers__Q312connectivity6adabas14OAdabasCatalog
+_refreshGroups__Q312connectivity6adabas14OAdabasCatalog
+_refreshViews__Q312connectivity6adabas14OAdabasCatalog
+_refreshTables__Q312connectivity6adabas14OAdabasCatalog
+__._Q312connectivity6adabas12OAdabasGroup
+_refreshUsers__Q312connectivity6adabas12OAdabasGroup
+__._Q312connectivity6adabas11OAdabasUser
+__._Q312connectivity6adabas11OUserExtend
+_construct__Q312connectivity6adabas11OUserExtend
+___Q312connectivity6adabas11OAdabasUserPQ312connectivity6adabas17OAdabasConnection
+__._Q312connectivity6adabas18UStringDescription
+___Q312connectivity6adabas18UStringDescriptionPFv_PCc
+__._Q312connectivity6adabas10OAdabasKey
+_refreshColumns__Q312connectivity6adabas10OAdabasKey
+__._Q312connectivity6adabas12OAdabasIndex
+_refreshColumns__Q312connectivity6adabas12OAdabasIndex
+__._Q312connectivity6adabas12OAdabasTable
+_release__Q312connectivity6adabas12OAdabasTable
+_acquire__Q312connectivity6adabas12OAdabasTable
+_refreshForgeinKeys__Q312connectivity6adabas12OAdabasTableRQ24_STLt6vector2ZQ23rtl8OUStringZQ24_STLt9allocator1ZB2
+_refreshPrimaryKeys__Q312connectivity6adabas12OAdabasTableRQ24_STLt6vector2ZQ23rtl8OUStringZQ24_STLt9allocator1ZB2
+_refreshIndexes__Q312connectivity6adabas12OAdabasTable
+_refreshKeys__Q312connectivity6adabas12OAdabasTable
+_refreshColumns__Q312connectivity6adabas12OAdabasTable
+_setComments__Q312connectivity6adabas7OTablesRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star5beans12XPropertySet
+__._Q312connectivity6adabas23OAdabasDatabaseMetaData
+__._Q312connectivity6adabas24OAdabasPreparedStatement
+__._Q312connectivity6adabas16OAdabasStatement
+__._Q312connectivity6adabas16OAdabasResultSet
+_initBoundParam__Q312connectivity4odbc18OPreparedStatement
+_setStream__Q312connectivity4odbc18OPreparedStatementlRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star2io12XInputStreamln2
+_setBinary__Q312connectivity4odbc18OPreparedStatementllRCQ53com3sun4star3unot8Sequence1ZSc
+_getLengthBuf__Q312connectivity4odbc18OPreparedStatementl
+_allocBindBuf__Q312connectivity4odbc18OPreparedStatementll
+_setChar__Q312connectivity4odbc18OPreparedStatementln2RCQ23rtl8OUString
+_putParamData__Q312connectivity4odbc18OPreparedStatementl
+_FreeParams__Q312connectivity4odbc18OPreparedStatement
+_prepareStatement__Q312connectivity4odbc18OPreparedStatement
+__._Q312connectivity4odbc18UStringDescription
+___Q312connectivity4odbc18UStringDescriptionPFv_PCc
+_disposing__Q312connectivity4odbc15OStatement_Base
+_release__Q312connectivity4odbc15OStatement_Base
+_acquire__Q312connectivity4odbc15OStatement_Base
+__._Q312connectivity4odbc16OStatement_BASE2
+__._Q312connectivity4odbc10OStatement
+_setFetchSize__Q312connectivity4odbc15OStatement_Basel
+_setCursorName__Q312connectivity4odbc15OStatement_BaseRCQ23rtl8OUString
+_setMaxRows__Q312connectivity4odbc15OStatement_Basel
+_setMaxFieldSize__Q312connectivity4odbc15OStatement_Basel
+_setQueryTimeOut__Q312connectivity4odbc15OStatement_Basel
+_isUsingBookmarks__CQ312connectivity4odbc15OStatement_Base
+_getFetchSize__CQ312connectivity4odbc15OStatement_Base
+_getFetchDirection__CQ312connectivity4odbc15OStatement_Base
+_getResultSetType__CQ312connectivity4odbc15OStatement_Base
+_getResultSetConcurrency__CQ312connectivity4odbc15OStatement_Base
+_getCursorName__CQ312connectivity4odbc15OStatement_Base
+_getMaxRows__CQ312connectivity4odbc15OStatement_Base
+_getMaxFieldSize__CQ312connectivity4odbc15OStatement_Base
+_getQueryTimeOut__CQ312connectivity4odbc15OStatement_Base
+_getStmtOption__CQ312connectivity4odbc15OStatement_Bases
+_getRowCount__Q312connectivity4odbc15OStatement_Base
+_lockIfNecessary__Q312connectivity4odbc15OStatement_BaseRCQ23rtl8OUString
+_setWarning__Q312connectivity4odbc15OStatement_BaseRCQ53com3sun4star4sdbc10SQLWarning
+_disposeResultSet__Q312connectivity4odbc15OStatement_Base
+_getCharColAttrib__Q312connectivity4odbc18OResultSetMetaDatall
+_getNumColAttrib__Q312connectivity4odbc18OResultSetMetaDatall
+_getResultSetType__CQ312connectivity4odbc10OResultSet
+_getResultSetConcurrency__CQ312connectivity4odbc10OResultSet
+_getCursorName__CQ312connectivity4odbc10OResultSet
+_isBookmarkable__CQ312connectivity4odbc10OResultSet
+_setFetchSize__Q312connectivity4odbc10OResultSetl
+_setFetchDirection__Q312connectivity4odbc10OResultSetl
+_getFetchSize__CQ312connectivity4odbc10OResultSet
+_getFetchDirection__CQ312connectivity4odbc10OResultSet
+_fillRow__Q312connectivity4odbc10OResultSetl
+_releaseBuffer__Q312connectivity4odbc10OResultSet
+_allocBuffer__Q312connectivity4odbc10OResultSetUc
+_jdbcTypeToOdbc__Q312connectivity4odbc6OToolsl
+_getPropertySetInfo__Q312connectivity4odbc26ODatabaseMetaDataResultSet
+_release__Q312connectivity4odbc26ODatabaseMetaDataResultSet
+_acquire__Q312connectivity4odbc26ODatabaseMetaDataResultSet
+_openSpecialColumns__Q312connectivity4odbc26ODatabaseMetaDataResultSetUcRCQ53com3sun4star3uno3AnyRCQ23rtl8OUStringn1lUc
+_getResultSetType__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getResultSetConcurrency__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getCursorName__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getFetchSize__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getFetchDirection__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getSupportedServiceNames_Static__Q312connectivity4odbc10ODBCDriver
+_getImplementationName_Static__Q312connectivity4odbc10ODBCDriver
+_LoadFunctions__12connectivityP10_oslModuleUc
+_OpenConnection__Q312connectivity4odbc11OConnectionRCQ23rtl8OUStringlUc
+___tf13bad_exception
+___uncatch_exception
+___eh_free
+___tfv
+___dynamic_cast
diff --git a/connectivity/source/drivers/adabas/adabas.xcu b/connectivity/source/drivers/adabas/adabas.xcu
new file mode 100755
index 000000000000..0648d25cebe6
--- /dev/null
+++ b/connectivity/source/drivers/adabas/adabas.xcu
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DataAccess.xcu,v $
+ * $Revision: 1.27 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:adabas:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbcx.adabas.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Adabas D</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="ShutdownDatabase" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="DataCacheSizeIncrement" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>20</value>
+ </prop>
+ </node>
+ <node oor:name="DataCacheSize" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>20</value>
+ </prop>
+ </node>
+ <node oor:name="ControlUser" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="ControlPassword" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AppendTableAliasInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/adabas/adabas.xml b/connectivity/source/drivers/adabas/adabas.xml
new file mode 100644
index 000000000000..ce1b0f84755b
--- /dev/null
+++ b/connectivity/source/drivers/adabas/adabas.xml
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>adabas</module-name>
+ <component-description>
+ <author>Ocke Janssen</Author>
+ <name>com.sun.star.comp.sdbcx.adabas.ODriver</name>
+ <description>
+ This is the implementation of the sdbc-adabas bridge.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/adabas/exports.dxp b/connectivity/source/drivers/adabas/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/adabas/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/adabas/makefile.mk b/connectivity/source/drivers/adabas/makefile.mk
new file mode 100644
index 000000000000..5b3483ed57bb
--- /dev/null
+++ b/connectivity/source/drivers/adabas/makefile.mk
@@ -0,0 +1,110 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.30 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=adabas
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+.IF "$(SYSTEM_ODBC_HEADERS)" == "YES"
+CFLAGS+=-DSYSTEM_ODBC_HEADERS
+.ENDIF
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/BFunctions.obj \
+ $(SLO)$/BConnection.obj \
+ $(SLO)$/BDriver.obj \
+ $(SLO)$/BCatalog.obj \
+ $(SLO)$/BGroups.obj \
+ $(SLO)$/BGroup.obj \
+ $(SLO)$/BUser.obj \
+ $(SLO)$/BUsers.obj \
+ $(SLO)$/BKeys.obj \
+ $(SLO)$/BColumns.obj \
+ $(SLO)$/BIndex.obj \
+ $(SLO)$/BIndexColumns.obj \
+ $(SLO)$/BIndexes.obj \
+ $(SLO)$/BTable.obj \
+ $(SLO)$/BTables.obj \
+ $(SLO)$/BViews.obj \
+ $(SLO)$/Bservices.obj \
+ $(SLO)$/BDatabaseMetaData.obj \
+ $(SLO)$/BPreparedStatement.obj \
+ $(SLO)$/BStatement.obj \
+ $(SLO)$/BResultSetMetaData.obj \
+ $(SLO)$/BResultSet.obj
+
+SHL1VERSIONMAP=$(TARGET).map
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(ODBCBASELIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(ODBCBASELIB)" == ""
+SHL1STDLIBS+=$(ODBCBASELIB)
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ----------------------------------
+
+
+.INCLUDE : $(PRJ)$/target.pmk