summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx9
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx31
-rw-r--r--connectivity/source/inc/file/FStatement.hxx4
3 files changed, 36 insertions, 8 deletions
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index fb9b2c2e48ec..2d7db2fa5ff1 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -101,15 +101,16 @@ void OPreparedStatement::construct(const OUString& sql) throw(SQLException, Run
Reference<XResultSet> OPreparedStatement::makeResultSet()
{
+ closeResultSet();
+
OResultSet *pResultSet = createResultSet();
Reference<XResultSet> xRS(pResultSet);
initializeResultSet(pResultSet);
initResultSet(pResultSet);
+ m_xResultSet = xRS;
return xRS;
}
-
-
Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
{
Any aRet = OStatement_BASE2::queryInterface(rType);
@@ -145,6 +146,8 @@ void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ closeResultSet();
}
@@ -157,6 +160,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeExc
// since we don't support the XMultipleResults interface, nobody will ever get that ResultSet...
Reference< XComponent > xComp(xRS, UNO_QUERY);
+ assert(xComp.is() || !xRS.is());
if (xComp.is())
xComp->dispose();
@@ -512,7 +516,6 @@ void OPreparedStatement::describeParameter()
}
}
}
-
void OPreparedStatement::initializeResultSet(OResultSet* pRS)
{
OStatement_Base::initializeResultSet(pRS);
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index fb3361a0e817..bf88543a3b42 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -95,10 +95,23 @@ OStatement_Base::~OStatement_Base()
delete m_pSQLAnalyzer;
}
+void OStatement_Base::disposeResultSet()
+{
+ SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OStatement_Base::disposeResultSet" );
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+ assert(xComp.is() || !m_xResultSet.get().is());
+ if (xComp.is())
+ xComp->dispose();
+ m_xResultSet.clear();
+}
+
void OStatement_BASE2::disposing()
{
::osl::MutexGuard aGuard(m_aMutex);
+ disposeResultSet();
+
if(m_pSQLAnalyzer)
m_pSQLAnalyzer->dispose();
@@ -173,17 +186,26 @@ void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException, s
dispose();
}
-
-void OStatement_Base::reset() throw (SQLException)
+void OStatement_Base::closeResultSet () throw (SQLException)
{
+ SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com OStatement_Base::clearMyResultSet " );
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
- clearWarnings ();
+ Reference< XCloseable > xCloseable(m_xResultSet.get(), UNO_QUERY);
+ assert(xCloseable.is() || !m_xResultSet.get().is());
+ if (xCloseable.is())
+ {
+ try
+ {
+ xCloseable->close();
+ }
+ catch( const DisposedException& ) { }
+ }
+ m_xResultSet.clear();
}
-
Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -252,6 +274,7 @@ Reference< XResultSet > SAL_CALL OStatement::executeQuery( const OUString& sql )
OResultSet* pResult = createResultSet();
xRS = pResult;
initializeResultSet(pResult);
+ m_xResultSet = xRS;
pResult->OpenImpl();
diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx
index 3fb60bb74738..9b540dd612ab 100644
--- a/connectivity/source/inc/file/FStatement.hxx
+++ b/connectivity/source/inc/file/FStatement.hxx
@@ -68,6 +68,7 @@ namespace connectivity
::std::vector<TAscendingOrder> m_aOrderbyAscending;
::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns // for this Statement
@@ -112,9 +113,10 @@ namespace connectivity
// create the analyzer
virtual OSQLAnalyzer* createAnalyzer();
- void reset () throw( ::com::sun::star::sdbc::SQLException);
+ void closeResultSet () throw( ::com::sun::star::sdbc::SQLException);
sal_Int32 getPrecision ( sal_Int32 sqlType);
+ void disposeResultSet();
void GetAssignValues();
void SetAssignValue(const OUString& aColumnName,
const OUString& aValue,