diff options
| author | Ocke Janssen <oj@openoffice.org> | 2001-08-29 11:13:20 +0000 |
|---|---|---|
| committer | Ocke Janssen <oj@openoffice.org> | 2001-08-29 11:13:20 +0000 |
| commit | aa3f42832756b7165a0722b2d013a572acf224c8 (patch) | |
| tree | 958cce54e5a52b2f6cb3e513df513719bd2495e2 | |
| parent | 8a0bf39fd7289bdfd1c31f94367c439820330862 (diff) | |
#84578# enable multiple connections
| -rw-r--r-- | connectivity/source/drivers/odbc/OConnection.cxx | 58 | ||||
| -rw-r--r-- | connectivity/source/drivers/odbc/ODatabaseMetaData.cxx | 102 | ||||
| -rw-r--r-- | connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx | 35 | ||||
| -rw-r--r-- | connectivity/source/drivers/odbc/OResultSet.cxx | 14 | ||||
| -rw-r--r-- | connectivity/source/drivers/odbc/OStatement.cxx | 25 |
5 files changed, 107 insertions, 127 deletions
diff --git a/connectivity/source/drivers/odbc/OConnection.cxx b/connectivity/source/drivers/odbc/OConnection.cxx index f749a26f5e9a..ae80a03f5925 100644 --- a/connectivity/source/drivers/odbc/OConnection.cxx +++ b/connectivity/source/drivers/odbc/OConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OConnection.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-05-30 14:16:09 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:13:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,7 +118,8 @@ OConnection::OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver) m_bClosed(sal_False), m_xMetaData(NULL), m_bUseCatalog(sal_False), - m_bUseOldDateFormat(sal_False) + m_bUseOldDateFormat(sal_False), + m_nStatementCount(0) { m_pDriver->acquire(); ModuleContext::AddRef(); @@ -218,6 +219,8 @@ SQLRETURN OConnection::Construct(const ::rtl::OUString& url,const Sequence< Prop { osl_incrementInterlockedCount( &m_refCount ); m_aConnectionHandle = SQL_NULL_HANDLE; + m_aURL = url; + m_aInfo = info; // Connection allozieren N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle); @@ -576,6 +579,11 @@ void OConnection::disposing() } m_aStatements.clear(); + for (::std::map< SQLHANDLE,OConnection*>::iterator aConIter = m_aConnections.begin();aConIter != m_aConnections.end();++aConIter ) + aConIter->second->dispose(); + + ::std::map< SQLHANDLE,OConnection*>().swap(m_aConnections); + OTools::ThrowException(this,N3SQLDisconnect(m_aConnectionHandle),m_aConnectionHandle,SQL_HANDLE_DBC,*this); m_bClosed = sal_True; m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>(); @@ -584,6 +592,50 @@ void OConnection::disposing() OConnection_BASE::disposing(); } // ----------------------------------------------------------------------------- +OConnection* OConnection::cloneConnection() +{ + return new OConnection(m_pDriverHandleCopy,m_pDriver); +} +// ----------------------------------------------------------------------------- +SQLHANDLE OConnection::createStatementHandle() +{ + OConnection* pConnectionTemp = this; + sal_Bool bNew = sal_False; + sal_Int32 nMaxStatements = getMetaData()->getMaxStatements(); + if(nMaxStatements && nMaxStatements <= m_nStatementCount) + { + OConnection* pConnection = cloneConnection(); + pConnection->acquire(); + pConnection->Construct(m_aURL,m_aInfo); + pConnectionTemp = pConnection; + bNew = sal_True; + } + + SQLHANDLE aStatementHandle = SQL_NULL_HANDLE; + SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,pConnectionTemp->getConnection(),&aStatementHandle); + OTools::ThrowException(pConnectionTemp,nRetcode,pConnectionTemp->getConnection(),SQL_HANDLE_DBC,*this); + ++m_nStatementCount; + if(bNew) + m_aConnections.insert(::std::map< SQLHANDLE,OConnection*>::value_type(aStatementHandle,pConnectionTemp)); + + return aStatementHandle; + +} +// ----------------------------------------------------------------------------- +void OConnection::freeStatementHandle(SQLHANDLE& _pHandle) +{ + ::std::map< SQLHANDLE,OConnection*>::iterator aFind = m_aConnections.find(_pHandle); + N3SQLFreeStmt(_pHandle,SQL_CLOSE); + N3SQLFreeHandle(SQL_HANDLE_STMT,_pHandle); + _pHandle = SQL_NULL_HANDLE; + if(aFind != m_aConnections.end()) + { + aFind->second->dispose(); + m_aConnections.erase(aFind); + } + --m_nStatementCount; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx index 9422593da2e0..085f9a44d7cd 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ODatabaseMetaData.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:13:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -115,11 +115,7 @@ ODatabaseMetaData::~ODatabaseMetaData() // ------------------------------------------------------------------------- Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openTypeInfo(); return xRef; @@ -136,11 +132,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLExc } else { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); xRef = pResult; pResult->openCatalogs(); } @@ -158,11 +150,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLExc // ------------------------------------------------------------------------- Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openSchemas(); return xRef; @@ -172,11 +160,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openColumnPrivileges(m_bUseCatalog ? catalog : Any(),schema,table,columnNamePattern); return xRef; @@ -186,11 +170,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,columnNamePattern); return xRef; @@ -200,11 +180,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openTables(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,types); return xRef; @@ -214,11 +190,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openProcedureColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern,columnNamePattern); return xRef; @@ -228,11 +200,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openProcedures(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern); return xRef; @@ -241,11 +209,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures( Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openVersionColumns(m_bUseCatalog ? catalog : Any(),schema,table); return xRef; @@ -338,11 +302,7 @@ sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLExceptio Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openExportedKeys(m_bUseCatalog ? catalog : Any(),schema,table); return xRef; @@ -351,11 +311,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys( Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openImportedKeys(m_bUseCatalog ? catalog : Any(),schema,table); return xRef; @@ -364,11 +320,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys( Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openPrimaryKeys(m_bUseCatalog ? catalog : Any(),schema,table); return xRef; @@ -378,11 +330,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openIndexInfo(m_bUseCatalog ? catalog : Any(),schema,table,unique,approximate); return xRef; @@ -392,11 +340,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier( const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openBestRowIdentifier(m_bUseCatalog ? catalog : Any(),schema,table,scope,nullable); return xRef; @@ -405,11 +349,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier( Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openTablePrivileges(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern); return xRef; @@ -420,11 +360,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference( const ::rtl::OUString& primaryTable, const Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException) { - SQLHANDLE hStmt; - SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&hStmt); - OTools::ThrowException(m_pConnection,nRetcode,m_pConnection->getConnection(),SQL_HANDLE_DBC,*this); - - ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection,hStmt,m_pConnection->getTextEncoding()); + ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection); Reference< XResultSet > xRef = pResult; pResult->openForeignKeys(m_bUseCatalog ? primaryCatalog : Any(),primarySchema.toChar() == '%' ? &primarySchema : NULL,&primaryTable, m_bUseCatalog ? foreignCatalog : Any(), foreignSchema.toChar() == '%' ? &foreignSchema : NULL,&foreignTable); @@ -723,7 +659,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLE continue; // no views supported ::connectivity::ODatabaseMetaDataResultSet::ORow aRow; aRow.push_back(::connectivity::ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(sTableTypes[i])); + aRow.push_back(new ::connectivity::ORowSetValueDecorator(sTableTypes[i])); aRows.push_back(aRow); } pResult->setRows(aRows); diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index e77fb96cd0b7..0495af84d516 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ODatabaseMetaDataResultSet.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:13:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -124,16 +124,17 @@ using namespace com::sun::star::sdbc; using namespace com::sun::star::util; // ------------------------------------------------------------------------- -ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection,SQLHANDLE _pStatementHandle,rtl_TextEncoding _nTextEncoding) : ODatabaseMetaDataResultSet_BASE(m_aMutex) - ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper) - ,m_aStatement(NULL) - ,m_xMetaData(NULL) - ,m_aStatementHandle(_pStatementHandle) - ,m_bEOF(sal_False) - ,m_nTextEncoding(_nTextEncoding) - ,m_bFreeHandle(sal_False) - ,m_pConnection(_pConnection) - ,m_nDriverColumnCount(0) +ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection) + :ODatabaseMetaDataResultSet_BASE(m_aMutex) + ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper) + ,m_aStatement(NULL) + ,m_xMetaData(NULL) + ,m_aStatementHandle(_pConnection->createStatementHandle()) + ,m_bEOF(sal_False) + ,m_nTextEncoding(_pConnection->getTextEncoding()) + ,m_bFreeHandle(sal_False) + ,m_pConnection(_pConnection) + ,m_nDriverColumnCount(0) { OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!"); osl_incrementInterlockedCount( &m_refCount ); @@ -154,11 +155,7 @@ void ODatabaseMetaDataResultSet::disposing(void) ::osl::MutexGuard aGuard(m_aMutex); if(m_bFreeHandle) - { - N3SQLFreeStmt(m_aStatementHandle,SQL_CLOSE); - N3SQLFreeHandle(SQL_HANDLE_STMT,m_aStatementHandle); - m_aStatementHandle = NULL; - } + m_pConnection->freeStatementHandle(m_aStatementHandle); m_aStatement = NULL; m_xMetaData = NULL; @@ -198,7 +195,7 @@ sal_Int32 ODatabaseMetaDataResultSet::mapColumn (sal_Int32 column) { sal_Int32 map = column; - if (m_aColMapping.size()) + if (!m_aColMapping.empty()) { // Validate column number map = m_aColMapping[column]; @@ -288,7 +285,7 @@ sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) t sal_Int8 nVal = 0; if(columnIndex <= m_nDriverColumnCount) { - OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_CHAR,m_bWasNull,**this,&nVal,sizeof nVal); + OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_TINYINT,m_bWasNull,**this,&nVal,sizeof nVal); if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end()) return sal_Int8((*m_aValueRangeIter).second[(sal_Int32)nVal]); diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index ee11dc8f8e15..fc754caeeaf4 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OResultSet.cxx,v $ * - * $Revision: 1.39 $ + * $Revision: 1.40 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:13:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -192,11 +192,7 @@ void OResultSet::disposing(void) if(m_aBindVector.size()) releaseBuffer(); if(m_bFreeHandle) - { - N3SQLFreeStmt(m_aStatementHandle,SQL_CLOSE); - N3SQLFreeHandle(SQL_HANDLE_STMT,m_aStatementHandle); - m_aStatementHandle = NULL; - } + m_pStatement->getOwnConnection()->freeStatementHandle(m_aStatementHandle); m_aStatement = NULL; m_xMetaData = NULL; @@ -206,7 +202,7 @@ sal_Int32 OResultSet::mapColumn (sal_Int32 column) { sal_Int32 map = column; - if (m_aColMapping.size()) + if (!m_aColMapping.empty()) { // Validate column number OSL_ENSURE(column>0,"OResultSet::mapColumn column <= 0"); @@ -434,7 +430,7 @@ sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLExcep sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { sal_Int8 nRet(0); - const ORowSetValue& aValue = getValue(columnIndex,SQL_C_CHAR,&nRet,sizeof nRet); + const ORowSetValue& aValue = getValue(columnIndex,SQL_C_TINYINT,&nRet,sizeof nRet); return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int8)aValue; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index d36c30c4f7ab..8b6fea219c1d 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OStatement.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:13:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -141,14 +141,17 @@ using namespace com::sun::star::container; using namespace com::sun::star::io; using namespace com::sun::star::util; //------------------------------------------------------------------------------ -OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex), - OPropertySetHelper(OStatement_BASE::rBHelper), - rBHelper(OStatement_BASE::rBHelper), - m_pConnection(_pConnection), - m_pRowStatusArray(0) +OStatement_Base::OStatement_Base(OConnection* _pConnection ) + :OStatement_BASE(m_aMutex) + ,OPropertySetHelper(OStatement_BASE::rBHelper) + ,rBHelper(OStatement_BASE::rBHelper) + ,m_pConnection(_pConnection) + ,m_pConnectionTemp(NULL) + ,m_pRowStatusArray(0) + ,m_aStatementHandle(SQL_NULL_HANDLE) { m_pConnection->acquire(); - N3SQLAllocHandle(SQL_HANDLE_STMT,m_pConnection->getConnection(),&m_aStatementHandle); + m_aStatementHandle = m_pConnection->createStatementHandle(); } // ----------------------------------------------------------------------------- OStatement_Base::~OStatement_Base() @@ -173,11 +176,7 @@ void OStatement_BASE2::disposing() OSL_ENSURE(m_aStatementHandle,"OStatement_BASE2::disposing: StatementHandle is null!"); N3SQLFreeStmt(m_aStatementHandle,SQL_RESET_PARAMS); N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND); - N3SQLFreeStmt(m_aStatementHandle,SQL_CLOSE); - // OTools::ThrowException(m_pConnection,N3SQLFreeStmt(m_aStatementHandle,SQL_DROP),m_aStatementHandle,SQL_HANDLE_STMT,*this); - - N3SQLFreeHandle(SQL_HANDLE_STMT,m_aStatementHandle); - m_aStatementHandle = NULL; + m_pConnection->freeStatementHandle(m_aStatementHandle); if (m_pConnection) m_pConnection->release(); |
