diff options
author | Ocke Janssen <oj@openoffice.org> | 2009-10-13 06:40:52 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2009-10-13 06:40:52 +0000 |
commit | 08b35d82a31b39898bb550f602c3209e101ed3a2 (patch) | |
tree | 2ec367f49d032e39198964badc6124c2368cc3ee | |
parent | 68e50981edfd8b0cb2a92c9984b8217078b9929c (diff) |
#i105825# throw exception when database was written by newer version
-rw-r--r-- | connectivity/source/drivers/hsqldb/HDriver.cxx | 43 | ||||
-rw-r--r-- | connectivity/source/drivers/hsqldb/makefile.mk | 1 | ||||
-rw-r--r-- | connectivity/source/inc/resource/hsqldb_res.hrc | 1 | ||||
-rw-r--r-- | connectivity/source/resource/conn_shared_res.src | 5 |
4 files changed, 50 insertions, 0 deletions
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 243aa6b802..d756eeecd1 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -55,6 +55,7 @@ #include <connectivity/dbexception.hxx> #include <comphelper/namedvaluecollection.hxx> #include <unotools/confignode.hxx> +#include <unotools/ucbstreamhelper.hxx> #include "resource/hsqldb_res.hrc" #include "resource/sharedresources.hxx" @@ -70,6 +71,8 @@ namespace connectivity using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::embed; + using namespace ::com::sun::star::io; + using namespace ::com::sun::star::task; using namespace ::com::sun::star::reflection; namespace hsqldb @@ -259,6 +262,46 @@ namespace connectivity makeAny( lcl_getPermittedJavaMethods_nothrow( m_xFactory ) ) ); aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) ); + + ::rtl::OUString sProperties( RTL_CONSTASCII_USTRINGPARAM( "properties" ) ); + try + { + if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) ) + { + Reference<XStream > xStream = xStorage->openStreamElement(sProperties,ElementModes::READ); + if ( xStream.is() ) + { + ::std::auto_ptr<SvStream> pStream( ::utl::UcbStreamHelper::CreateStream(xStream) ); + if ( pStream.get() ) + { + ByteString sLine; + while ( pStream->ReadLine(sLine) ) + { + if ( sLine.Equals("version=",0,sizeof("version=")-1) ) + { + sLine = sLine.GetToken(1,'='); + const sal_Int32 nMajor = sLine.GetToken(0,'.').ToInt32(); + const sal_Int32 nMinor = sLine.GetToken(1,'.').ToInt32(); + const sal_Int32 nMicro = sLine.GetToken(2,'.').ToInt32(); + if ( nMajor > 1 + || ( nMajor == 1 && nMinor > 8 ) + || ( nMajor == 1 && nMinor == 8 && nMicro > 0 ) ) + { + ::connectivity::SharedResources aResources; + const ::rtl::OUString sMessage = aResources.getResourceString(STR_ERROR_NEW_VERSION); + ::dbtools::throwGenericSQLException(sMessage ,*this); + } + break; + } + } + } + } // if ( xStream.is() ) + ::comphelper::disposeComponent(xStream); + } + } + catch(Exception&) + { + } // readonly? Reference<XPropertySet> xProp(xStorage,UNO_QUERY); diff --git a/connectivity/source/drivers/hsqldb/makefile.mk b/connectivity/source/drivers/hsqldb/makefile.mk index 9ed5acb17d..c61e4b297b 100644 --- a/connectivity/source/drivers/hsqldb/makefile.mk +++ b/connectivity/source/drivers/hsqldb/makefile.mk @@ -102,6 +102,7 @@ SHL1STDLIBS=\ $(DBTOOLSLIB) \ $(JVMFWKLIB) \ $(COMPHELPERLIB) \ + $(TOOLSLIB) \ $(UNOTOOLSLIB) diff --git a/connectivity/source/inc/resource/hsqldb_res.hrc b/connectivity/source/inc/resource/hsqldb_res.hrc index a56fea79e8..e649cd9786 100644 --- a/connectivity/source/inc/resource/hsqldb_res.hrc +++ b/connectivity/source/inc/resource/hsqldb_res.hrc @@ -44,6 +44,7 @@ #define STR_NO_TABLE_EDITOR_DIALOG ( STR_HSQLDB_BASE + 3 ) #define STR_NO_TABLENAME ( STR_HSQLDB_BASE + 4 ) #define STR_NO_DOCUMENTUI ( STR_HSQLDB_BASE + 5 ) +#define STR_ERROR_NEW_VERSION ( STR_HSQLDB_BASE + 6 ) #endif // CONNECTIVITY_RESOURCE_HSQLDB_HRC diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src index ea3fb4e065..bfa1b29c6d 100644 --- a/connectivity/source/resource/conn_shared_res.src +++ b/connectivity/source/resource/conn_shared_res.src @@ -645,3 +645,8 @@ String STR_NO_DOCUMENTUI { Text [ en-US ] = "The provided DocumentUI is not allowed to be NULL."; }; +String STR_ERROR_NEW_VERSION +{ + Text = "The connection could not be established. The database was created by a newer version of %PRODUCTNAME."; +}; + |