diff --git a/Data/SQLite/src/SessionImpl.cpp b/Data/SQLite/src/SessionImpl.cpp index cc95ec032..da6c7dd89 100644 --- a/Data/SQLite/src/SessionImpl.cpp +++ b/Data/SQLite/src/SessionImpl.cpp @@ -176,6 +176,8 @@ void SessionImpl::open(const std::string& connect) rc = sqlite3_open_v2(connectionString().c_str(), &_pDB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL); if (rc == SQLITE_OK) break; + if (!_pDB) + throw ConnectionFailedException(std::string(sqlite3_errstr(rc))); if (sw.elapsedSeconds() >= tout) { Utility::throwException(_pDB, rc); diff --git a/Data/SQLite/testsuite/src/SQLiteTest.cpp b/Data/SQLite/testsuite/src/SQLiteTest.cpp index ffeaa6378..931e00e4d 100755 --- a/Data/SQLite/testsuite/src/SQLiteTest.cpp +++ b/Data/SQLite/testsuite/src/SQLiteTest.cpp @@ -1376,6 +1376,21 @@ void SQLiteTest::testEmptyDB() } +void SQLiteTest::testNonexistingDB() +{ + try + { + Session tmp (Poco::Data::SQLite::Connector::KEY, "foo/bar/nonexisting.db", 1); + fail("non-existing DB must throw"); + } + catch(ConnectionFailedException& ex) + { + return; + } + fail("non-existing DB must throw ConnectionFailedException"); +} + + void SQLiteTest::testCLOB() { std::string lastName("lastname"); @@ -3506,6 +3521,7 @@ CppUnit::Test* SQLiteTest::suite() CppUnit_addTest(pSuite, SQLiteTest, testIllegalRange); CppUnit_addTest(pSuite, SQLiteTest, testSingleSelect); CppUnit_addTest(pSuite, SQLiteTest, testEmptyDB); + CppUnit_addTest(pSuite, SQLiteTest, testNonexistingDB); CppUnit_addTest(pSuite, SQLiteTest, testCLOB); CppUnit_addTest(pSuite, SQLiteTest, testBLOB); CppUnit_addTest(pSuite, SQLiteTest, testTuple10); diff --git a/Data/SQLite/testsuite/src/SQLiteTest.h b/Data/SQLite/testsuite/src/SQLiteTest.h index 59425ab88..6e4f911ea 100755 --- a/Data/SQLite/testsuite/src/SQLiteTest.h +++ b/Data/SQLite/testsuite/src/SQLiteTest.h @@ -74,6 +74,7 @@ public: void testIllegalRange(); void testSingleSelect(); void testEmptyDB(); + void testNonexistingDB(); void testCLOB(); void testBLOB();