Commits

Anonymous committed e0bf3fa

CWS-TOOLING: integrate CWS dbaperf3
2009-08-28 08:04:41 +0200 oj r275515 : wrong replacement
2009-08-28 07:57:44 +0200 oj r275514 : declaration of 'nRealSize' shadows a previous local
2009-08-20 10:17:11 +0200 oj r275168 : CWS-TOOLING: rebase CWS dbaperf3 to trunk@275001 (milestone: DEV300:m55)
2009-08-19 11:50:49 +0200 oj r275145 : #ii102891# minimize metadata calls
2009-06-22 12:20:15 +0200 oj r273213 : compile error
2009-06-22 12:19:45 +0200 oj r273212 : compile error
2009-06-18 08:54:08 +0200 oj r273099 : #i102891# reduce calls to databasemetadata
2009-06-18 08:19:55 +0200 oj r273095 : #i102891# reduce calls to databasemetadata

Comments (0)

Files changed (85)

connectivity/inc/connectivity/TTableHelper.hxx

 
 namespace connectivity
 {
+    typedef sal_Int32   OrdinalPosition;
+    struct ColumnDesc
+    {
+        ::rtl::OUString sName;
+        ::rtl::OUString aField6;
+        ::rtl::OUString sField13;
+        sal_Int32		nField5        
+		            ,   nField7
+					,	nField9
+					,	nField11;
+		
+        OrdinalPosition nOrdinalPosition;
+
+        ColumnDesc() {}
+        ColumnDesc( const ::rtl::OUString& _rName
+            , sal_Int32		_nField5
+            , const ::rtl::OUString& _aField6
+			, sal_Int32		_nField7
+			, sal_Int32		_nField9
+			, sal_Int32		_nField11
+			, const ::rtl::OUString& _sField13
+            ,OrdinalPosition _nPosition )
+            :sName( _rName )
+            ,aField6(_aField6)
+            ,sField13(_sField13)
+            ,nField5(_nField5)            
+            ,nField7(_nField7)
+            ,nField9(_nField9)
+            ,nField11(_nField11)            
+            ,nOrdinalPosition( _nPosition )
+        {
+        }
+    };
 	typedef connectivity::sdbcx::OTable OTable_TYPEDEF;
 
     OOO_DLLPUBLIC_DBTOOLS ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
 
     DECLARE_STL_USTRINGACCESS_MAP( sdbcx::TKeyProperties , TKeyMap);
 
+    struct OTableHelperImpl;
+
 	class OOO_DLLPUBLIC_DBTOOLS OTableHelper : public OTable_TYPEDEF
 	{
-        TKeyMap  m_aKeys;
-        ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >	m_xMetaData;
-		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >			m_xConnection;
+        ::std::auto_ptr<OTableHelperImpl> m_pImpl;
 
 		void refreshPrimaryKeys(TStringVector& _rKeys);
 		void refreshForgeinKeys(TStringVector& _rKeys);
         */
         virtual ::rtl::OUString getRenameStart() const;
 
+		virtual ~OTableHelper();
+
 	public:
 		virtual void refreshColumns();
 		virtual void refreshKeys();
 		virtual void refreshIndexes();
 
+        const ColumnDesc* getColumnDescription(const ::rtl::OUString& _sName) const;
+
 	public:
 		OTableHelper(	sdbcx::OCollection* _pTables,
 						const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
 			);
 
 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() const;
-		inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const { return m_xConnection; }
+		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() const;
 
 		virtual void SAL_CALL acquire() throw();
         virtual void SAL_CALL release() throw();

connectivity/inc/connectivity/sdbcx/VKey.hxx

 
         struct OOO_DLLPUBLIC_DBTOOLS KeyProperties
         {
+            ::std::vector< ::rtl::OUString> m_aKeyColumnNames;
 			::rtl::OUString m_ReferencedTable;
 			sal_Int32		m_Type;
 			sal_Int32		m_UpdateRule;

connectivity/inc/connectivity/sdbcx/VView.hxx

 #include "connectivity/sdbcx/VDescriptor.hxx"
 #include "connectivity/dbtoolsdllapi.hxx"
 #include <comphelper/IdPropArrayHelper.hxx>
+#include <cppuhelper/implbase2.hxx>
 
 namespace connectivity
 {
 	namespace sdbcx
 	{
 
-		typedef ::cppu::OWeakObject OView_BASE;
+        typedef ::cppu::WeakImplHelper2<    ::com::sun::star::lang::XServiceInfo,
+							            ::com::sun::star::container::XNamed> OView_BASE;
 
 
-		class OOO_DLLPUBLIC_DBTOOLS OViewHelper
-		{
-		protected:
-			::osl::Mutex			 m_aMutex;
-			::cppu::OBroadcastHelper rBHelper;
-
-		public:
-			OViewHelper(): rBHelper(m_aMutex){}
-		};
 
 		class OOO_DLLPUBLIC_DBTOOLS OView :
-                        public OViewHelper,
+                        public ::comphelper::OMutexAndBroadcastHelper,
 						public OView_BASE,
-						public ::com::sun::star::container::XNamed,
-                        public ::com::sun::star::lang::XServiceInfo,
 						public ::comphelper::OIdPropertyArrayUsageHelper<OView>,
 						public ODescriptor
 		{

connectivity/inc/connectivity/sqlnode.hxx

 		static sal_Bool getTableComponents(const OSQLParseNode* _pTableNode,
 											::com::sun::star::uno::Any &_rCatalog,
 											::rtl::OUString &_rSchema,
-											::rtl::OUString &_rTable);
+											::rtl::OUString &_rTable
+                                            ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _xMetaData);
 
 		// susbtitute all occurences of :var or [name] into the dynamic parameter ?
 		// _pNode will be modified if parameters exists

connectivity/source/commontools/ConnectionWrapper.cxx

 // -----------------------------------------------------------------------------
 void OConnectionWrapper::disposing()
 {
-	m_xConnection = NULL;
+m_xConnection.clear();
 }
 //-----------------------------------------------------------------------------
 OConnectionWrapper::~OConnectionWrapper()

connectivity/source/commontools/DateConversion.cxx

 #include "TConnection.hxx"
 #include "diagnose_ex.h"
 #include <comphelper/numbers.hxx>
+#include <rtl/ustrbuf.hxx>
 
 
 using namespace ::connectivity;
 ::rtl::OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, sal_Bool bQuote,
 											  const Reference< XTypeConverter >&  _rxTypeConverter)
 {
-	::rtl::OUString aRet;
+	::rtl::OUStringBuffer aRet;
 	if (_rVal.hasValue())
 	{
 		try
 					if (_rVal.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_BOOLEAN)
 					{
 						if (::cppu::any2bool(_rVal))
-							aRet = ::rtl::OUString::createFromAscii("1");
+							aRet.appendAscii("1");
 						else
-							aRet = ::rtl::OUString::createFromAscii("0");
+							aRet.appendAscii("0");
 					}
 					else
-						_rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aRet;
+                    {
+                        ::rtl::OUString sTemp;
+					    _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp;
+                        aRet.append(sTemp);
+                    }
 					break;
 				case DataType::CHAR:
 				case DataType::VARCHAR:
                 case DataType::LONGVARCHAR:
 					if (bQuote)
-						aRet += ::rtl::OUString::createFromAscii("'");
+						aRet.appendAscii("'");
 					{
 						::rtl::OUString aTemp;
 						_rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp;
 								aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(),sQuotToReplace);
 						} while (nIndex != -1);
 
-						aRet += aTemp;
+						aRet.append(aTemp);
 					}
 					if (bQuote)
-						aRet += ::rtl::OUString::createFromAscii("'");
+						aRet.appendAscii("'");
 					break;
 				case DataType::REAL:
 				case DataType::DOUBLE:
 				case DataType::DECIMAL:
 				case DataType::NUMERIC:
 				case DataType::BIGINT:
-					_rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aRet;
+                default:
+                    {
+                        ::rtl::OUString sTemp;
+					    _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= sTemp;
+                        aRet.append(sTemp);
+                    }
 					break;
 				case DataType::TIMESTAMP:
 				{
 					// check if this is really a timestamp or only a date
 					if ( _rVal >>= aDateTime )
 					{
-						if (bQuote) aRet += ::rtl::OUString::createFromAscii("{TS '");
-						aRet += DBTypeConversion::toDateTimeString(aDateTime);
-						if (bQuote) aRet += ::rtl::OUString::createFromAscii("'}");
+						if (bQuote) 
+                            aRet.appendAscii("{TS '");
+						aRet.append(DBTypeConversion::toDateTimeString(aDateTime));
+						if (bQuote) 
+                            aRet.appendAscii("'}");
 						break;
 					}
 					break;
 				{
 					Date aDate;
                     OSL_VERIFY_RES( _rVal >>= aDate, "DBTypeConversion::toSQLString: _rVal is not date!");
-					if (bQuote) aRet += ::rtl::OUString::createFromAscii("{D '");
-					aRet += DBTypeConversion::toDateString(aDate);;
-					if (bQuote) aRet += ::rtl::OUString::createFromAscii("'}");
+					if (bQuote) 
+                        aRet.appendAscii("{D '");
+					aRet.append(DBTypeConversion::toDateString(aDate));
+					if (bQuote) 
+                        aRet.appendAscii("'}");
 				}	break;
 				case DataType::TIME:
 				{
 					Time aTime;
                     OSL_VERIFY_RES( _rVal >>= aTime,"DBTypeConversion::toSQLString: _rVal is not time!");
-					if (bQuote) aRet += ::rtl::OUString::createFromAscii("{T '");
-					aRet += DBTypeConversion::toTimeString(aTime);
-					if (bQuote) aRet += ::rtl::OUString::createFromAscii("'}");
+					if (bQuote) 
+                        aRet.appendAscii("{T '");
+					aRet.append(DBTypeConversion::toTimeString(aTime));
+					if (bQuote) 
+                        aRet.appendAscii("'}");
 				} break;
-				default:
-					_rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aRet;
 			}
 		}
 		catch ( const Exception&  )
 		}
 	}
 	else
-		aRet = ::rtl::OUString::createFromAscii(" NULL ");
-	return aRet;
+		aRet.appendAscii(" NULL ");
+	return aRet.makeStringAndClear();
 }
 // -----------------------------------------------------------------------------
 Date DBTypeConversion::getNULLDate(const Reference< XNumberFormatsSupplier > &xSupplier)

connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx

 
 	::osl::MutexGuard aGuard(m_aMutex);
 	m_aStatement	= NULL;
-	m_xMetaData		= NULL;
+m_xMetaData.clear();
 	m_aRowsIter = m_aRows.end();
 	m_aRows.clear();
 	m_aRowsIter = m_aRows.end();

connectivity/source/commontools/TColumnsHelper.cxx

 #include <com/sun/star/sdbc/XResultSet.hpp>
 #include <com/sun/star/sdbc/DataType.hpp>
 #include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
 #include <comphelper/types.hxx>
 #include "connectivity/dbtools.hxx"
 #include "TConnection.hxx"
 using namespace dbtools;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::beans;
-//	using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbcx;
 using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::lang;
 		bAutoIncrement	= aFind->second.first.first;
 		bIsCurrency		= aFind->second.first.second;
 		nDataType		= aFind->second.second;
-	}
-	
+	} // if ( aFind != m_pImpl->m_aColumnInfo.end() )
 
-	sdbcx::ObjectType xRet(::dbtools::createSDBCXColumn(	m_pTable,
-															xConnection,
-															_rName,
-															isCaseSensitive(),
-															bQueryInfo,
-															bAutoIncrement,
-															bIsCurrency,
-															nDataType),UNO_QUERY);
+    sdbcx::ObjectType xRet;
+    const ColumnDesc* pColDesc = m_pTable->getColumnDescription(_rName);
+    if ( pColDesc )
+    {
+        Reference<XPropertySet> xPr = m_pTable;
+        Reference<XKeysSupplier> xKeysSup(xPr,UNO_QUERY);
+        Reference<XNameAccess> xPrimaryKeyColumns;
+        if ( xKeysSup.is() )
+        {
+            const Reference<XIndexAccess> xKeys = xKeysSup->getKeys();
+            if ( xKeys.is() )
+            {
+                ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+                const sal_Int32 nKeyCount = xKeys->getCount();
+                for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++nKeyIter)
+                {
+                    const Reference<XPropertySet> xKey(xKeys->getByIndex(nKeyIter),UNO_QUERY_THROW);
+                    sal_Int32 nType = 0;
+                    xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE))	>>= nType;
+                    if ( nType == KeyType::PRIMARY )
+                    {
+                        const Reference<XColumnsSupplier> xColS(xKey,UNO_QUERY_THROW);
+                        xPrimaryKeyColumns = xColS->getColumns();
+                        break;
+                    }
+                } // for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++)
+            }
+        }
+        sal_Int32 nField11 = pColDesc->nField11;
+        if ( nField11 != ColumnValue::NO_NULLS && xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(_rName) )
+        {
+            nField11 = ColumnValue::NO_NULLS;
+        } // if ( xKeys.is() )
+        connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName,
+												pColDesc->aField6,
+												pColDesc->sField13,
+												nField11,
+												pColDesc->nField7,
+												pColDesc->nField9,
+												pColDesc->nField5,
+												bAutoIncrement,
+												sal_False,
+												bIsCurrency,
+												isCaseSensitive());
+
+		xRet = pRet;
+    }
+    else
+    {
+
+	    xRet.set(::dbtools::createSDBCXColumn(	m_pTable,
+											    xConnection,
+											    _rName,
+											    isCaseSensitive(),
+											    bQueryInfo,
+											    bAutoIncrement,
+											    bIsCurrency,
+											    nDataType),UNO_QUERY);
+    }
 	return xRet;
 }
 

connectivity/source/commontools/TDatabaseMetaDataBase.cxx

 void SAL_CALL ODatabaseMetaDataBase::disposing( const EventObject& /*Source*/ ) throw(RuntimeException)
 {
 	// cut off all references to the connection
-	m_xConnection		= NULL;
-	m_xListenerHelper	= NULL;
+m_xConnection.clear();
+m_xListenerHelper.clear();
 }
 // -----------------------------------------------------------------------------
 Reference< XResultSet > SAL_CALL ODatabaseMetaDataBase::getTypeInfo(  ) throw(SQLException, RuntimeException)

connectivity/source/commontools/TIndexColumns.cxx

 		m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
 		aSchema,aTable,_rName);
 
-    sdbcx::ObjectType xRet = NULL;
+    sdbcx::ObjectType xRet;
 	if ( xResult.is() )
 	{
         Reference< XRow > xRow(xResult,UNO_QUERY);

connectivity/source/commontools/TIndexes.cxx

 			{
                 sal_Int32 nClustered = xRow->getShort(7);
                 sal_Bool bPrimarKeyIndex = sal_False;
-                xRow = NULL;
-                xResult = NULL;
+                xRow.clear();
+                xResult.clear();
                 try
                 {
                     xResult = m_pTable->getMetaData()->getPrimaryKeys(aCatalog,aSchema,aTable);

connectivity/source/commontools/TKey.cxx

 	::std::vector< ::rtl::OUString> aVector;
 	if ( !isNew() )
 	{
-		::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
-		::rtl::OUString aSchema,aTable;
-		m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME))	>>= aSchema;
-		m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))		>>= aTable;
+        aVector = m_aProps->m_aKeyColumnNames;
+        if ( aVector.empty() )
+		{
+		    ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+		    ::rtl::OUString aSchema,aTable;
+		    m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME))	>>= aSchema;
+		    m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))		>>= aTable;
 
-		if ( m_Name.getLength() ) // foreign key
-		{
+		    if ( m_Name.getLength() ) // foreign key
+		    {
 
-			Reference< XResultSet > xResult = m_pTable->getMetaData()->getImportedKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
-				aSchema,aTable);
+			    Reference< XResultSet > xResult = m_pTable->getMetaData()->getImportedKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+				    aSchema,aTable);
 
-			if ( xResult.is() )
-			{
-				Reference< XRow > xRow(xResult,UNO_QUERY);
-				while( xResult->next() )
-				{
-					::rtl::OUString aForeignKeyColumn = xRow->getString(8);
-					if(xRow->getString(12) == m_Name)
-						aVector.push_back(aForeignKeyColumn);
-				}
-			}
-		}
-		if ( aVector.empty() )
-		{
-			Reference< XResultSet > xResult = m_pTable->getMetaData()->getPrimaryKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
-				aSchema,aTable);
+			    if ( xResult.is() )
+			    {
+				    Reference< XRow > xRow(xResult,UNO_QUERY);
+				    while( xResult->next() )
+				    {
+					    ::rtl::OUString aForeignKeyColumn = xRow->getString(8);
+					    if(xRow->getString(12) == m_Name)
+						    aVector.push_back(aForeignKeyColumn);
+				    }
+			    }
+		    }
+		
+            if ( aVector.empty() )
+		    {
+			    const Reference< XResultSet > xResult = m_pTable->getMetaData()->getPrimaryKeys(m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
+				    aSchema,aTable);
 
-			if ( xResult.is() )
-			{
-				Reference< XRow > xRow(xResult,UNO_QUERY);
-				while( xResult->next() )
-					aVector.push_back(xRow->getString(4));
-			}
+			    if ( xResult.is() )
+			    {
+				    const Reference< XRow > xRow(xResult,UNO_QUERY);
+				    while( xResult->next() )
+					    aVector.push_back(xRow->getString(4));
+			    } // if ( xResult.is() )
+            }
 		}
 	}
 

connectivity/source/commontools/TPrivilegesResultSet.cxx

 void SAL_CALL OResultSetPrivileges::disposing(void)
 {
 	ODatabaseMetaDataResultSet::disposing();
-	m_xTables = NULL;
-	m_xRow = NULL;
+m_xTables.clear();
+m_xRow.clear();
 }
 // -----------------------------------------------------------------------------
 sal_Bool SAL_CALL OResultSetPrivileges::next(  ) throw(SQLException, RuntimeException)

connectivity/source/commontools/TTableHelper.cxx

 #include <cppuhelper/typeprovider.hxx>
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/implementationreference.hxx>
 #include <comphelper/sequence.hxx>
 #include <comphelper/extract.hxx>
 #include <comphelper/types.hxx>
 using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::lang;
+namespace
+{
+    /// helper class for column property change events which holds the OComponentDefinition weak
+typedef ::cppu::WeakImplHelper1	< XContainerListener > OTableContainerListener_BASE;
+class OTableContainerListener : public OTableContainerListener_BASE
+{
+    OTableHelper* m_pComponent;
+    ::std::map< ::rtl::OUString,bool> m_aRefNames;
+
+    OTableContainerListener(const OTableContainerListener&);
+    void operator =(const OTableContainerListener&);
+protected:
+    virtual ~OTableContainerListener(){}
+public:
+    OTableContainerListener(OTableHelper* _pComponent) : m_pComponent(_pComponent){}
+    virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) throw (RuntimeException)
+    {
+    }
+    virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (RuntimeException)
+    {
+        ::rtl::OUString sName;
+		Event.Accessor	>>= sName;
+        if ( m_aRefNames.find(sName) != m_aRefNames.end() )
+            m_pComponent->refreshKeys();
+    }
+    virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (RuntimeException)
+	{
+        ::rtl::OUString sOldComposedName,sNewComposedName;
+		Event.ReplacedElement	>>= sOldComposedName;
+		Event.Accessor			>>= sNewComposedName;
+        if ( sOldComposedName != sNewComposedName && m_aRefNames.find(sOldComposedName) != m_aRefNames.end() )
+            m_pComponent->refreshKeys();
+    }
+	// XEventListener
+	virtual void SAL_CALL disposing( const EventObject& /*_rSource*/ ) throw (RuntimeException)
+    {
+    }
+    void clear() { m_pComponent = NULL; }
+    inline void add(const ::rtl::OUString& _sRefName) { m_aRefNames.insert(::std::map< ::rtl::OUString,bool>::value_type(_sRefName,true)); }
+};
+}
+namespace connectivity
+{
+    struct OTableHelperImpl
+    {
+        TKeyMap  m_aKeys;
+        Reference< ::com::sun::star::sdbc::XDatabaseMetaData >	m_xMetaData;
+		Reference< ::com::sun::star::sdbc::XConnection >			m_xConnection;
+        ::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>   
+                                    m_xTablePropertyListener;
+        ::std::vector< ColumnDesc > m_aColumnDesc;
+    };
+}
 
 OTableHelper::OTableHelper(	sdbcx::OCollection* _pTables,
 						   const Reference< XConnection >& _xConnection,
 						   sal_Bool _bCase) 
 	:OTable_TYPEDEF(_pTables,_bCase)
-	,m_xConnection(_xConnection)
+    ,m_pImpl(new OTableHelperImpl)
 {
 	try
 	{
-		m_xMetaData = m_xConnection->getMetaData();
+        m_pImpl->m_xConnection = _xConnection;
+		m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
 	}
 	catch(const Exception&)
 	{
 										  _Description,
 										  _SchemaName,
 										  _CatalogName)
-						,m_xConnection(_xConnection)
+						,m_pImpl(new OTableHelperImpl)
 {
 	try
 	{
-		m_xMetaData = m_xConnection->getMetaData();
+		m_pImpl->m_xConnection = _xConnection;
+		m_pImpl->m_xMetaData = m_pImpl->m_xConnection->getMetaData();
 	}
 	catch(const Exception&)
 	{
 	}
 }
 // -----------------------------------------------------------------------------
+OTableHelper::~OTableHelper()
+{
+}
+// -----------------------------------------------------------------------------
 void SAL_CALL OTableHelper::disposing()
 {
+    ::osl::MutexGuard aGuard(m_aMutex);
+    if ( m_pImpl->m_xTablePropertyListener.is() )
+    {
+        m_pTables->removeContainerListener(m_pImpl->m_xTablePropertyListener.getRef());
+        m_pImpl->m_xTablePropertyListener->clear();
+        m_pImpl->m_xTablePropertyListener.dispose();
+    }
 	OTable_TYPEDEF::disposing();
-	::osl::MutexGuard aGuard(m_aMutex);
-	m_xConnection	= NULL;
-	m_xMetaData		= NULL;
+	
+	m_pImpl->m_xConnection	= NULL;
+	m_pImpl->m_xMetaData	= NULL;
+    
 }
 
 // -------------------------------------------------------------------------
 namespace
 {
-    typedef sal_Int32   OrdinalPosition;
-    struct ColumnDesc
-    {
-        ::rtl::OUString sName;
-        OrdinalPosition nOrdinalPosition;
-
-        ColumnDesc() {}
-        ColumnDesc( const ::rtl::OUString& _rName, OrdinalPosition _nPosition )
-            :sName( _rName )
-            ,nOrdinalPosition( _nPosition )
-        {
-        }
-    };
-
     /** collects ColumnDesc's from a resultset produced by XDatabaseMetaData::getColumns
     */
     void lcl_collectColumnDescs_throw( const Reference< XResultSet >& _rxResult, ::std::vector< ColumnDesc >& _out_rColumns )
 	    while ( _rxResult->next() )
         {
             sName = xRow->getString( 4 );           // COLUMN_NAME
+            sal_Int32		nField5	= xRow->getInt(5);
+			::rtl::OUString aField6 = xRow->getString(6);
+			sal_Int32		nField7 = xRow->getInt(7)
+						,	nField9 = xRow->getInt(9)
+						,	nField11= xRow->getInt(11);
+			::rtl::OUString sField13 = xRow->getString(13);
             nOrdinalPosition = xRow->getInt( 17 );  // ORDINAL_POSITION
-            _out_rColumns.push_back( ColumnDesc( sName, nOrdinalPosition ) );
+            _out_rColumns.push_back( ColumnDesc( sName,nField5,aField6,nField7,nField9,nField11,sField13, nOrdinalPosition ) );
         }
     }
 
         ) );
 
         // collect the column names, together with their ordinal position
-        ::std::vector< ColumnDesc > aColumns;
-        lcl_collectColumnDescs_throw( xResult, aColumns );
+        m_pImpl->m_aColumnDesc.clear();
+        lcl_collectColumnDescs_throw( xResult, m_pImpl->m_aColumnDesc );
 
         // ensure that the ordinal positions as obtained from the meta data do make sense
-        lcl_sanitizeColumnDescs( aColumns );
+        lcl_sanitizeColumnDescs( m_pImpl->m_aColumnDesc );
 
         // sort by ordinal position
         ::std::map< OrdinalPosition, ::rtl::OUString > aSortedColumns;
-        for (   ::std::vector< ColumnDesc >::const_iterator copy = aColumns.begin();
-                copy != aColumns.end();
+        for (   ::std::vector< ColumnDesc >::const_iterator copy = m_pImpl->m_aColumnDesc.begin();
+                copy != m_pImpl->m_aColumnDesc.end();
                 ++copy
             )
             aSortedColumns[ copy->nOrdinalPosition ] = copy->sName;
 	else
 		m_pColumns	= createColumns(aVector);
 }
+// -----------------------------------------------------------------------------
+const ColumnDesc* OTableHelper::getColumnDescription(const ::rtl::OUString& _sName) const
+{
+    const ColumnDesc* pRet = NULL;
+    ::std::vector< ColumnDesc >::const_iterator aEnd = m_pImpl->m_aColumnDesc.end();
+    for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter)
+    {
+        if ( aIter->sName == _sName )
+        {
+            pRet = &*aIter;
+            break;
+        }
+    } // for (::std::vector< ColumnDesc >::const_iterator aIter = m_pImpl->m_aColumnDesc.begin();aIter != aEnd;++aIter)
+    return pRet;
+}
 // -------------------------------------------------------------------------
 void OTableHelper::refreshPrimaryKeys(TStringVector& _rNames)
 {
 		aCatalog <<= m_CatalogName;
     Reference< XResultSet > xResult = getMetaData()->getPrimaryKeys(aCatalog,m_SchemaName,m_Name);
 
-	if ( xResult.is() && xResult->next() )
+	if ( xResult.is() )
 	{
-        Reference< XRow > xRow(xResult,UNO_QUERY);
-		const ::rtl::OUString aPkName = xRow->getString(6);
-        m_aKeys.insert(TKeyMap::value_type(aPkName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(::rtl::OUString(),KeyType::PRIMARY,0,0))));
+        sdbcx::TKeyProperties pKeyProps(new sdbcx::KeyProperties(::rtl::OUString(),KeyType::PRIMARY,0,0));
+        ::rtl::OUString aPkName;
+        bool bAlreadyFetched = false;
+        const Reference< XRow > xRow(xResult,UNO_QUERY);
+        while ( xResult->next() )
+        {
+            pKeyProps->m_aKeyColumnNames.push_back(xRow->getString(4));
+            if ( !bAlreadyFetched )
+            {
+		        aPkName = xRow->getString(6);
+                bAlreadyFetched = true;
+            }
+        }
+        
+        m_pImpl->m_aKeys.insert(TKeyMap::value_type(aPkName,pKeyProps));
         _rNames.push_back(aPkName);
-		::comphelper::disposeComponent(xResult);
-	}
+	} // if ( xResult.is() && xResult->next() )
+    ::comphelper::disposeComponent(xResult);
 }
 // -------------------------------------------------------------------------
 void OTableHelper::refreshForgeinKeys(TStringVector& _rNames)
 
 	if ( xRow.is() )
 	{
-        ::rtl::OUString aName,sCatalog,aSchema;
+        sdbcx::TKeyProperties pKeyProps;
+        ::rtl::OUString aName,sCatalog,aSchema,sOldFKName;
 		while( xResult->next() )
 		{
             // this must be outsid the "if" because we have to call in a right order
 			aSchema		= xRow->getString(2);
 			aName		= xRow->getString(3);
 
-            const sal_Int32 nKeySeq = xRow->getInt(9);
+            const ::rtl::OUString sForeignKeyColumn = xRow->getString(8);
 			const sal_Int32 nUpdateRule = xRow->getInt(10);
 			const sal_Int32 nDeleteRule = xRow->getInt(11);
+            const ::rtl::OUString sFkName = xRow->getString(12);
 			
-			if ( nKeySeq == 1 )
-			{ // only append when the sequnce number is 1 to forbid serveral inserting the same key name
-				const ::rtl::OUString sFkName = xRow->getString(12);
-				if ( sFkName.getLength() && !xRow->wasNull() )
+                if ( pKeyProps.get() )
                 {
-                    ::rtl::OUString sReferencedName;
-					sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,sal_False,::dbtools::eInDataManipulation);
-                    m_aKeys.insert(TKeyMap::value_type(sFkName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(sReferencedName,KeyType::FOREIGN,nUpdateRule,nDeleteRule))));
+                }
+                
+				
+			if ( sFkName.getLength() && !xRow->wasNull() )
+            {
+                if ( sOldFKName != sFkName )
+                {
+                    if ( pKeyProps.get() )
+                        m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps));
+
+                    const ::rtl::OUString sReferencedName = ::dbtools::composeTableName(getMetaData(),sCatalog,aSchema,aName,sal_False,::dbtools::eInDataManipulation);
+                    pKeyProps.reset(new sdbcx::KeyProperties(sReferencedName,KeyType::FOREIGN,nUpdateRule,nDeleteRule));
+                    pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);                    
                     _rNames.push_back(sFkName);
+                    if ( m_pTables->hasByName(sReferencedName) )
+                    {
+                        if ( !m_pImpl->m_xTablePropertyListener.is() )
+                            m_pImpl->m_xTablePropertyListener = ::comphelper::ImplementationReference< OTableContainerListener,XContainerListener>( new OTableContainerListener(this) );
+                        m_pTables->addContainerListener(m_pImpl->m_xTablePropertyListener.getRef());
+                        m_pImpl->m_xTablePropertyListener->add(sReferencedName);
+                    } // if ( m_pTables->hasByName(sReferencedName) )
+                    sOldFKName = sFkName;
+                } // if ( sOldFKName != sFkName )
+                else if ( pKeyProps.get() )
+                {
+                    pKeyProps->m_aKeyColumnNames.push_back(sForeignKeyColumn);
                 }
-			}
-		}
+            }
+		} // while( xResult->next() )
+        if ( pKeyProps.get() )
+            m_pImpl->m_aKeys.insert(TKeyMap::value_type(sOldFKName,pKeyProps));
 		::comphelper::disposeComponent(xResult);
 	}
 }
 // -------------------------------------------------------------------------
 void OTableHelper::refreshKeys()
 {
-	m_aKeys.clear();
+	m_pImpl->m_aKeys.clear();
 
     TStringVector aNames;
 
 		sComposedName = ::dbtools::composeTableName(getMetaData(),sCatalog,sSchema,sTable,sal_True,::dbtools::eInDataManipulation);
 		sSql += sComposedName;
 
-		Reference< XStatement > xStmt = m_xConnection->createStatement(  );
+		Reference< XStatement > xStmt = m_pImpl->m_xConnection->createStatement(  );
 		if ( xStmt.is() )
 		{
 			xStmt->execute(sSql);
 // -----------------------------------------------------------------------------
 Reference< XDatabaseMetaData> OTableHelper::getMetaData() const 
 { 
-	return m_xMetaData; 
+	return m_pImpl->m_xMetaData; 
 }
 // -------------------------------------------------------------------------
 void SAL_CALL OTableHelper::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
 sdbcx::TKeyProperties OTableHelper::getKeyProperties(const ::rtl::OUString& _sName) const
 {
     sdbcx::TKeyProperties pKeyProps;
-    TKeyMap::const_iterator aFind = m_aKeys.find(_sName);
-    if ( aFind != m_aKeys.end() )
+    TKeyMap::const_iterator aFind = m_pImpl->m_aKeys.find(_sName);
+    if ( aFind != m_pImpl->m_aKeys.end() )
     {
         pKeyProps = aFind->second;
     }
 // -----------------------------------------------------------------------------
 void OTableHelper::addKey(const ::rtl::OUString& _sName,const sdbcx::TKeyProperties& _aKeyProperties)
 {
-    m_aKeys.insert(TKeyMap::value_type(_sName,_aKeyProperties));
+    m_pImpl->m_aKeys.insert(TKeyMap::value_type(_sName,_aKeyProperties));
 }
 // -----------------------------------------------------------------------------
 ::rtl::OUString OTableHelper::getTypeCreatePattern() const
     return ::rtl::OUString();
 }
 // -----------------------------------------------------------------------------
-
+Reference< XConnection> OTableHelper::getConnection() const 
+{ 
+    return m_pImpl->m_xConnection; 
+}

connectivity/source/commontools/dbconversion.cxx

         ::rtl::OUStringBuffer aTemp(toDateString(aDate));
         aTemp.appendAscii(" ");
         Time aTime(0,_rDateTime.Seconds,_rDateTime.Minutes,_rDateTime.Hours);
-        aTemp.append(toTimeString(aTime));
+        aTemp.append( toTimeString(aTime) );
         aTemp.appendAscii(".");
-        aTemp.append(static_cast<sal_Int32>(_rDateTime.HundredthSeconds));
+        aTemp.append( static_cast<sal_Int32>(_rDateTime.HundredthSeconds));
         return  aTemp.makeStringAndClear();
     }
     //------------------------------------------------------------------------------

connectivity/source/commontools/dbmetadata.cxx

             const DatabaseMetaData_Impl& _metaData, ::boost::optional< ::rtl::OUString >& _cachedSetting,
             ::rtl::OUString (SAL_CALL XDatabaseMetaData::*_getter)() )
         {
-            lcl_checkConnected( _metaData );
-
             if ( !_cachedSetting )
             {
+                lcl_checkConnected( _metaData );
                 try
                 {
                     _cachedSetting.reset( (_metaData.xConnectionMetaData.get()->*_getter)() );

connectivity/source/commontools/dbtools.cxx

         return ::rtl::OUString();
 	OSL_ENSURE(_rName.getLength(), "impl_doComposeTableName : at least the name should be non-empty !");
 
-	::rtl::OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
-
-    NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
+	const ::rtl::OUString sQuoteString = _rxMetaData->getIdentifierQuoteString();
+    const NameComponentSupport aNameComps( lcl_getNameComponentSupport( _rxMetaData, _eComposeRule ) );
 
     ::rtl::OUStringBuffer aComposedName;
 

connectivity/source/commontools/dbtools2.cxx

 }
 namespace 
 {
-	Reference<XPropertySet> lcl_createSDBCXColumn(
+	Reference<XPropertySet> lcl_createSDBCXColumn(const Reference<XNameAccess>& _xPrimaryKeyColumns,
 										  const Reference<XConnection>& _xConnection,
 										  const Any& _aCatalog,
 										  const ::rtl::OUString& _aSchema,
 						const ::rtl::OUString sQuote = xMetaData->getIdentifierQuoteString();
 						::rtl::OUString sQuotedName  = ::dbtools::quoteName(sQuote,_rName);
 						::rtl::OUString sComposedName;
-						sComposedName = composeTableNameForSelect(
-                            _xConnection, getString( _aCatalog ), _aSchema, _aTable );
+						sComposedName = composeTableNameForSelect(_xConnection, getString( _aCatalog ), _aSchema, _aTable );
 
 						ColumnInformationMap aInfo(_bCase);
 						collectColumnInformation(_xConnection,sComposedName,sQuotedName,aInfo);
 					{
 						try
 						{
-							Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable );
-                            Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW );
-                            while( xPKeys->next() ) // there can be only one primary key
-								{
-                                ::rtl::OUString sKeyColumn = xPKeyRow->getString(4);
-									if ( aMixCompare(_rName,sKeyColumn) )
-									{
-										nField11 = ColumnValue::NO_NULLS;
-										break;
-									}
-								}
+                            if ( _xPrimaryKeyColumns.is() )
+                            {
+                                if ( _xPrimaryKeyColumns->hasByName(_rName) )
+                                    nField11 = ColumnValue::NO_NULLS;
+                                
+                            }
+                            else
+                            {
+							    Reference< XResultSet > xPKeys = xMetaData->getPrimaryKeys( _aCatalog, _aSchema, _aTable );
+                                Reference< XRow > xPKeyRow( xPKeys, UNO_QUERY_THROW );
+                                while( xPKeys->next() ) // there can be only one primary key
+							    {
+                                    ::rtl::OUString sKeyColumn = xPKeyRow->getString(4);
+								    if ( aMixCompare(_rName,sKeyColumn) )
+								    {
+									    nField11 = ColumnValue::NO_NULLS;
+									    break;
+								    }
+							    }
 							}
+                        }
 						catch(SQLException&)
 						{
                             OSL_ENSURE( false, "lcl_createSDBCXColumn: caught an exception!" );
 	_xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME))	>>= aSchema;
 	_xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))		>>= aTable;
 
-	xProp = lcl_createSDBCXColumn(_xConnection,aCatalog, aSchema, aTable, _rName,_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
+    Reference<XKeysSupplier> xKeysSup(_xTable,UNO_QUERY);
+    Reference<XNameAccess> xPrimaryKeyColumns;
+    if ( xKeysSup.is() )
+    {
+        const Reference<XIndexAccess> xKeys = xKeysSup->getKeys();
+        if ( xKeys.is() )
+        {
+            const sal_Int32 nKeyCount = xKeys->getCount();
+            for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++nKeyIter)
+            {
+                const Reference<XPropertySet> xKey(xKeys->getByIndex(nKeyIter),UNO_QUERY_THROW);
+                sal_Int32 nType = 0;
+                xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE))	>>= nType;
+                if ( nType == KeyType::PRIMARY )
+                {
+                    const Reference<XColumnsSupplier> xColS(xKey,UNO_QUERY_THROW);
+                    xPrimaryKeyColumns = xColS->getColumns();
+                    break;
+                }
+            } // for(sal_Int32 nKeyIter = 0; nKeyIter < nKeyCount;++)
+        }
+    }
+
+	xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, _rName,_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
 	if ( !xProp.is() )
 	{
-		xProp = lcl_createSDBCXColumn(_xConnection,aCatalog, aSchema, aTable, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
+		xProp = lcl_createSDBCXColumn(xPrimaryKeyColumns,_xConnection,aCatalog, aSchema, aTable, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),_rName,_bCase,_bQueryForInfo,_bIsAutoIncrement,_bIsCurrency,_nDataType);
 		if ( !xProp.is() )
 			xProp = new connectivity::sdbcx::OColumn(_rName,
 												::rtl::OUString(),::rtl::OUString(),

connectivity/source/commontools/parameters.cxx

     //--------------------------------------------------------------------
     void ParameterManager::clearAllParameterInformation()
     {
-        m_xInnerParamColumns = NULL;
+       m_xInnerParamColumns.clear();
         if ( m_pOuterParameters.is() )
             m_pOuterParameters->dispose();
         m_pOuterParameters   = NULL;

connectivity/source/cpool/ZConnectionPool.cxx

 	if (xProp.is())
 		xProp->removePropertyChangeListener(getTimeoutNodeName(),this);
 
-	m_xDriverNode	= NULL;
-	m_xDriver		= NULL;
+m_xDriverNode.clear();
+m_xDriver.clear();
 }
 //--------------------------------------------------------------------------
 Reference< XConnection > SAL_CALL OConnectionPool::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException)
 	}
 	else
 	{
-		m_xDriverNode = NULL;
+	m_xDriverNode.clear();
 	}
 }
 // -----------------------------------------------------------------------------

connectivity/source/cpool/ZPoolCollection.cxx

 			{
 				if ( xProp.is() )
 					xProp->removePropertyChangeListener(getEnablePoolingNodeName(),this);
-				m_xConfigNode = NULL;
+			m_xConfigNode.clear();
 			}
 			else if ( xProp.is() )
 				xProp->removePropertyChangeListener(getEnableNodeName(),this);
 	clearConnectionPools(sal_True);
 	if ( m_xDesktop.is() )
 		m_xDesktop->removeTerminateListener(this);
-	m_xDesktop = NULL;
+m_xDesktop.clear();
 }
 // -----------------------------------------------------------------------------
 

connectivity/source/cpool/ZPooledConnection.cxx

 	MutexGuard aGuard(m_aMutex);
 	if (m_xComponent.is())
 		m_xComponent->removeEventListener(this);
-	m_xComponent = NULL;
+m_xComponent.clear();
 	::comphelper::disposeComponent(m_xRealConnection);
 }
 // -----------------------------------------------------------------------------
 // XEventListener
 void SAL_CALL OPooledConnection::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
 {
-	m_xComponent = NULL;
+m_xComponent.clear();
 }
 // -----------------------------------------------------------------------------
 //XPooledConnection 

connectivity/source/drivers/adabas/BConnection.cxx

 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
 
-	if(m_aTypeInfo.empty())
-		buildTypeInfo();
-
-	Reference< XPreparedStatement > xReturn = new OAdabasPreparedStatement(this,m_aTypeInfo,sql);
+	Reference< XPreparedStatement > xReturn = new OAdabasPreparedStatement(this,sql);
 	m_aStatements.push_back(WeakReferenceHelper(xReturn));
 	return xReturn;
 }

connectivity/source/drivers/adabas/BDriver.cxx

 				}
 			}
 		}
-		m_xORB = NULL;
+	m_xORB.clear();
 	}
 }
 // --------------------------------------------------------------------------------

connectivity/source/drivers/adabas/BPreparedStatement.cxx

 using namespace com::sun::star::io;
 using namespace com::sun::star::util;
 
-OAdabasPreparedStatement::OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::std::vector<OTypeInfo>& _TypeInfo,const ::rtl::OUString& sql) 
-: ::connectivity::odbc::OPreparedStatement( _pConnection,_TypeInfo,sql)
+OAdabasPreparedStatement::OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::rtl::OUString& sql) 
+: ::connectivity::odbc::OPreparedStatement( _pConnection,sql)
 {
 	m_aSelectColumns = _pConnection->createSelectColumns(sql);
 }

connectivity/source/drivers/adabas/BTables.cxx

 // -------------------------------------------------------------------------
 void OTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -------------------------------------------------------------------------

connectivity/source/drivers/adabas/BViews.cxx

 // -------------------------------------------------------------------------
 void OViews::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -------------------------------------------------------------------------

connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx

 	if(m_pRecordSet)
 		m_pRecordSet->Close();
 	m_aStatement	= NULL;
-	m_xMetaData		= NULL;
+m_xMetaData.clear();
 }
 // -------------------------------------------------------------------------
 Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException)

connectivity/source/drivers/ado/ADriver.cxx

 #include <com/sun/star/lang/DisposedException.hpp>
 #include "connectivity/dbexception.hxx"
 #include "resource/ado_res.hrc"
+#include <Objbase.h>
+
 
 #include "resource/sharedresources.hxx"
 
 	: ODriver_BASE(m_aMutex)
 	,m_xORB(_xORB)
 {
-	CoInitialize(NULL);
+     if ( FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) )
+     {
+         CoUninitialize();
+         int h = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+         (void)h;
+         ++h;
+     }
 }
 // -------------------------------------------------------------------------
 ODriver::~ODriver()
 {
 	CoUninitialize();
+    CoInitialize(NULL);
 }
 //------------------------------------------------------------------------------
 void ODriver::disposing()

connectivity/source/drivers/ado/APreparedStatement.cxx

 // -------------------------------------------------------------------------
 void OPreparedStatement::disposing()
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	if (m_pParameters)
 	{
 		m_pParameters->Release();
 
 
 	// first clear the old things
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	disposeResultSet();
 	if(m_RecordSet.IsValid())
 		m_RecordSet.Close();

connectivity/source/drivers/ado/AResultSet.cxx

 	::osl::MutexGuard aGuard(m_aMutex);
 	if(m_pRecordSet)
 		m_pRecordSet->Close();
-	m_xStatement	= NULL;
-	m_xMetaData		= NULL;
+m_xStatement.clear();
+m_xMetaData.clear();
 }
 // -------------------------------------------------------------------------
 Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)

connectivity/source/drivers/ado/Aservices.cxx

 				uno_Environment	** /*ppEnv*/
 			)
 {
-	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine";
 }
 
 //---------------------------------------------------------------------------------------
 	}
 	catch (::com::sun::star::registry::InvalidRegistryException& )
 	{
-		OSL_ENSURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+		OSL_ENSURE(sal_False, "ADO::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
 	}
 
 	return sal_False;

connectivity/source/drivers/dbase/DTable.cxx

 						m_pColumns->getByIndex(i) >>= xCol;
 						OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
 						xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
-						xCol = NULL;
+						xCol.clear();
 					} // if ( !aColName.getLength() )
                     const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
                             STR_DUPLICATE_VALUE_IN_COLUMN

connectivity/source/drivers/evoab2/NDriver.cxx

 			xComp->dispose();
 			}
 		    catch (com::sun::star::lang::DisposedException e) {
-			 xComp=NULL;
+			 xComp.clear();
 			}
 		}
 	}

connectivity/source/drivers/evoab2/NResultSet.cxx

 	g_list_free(m_pContacts);
 	m_pContacts = NULL;
 	m_pStatement = NULL;
-	m_xMetaData	= NULL;
+m_xMetaData.clear();
 }
 // -------------------------------------------------------------------------
 Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException)

connectivity/source/drivers/evoab2/NStatement.cxx

 
 		if( m_aSQLIterator.isTableNode( pAllTableNames->getChild( 0 ) ) )
 			OSQLParseNode::getTableComponents( pAllTableNames->getChild( 0 ),
-											   aCatalog,aSchema, aTableName );
+											   aCatalog,aSchema, aTableName,NULL );
 
 		else if( SQL_ISRULE( pAllTableNames->getChild( 0 ), table_ref ) )
 		{
 			{
                 aTableName = OSQLParseNode::getTableRange(pAllTableNames->getChild( 0 ));
 				if( !aTableName.getLength() )
-        			OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName);
+        			OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName,NULL);
 			}
 			else
 				OSL_ENSURE( false,  "odd table layout" );

connectivity/source/drivers/evoab2/NTables.cxx

 // -------------------------------------------------------------------------
 void OEvoabTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -----------------------------------------------------------------------------

connectivity/source/drivers/file/FCatalog.cxx

 	::osl::MutexGuard aGuard(m_aMutex);
 
 	typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OFileCatalog_BASE::disposing();
 }
 // -----------------------------------------------------------------------------

connectivity/source/drivers/file/FConnection.cxx

     OConnection_BASE::disposing();
 
 	m_bClosed	= sal_True;
-	m_xDir		= NULL;
-	m_xContent	= NULL;
+m_xDir.clear();
+m_xContent.clear();
 	m_xCatalog	= WeakReference< XTablesSupplier>();
 
 	dispose_ChildImpl();

connectivity/source/drivers/file/FPreparedStatement.cxx

 		m_pResultSet = NULL;
 	}
 
-	m_xParamColumns = NULL;
-
-
-	m_xMetaData = NULL;
+    m_xParamColumns = NULL;
+    m_xMetaData.clear();
 	if(m_aParameterRow.isValid())
 	{
 		m_aParameterRow->get().clear();

connectivity/source/drivers/file/FResultSet.cxx

 	OPropertySetHelper::disposing();
 
 	::osl::MutexGuard aGuard(m_aMutex);
-	m_xStatement	= NULL;
-	m_xMetaData		= NULL;
+    m_xStatement.clear();
+    m_xMetaData.clear();
 	m_pParseTree	= NULL;
-	m_xColNames		= NULL;
-	m_xColumns		= NULL;
-	m_xParamColumns = NULL;
-	m_xColsIdx		= NULL;
+    m_xColNames.clear();
+    m_xColumns = NULL;
+    m_xParamColumns = NULL;
+    m_xColsIdx.clear();
 
     Reference<XComponent> xComp = m_pTable;
 	if ( xComp.is() )

connectivity/source/drivers/file/FResultSetMetaData.cxx

 // -------------------------------------------------------------------------
 OResultSetMetaData::~OResultSetMetaData()
 {
-	m_xColumns = NULL;
+    m_xColumns = NULL;
 }
 // -----------------------------------------------------------------------------
 void OResultSetMetaData::checkColumnIndex(sal_Int32 column)  throw(SQLException, RuntimeException)

connectivity/source/drivers/file/FTables.cxx

 // -------------------------------------------------------------------------
 void OTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 //------------------------------------------------------------------

connectivity/source/drivers/file/fcomp.cxx

 {
 	Clean();
 	m_orgColumns		= NULL;
-	m_xIndexes			= NULL;
+m_xIndexes.clear();
 }
 //------------------------------------------------------------------
 //	inline OCursor& OPredicateCompiler::Cursor() const {return m_rCursor;}

connectivity/source/drivers/hsqldb/HStorageMap.cxx

 		{
 			try
 			{
-                m_xStream = NULL;
-				m_xSeek = NULL;
+               m_xStream.clear();
+			m_xSeek.clear();
 				if ( m_xInputStream.is() )
 				{
 					m_xInputStream->closeInput();
-					m_xInputStream = NULL;
+				m_xInputStream.clear();
 				}
 				if ( m_xOutputStream.is() )
 				{
                         OSL_UNUSED( e );
                         OSL_ENSURE(0,"Could not dispose OutputStream");
                     }
-					m_xOutputStream = NULL;
+				m_xOutputStream.clear();
 				}
 			}
 			catch(Exception& )

connectivity/source/drivers/hsqldb/HTables.cxx

 // -------------------------------------------------------------------------
 void OTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -------------------------------------------------------------------------

connectivity/source/drivers/hsqldb/HViews.cxx

 // -------------------------------------------------------------------------
 void HViews::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -------------------------------------------------------------------------

connectivity/source/drivers/jdbc/JDriver.cxx

 		java_sql_Connection* pConnection = new java_sql_Connection( *this );
 		xOut = pConnection;
 		if ( !pConnection->construct(url,info) )
-			xOut = NULL; // an error occured and the java driver didn't throw an exception
+			xOut.clear(); // an error occured and the java driver didn't throw an exception
         else
             m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_SUCCESS );
 	}

connectivity/source/drivers/jdbc/ResultSet.cxx

 	OPropertySetHelper::disposing();
 
 	::osl::MutexGuard aGuard(m_aMutex);
-	m_xMetaData		= NULL;
+m_xMetaData.clear();
 	if( object )
 	{
         SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");

connectivity/source/drivers/kab/KResultSet.cxx

 
 	::osl::MutexGuard aGuard(m_aMutex);
 
-	m_xStatement	= NULL;
-	m_xMetaData		= NULL;
+m_xStatement.clear();
+m_xMetaData.clear();
 }
 // -------------------------------------------------------------------------
 Any SAL_CALL KabResultSet::queryInterface(const Type & rType) throw(RuntimeException)

connectivity/source/drivers/kab/KTables.cxx

 // -------------------------------------------------------------------------
 void KabTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }

connectivity/source/drivers/macab/MacabResultSet.cxx

 
 	::osl::MutexGuard aGuard(m_aMutex);
 
-	m_xStatement	= NULL;
-	m_xMetaData		= NULL;
+m_xStatement.clear();
+m_xMetaData.clear();
 }
 // -------------------------------------------------------------------------
 Any SAL_CALL MacabResultSet::queryInterface(const Type & rType) throw(RuntimeException)

connectivity/source/drivers/macab/MacabTables.cxx

 // -------------------------------------------------------------------------
 void MacabTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }

connectivity/source/drivers/mozab/MPreparedStatement.cxx

 
 	OCommonStatement::disposing();
 
-	m_xMetaData = NULL;
+    m_xMetaData.clear();
 	if(m_aParameterRow.isValid())
 	{
 		m_aParameterRow->get().clear();
 		m_aParameterRow = NULL;
 	}
-	m_xParamColumns = NULL;
+    m_xParamColumns = NULL;
 }
 // -----------------------------------------------------------------------------
 

connectivity/source/drivers/mozab/MResultSet.cxx

 
 	::osl::MutexGuard aGuard(m_aMutex);
 
-	m_xStatement	= NULL;
-    m_xMetaData     = NULL;
+    m_xStatement.clear();
+    m_xMetaData.clear();
     m_pParseTree    = NULL;
-    m_xColumns      = NULL;
+    m_xColumns = NULL;
     m_xParamColumns = NULL;
     m_pKeySet       = NULL;
     if(m_pTable)

connectivity/source/drivers/mozab/MResultSetMetaData.cxx

 // -------------------------------------------------------------------------
 OResultSetMetaData::~OResultSetMetaData()
 {
-    m_xColumns = NULL;
+   m_xColumns = NULL;
 }
 
 // -----------------------------------------------------------------------------

connectivity/source/drivers/mozab/MTables.cxx

 // -------------------------------------------------------------------------
 void OTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -----------------------------------------------------------------------------

connectivity/source/drivers/mysql/YTables.cxx

 // -------------------------------------------------------------------------
 void OTables::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -------------------------------------------------------------------------

connectivity/source/drivers/mysql/YViews.cxx

 // -------------------------------------------------------------------------
 void OViews::disposing(void)
 {
-	m_xMetaData = NULL;
+m_xMetaData.clear();
 	OCollection::disposing();
 }
 // -------------------------------------------------------------------------

connectivity/source/drivers/odbcbase/OConnection.cxx

 						 ,m_bParameterSubstitution(sal_False)
 						 ,m_bIgnoreDriverPrivileges(sal_False)
                          ,m_bPreventGetVersionColumns(sal_False)
+                         ,m_bReadOnly(sal_True)
 {
 	m_pDriver->acquire();
 }
 	if (m_aConnectionHandle == SQL_NULL_HANDLE)
 		return -1;
 
-	sal_Bool bReadOnly; //weil Methode statisch hier noch einmal ein lokales bReadOnly
 	SQLRETURN nSQLRETURN = 0;
 	SDB_ODBC_CHAR szConnStrOut[4096];
 	SDB_ODBC_CHAR szConnStrIn[2048];
 	{
 		::rtl::OUString aVal;
 		OTools::GetInfo(this,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aVal,*this,getTextEncoding());
-		bReadOnly = !aVal.compareToAscii("Y");
+		m_bReadOnly = !aVal.compareToAscii("Y");
 	}
 	catch(Exception&)
 	{
-		bReadOnly = sal_True;
+		m_bReadOnly = sal_True;
 	}
 	try
 	{
 
 	// autocoomit ist immer default
 
-	if (!bReadOnly)
+	if (!m_bReadOnly)
 		N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER);
 
 	return nSQLRETURN;
 	::osl::MutexGuard aGuard( m_aMutex );
 	checkDisposed(OConnection_BASE::rBHelper.bDisposed);
 
-	if(m_aTypeInfo.empty())
-		buildTypeInfo();
-
-	Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,m_aTypeInfo,sql);
+	Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,sql);
 	m_aStatements.push_back(WeakReferenceHelper(xReturn));
 	return xReturn;
 }
 		m_aConnectionHandle,SQL_HANDLE_DBC,*this);
 }
 // --------------------------------------------------------------------------------
-sal_Bool SAL_CALL OConnection::isReadOnly(  ) throw(SQLException, RuntimeException)
+sal_Bool SAL_CALL OConnection::isReadOnly() throw(SQLException, RuntimeException)
 {
-	::osl::MutexGuard aGuard( m_aMutex );
-	checkDisposed(OConnection_BASE::rBHelper.bDisposed);
-
-
-	::rtl::OUString aValue;
-	OTools::GetInfo(this,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aValue,*this,getTextEncoding());
-	return !aValue.compareToAscii("Y");
+	// const member which will initialized only once
+	return m_bReadOnly;
 }
 // --------------------------------------------------------------------------------
 void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)

connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx

 #include "stdio.h"
 #include "TPrivilegesResultSet.hxx"
 #include <connectivity/dbexception.hxx>
+#include <rtl/ustrbuf.hxx>
 
 using namespace connectivity::odbc;
 using namespace com::sun::star::uno;
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly(  ) throw(SQLException, RuntimeException)
 {
-	::rtl::OUString aValue;
-	OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aValue,*this,m_pConnection->getTextEncoding());
-	return aValue.toChar() == 'Y';
+	return m_pConnection->isReadOnly();
 }
 // -------------------------------------------------------------------------
 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles(  ) throw(SQLException, RuntimeException)
 ::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions(  ) throw(SQLException, RuntimeException)
 {
 	SQLUINTEGER nValue;
-	::rtl::OUString aValue;
+	::rtl::OUStringBuffer aValue;
 	OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_STRING_FUNCTIONS,nValue,*this);
 	if(nValue & SQL_FN_STR_ASCII)
-		aValue = ::rtl::OUString::createFromAscii("ASCII,");
+		aValue.appendAscii("ASCII,");
 	if(nValue & SQL_FN_STR_BIT_LENGTH)
-		aValue += ::rtl::OUString::createFromAscii("BIT_LENGTH,");
+		aValue.appendAscii("BIT_LENGTH,");
 	if(nValue & SQL_FN_STR_CHAR)
-		aValue += ::rtl::OUString::createFromAscii("CHAR,");
+		aValue.appendAscii("CHAR,");
 	if(nValue & SQL_FN_STR_CHAR_LENGTH)
-		aValue += ::rtl::OUString::createFromAscii("CHAR_LENGTH,");
+		aValue.appendAscii("CHAR_LENGTH,");
 	if(nValue & SQL_FN_STR_CHARACTER_LENGTH)
-		aValue += ::rtl::OUString::createFromAscii("CHARACTER_LENGTH,");
+		aValue.appendAscii("CHARACTER_LENGTH,");
 	if(nValue & SQL_FN_STR_CONCAT)
-		aValue += ::rtl::OUString::createFromAscii("CONCAT,");
+		aValue.appendAscii("CONCAT,");
 	if(nValue & SQL_FN_STR_DIFFERENCE)
-		aValue += ::rtl::OUString::createFromAscii("DIFFERENCE,");
+		aValue.appendAscii("DIFFERENCE,");
 	if(nValue & SQL_FN_STR_INSERT)
-		aValue += ::rtl::OUString::createFromAscii("INSERT,");
+		aValue.appendAscii("INSERT,");
 	if(nValue & SQL_FN_STR_LCASE)
-		aValue += ::rtl::OUString::createFromAscii("LCASE,");
+		aValue.appendAscii("LCASE,");
 	if(nValue & SQL_FN_STR_LEFT)
-		aValue += ::rtl::OUString::createFromAscii("LEFT,");
+		aValue.appendAscii("LEFT,");
 	if(nValue & SQL_FN_STR_LENGTH)
-		aValue += ::rtl::OUString::createFromAscii("LENGTH,");
+		aValue.appendAscii("LENGTH,");
 	if(nValue & SQL_FN_STR_LOCATE)
-		aValue += ::rtl::OUString::createFromAscii("LOCATE,");
+		aValue.appendAscii("LOCATE,");