mirror of
				https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
				synced 2025-10-31 02:27:56 +00:00 
			
		
		
		
	DateTime support & some test tidying
This commit is contained in:
		| @@ -222,6 +222,42 @@ inline Poco::Any SessionImpl::dataTypeInfo(const std::string& rName) | ||||
| } | ||||
|  | ||||
|  | ||||
| inline void SessionImpl::setEnforceCapability(const std::string&, bool val) | ||||
| { | ||||
| 	_enforceCapability = val; | ||||
| } | ||||
|  | ||||
|  | ||||
| inline bool SessionImpl::getEnforceCapability(const std::string&) | ||||
| { | ||||
| 	return _enforceCapability; | ||||
| } | ||||
|  | ||||
|  | ||||
| inline void SessionImpl::autoBind(const std::string&, bool val) | ||||
| { | ||||
| 	_autoBind = val; | ||||
| } | ||||
|  | ||||
|  | ||||
| inline bool SessionImpl::isAutoBind(const std::string& name) | ||||
| { | ||||
| 	return _autoBind; | ||||
| } | ||||
|  | ||||
|  | ||||
| inline void SessionImpl::autoExtract(const std::string&, bool val) | ||||
| { | ||||
| 	_autoExtract = val; | ||||
| } | ||||
|  | ||||
|  | ||||
| inline bool SessionImpl::isAutoExtract(const std::string& name) | ||||
| { | ||||
| 	return _autoExtract; | ||||
| } | ||||
|  | ||||
|  | ||||
| } } } // namespace Poco::Data::ODBC | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -104,6 +104,7 @@ void ODBCColumn::init() | ||||
| 	case SQL_CHAR: | ||||
| 	case SQL_VARCHAR: | ||||
| 	case SQL_LONGVARCHAR: | ||||
| 	case -9:// SQL Server NVARCHAR | ||||
| 		setType(MetaColumn::FDT_STRING); break; | ||||
| 	case SQL_TINYINT: | ||||
| 		setType(MetaColumn::FDT_INT8); break; | ||||
|   | ||||
| @@ -203,8 +203,12 @@ void SessionImpl::close() | ||||
| { | ||||
| 	if (!isConnected()) return; | ||||
|  | ||||
| 	commit(); | ||||
| 	checkError(SQLDisconnect(_db)); | ||||
| 	try | ||||
| 	{ | ||||
| 		commit(); | ||||
| 	}catch (ConnectionException&) { } | ||||
|  | ||||
| 	SQLDisconnect(_db); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -265,40 +269,4 @@ int SessionImpl::maxStatementLength() | ||||
| } | ||||
|  | ||||
|  | ||||
| void SessionImpl::setEnforceCapability(const std::string&, bool val) | ||||
| { | ||||
| 	_enforceCapability = val; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool SessionImpl::getEnforceCapability(const std::string&) | ||||
| { | ||||
| 	return _enforceCapability; | ||||
| } | ||||
|  | ||||
|  | ||||
| void SessionImpl::autoBind(const std::string&, bool val) | ||||
| { | ||||
| 	_autoBind = val; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool SessionImpl::isAutoBind(const std::string& name) | ||||
| { | ||||
| 	return _autoBind; | ||||
| } | ||||
|  | ||||
|  | ||||
| void SessionImpl::autoExtract(const std::string&, bool val) | ||||
| { | ||||
| 	_autoExtract = val; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool SessionImpl::isAutoExtract(const std::string& name) | ||||
| { | ||||
| 	return _autoExtract; | ||||
| } | ||||
|  | ||||
|  | ||||
| } } } // namespace Poco::Data::ODBC | ||||
|   | ||||
| @@ -49,28 +49,28 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::NotFoundException; | ||||
|  | ||||
|  | ||||
| Poco::SharedPtr<Poco::Data::Session> ODBCAccessTest::_pSession = 0; | ||||
| std::string ODBCAccessTest::_dbConnString; | ||||
| Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers; | ||||
| Session*                 ODBCAccessTest::_pSession = 0; | ||||
| std::string              ODBCAccessTest::_dbConnString; | ||||
| ODBC::Utility::DriverMap ODBCAccessTest::_drivers; | ||||
|  | ||||
|  | ||||
| ODBCAccessTest::ODBCAccessTest(const std::string& name):  | ||||
| 	CppUnit::TestCase(name) | ||||
| { | ||||
| 	ODBC::Connector::registerConnector(); | ||||
| } | ||||
|  | ||||
|  | ||||
| ODBCAccessTest::~ODBCAccessTest() | ||||
| { | ||||
| 	ODBC::Connector::unregisterConnector(); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -72,7 +72,7 @@ private: | ||||
|  | ||||
| 	static Poco::Data::ODBC::Utility::DriverMap _drivers; | ||||
| 	static std::string _dbConnString; | ||||
| 	static Poco::SharedPtr<Poco::Data::Session> _pSession; | ||||
| 	static Poco::Data::Session* _pSession; | ||||
| 	bool _owner; | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -50,20 +50,21 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::Tuple; | ||||
| using Poco::NotFoundException; | ||||
|  | ||||
|  | ||||
| const bool ODBCDB2Test::bindValues[8] = {true, true, true, false, false, true, false, false}; | ||||
| Poco::SharedPtr<Poco::Data::Session> ODBCDB2Test::_pSession = 0; | ||||
| Poco::SharedPtr<SQLExecutor> ODBCDB2Test::_pExecutor = 0; | ||||
| std::string ODBCDB2Test::_dbConnString; | ||||
| Poco::Data::ODBC::Utility::DriverMap ODBCDB2Test::_drivers; | ||||
| ODBCDB2Test::SessionPtr  ODBCDB2Test::_pSession = 0; | ||||
| ODBCDB2Test::ExecPtr ODBCDB2Test::_pExecutor = 0; | ||||
| std::string              ODBCDB2Test::_dbConnString; | ||||
| ODBCDB2Test::Drivers     ODBCDB2Test::_drivers; | ||||
| const bool               ODBCDB2Test::bindValues[8] =  | ||||
| 	{true, true, true, false, false, true, false, false}; | ||||
|  | ||||
|  | ||||
| ODBCDB2Test::ODBCDB2Test(const std::string& name):  | ||||
|   | ||||
| @@ -131,6 +131,10 @@ public: | ||||
| 	static CppUnit::Test* suite(); | ||||
|  | ||||
| private: | ||||
| 	typedef Poco::Data::ODBC::Utility::DriverMap Drivers; | ||||
| 	typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr; | ||||
| 	typedef Poco::SharedPtr<SQLExecutor>         ExecPtr; | ||||
|  | ||||
| 	void dropObject(const std::string& type, const std::string& tableName); | ||||
| 	void recreatePersonTable(); | ||||
| 	void recreatePersonBLOBTable(); | ||||
| @@ -145,11 +149,11 @@ private: | ||||
| 	static bool init(const std::string& driver, const std::string& dsn); | ||||
| 	static bool canConnect(const std::string& driver, const std::string& dsn); | ||||
|  | ||||
| 	static Poco::Data::ODBC::Utility::DriverMap _drivers; | ||||
| 	static Drivers     _drivers; | ||||
| 	static std::string _dbConnString; | ||||
| 	static Poco::SharedPtr<Poco::Data::Session> _pSession; | ||||
| 	static Poco::SharedPtr<SQLExecutor> _pExecutor; | ||||
| 	static const bool bindValues[8]; | ||||
| 	static SessionPtr  _pSession; | ||||
| 	static ExecPtr     _pExecutor; | ||||
| 	static const bool  bindValues[8]; | ||||
| }; | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -50,20 +50,21 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::Tuple; | ||||
| using Poco::NotFoundException; | ||||
|  | ||||
|  | ||||
| const bool ODBCMySQLTest::bindValues[8] = {true, true, true, false, false, true, false, false}; | ||||
| Poco::SharedPtr<Poco::Data::Session> ODBCMySQLTest::_pSession = 0; | ||||
| Poco::SharedPtr<SQLExecutor> ODBCMySQLTest::_pExecutor = 0; | ||||
| std::string ODBCMySQLTest::_dbConnString; | ||||
| Poco::Data::ODBC::Utility::DriverMap ODBCMySQLTest::_drivers; | ||||
| ODBCMySQLTest::SessionPtr  ODBCMySQLTest::_pSession = 0; | ||||
| ODBCMySQLTest::ExecPtr ODBCMySQLTest::_pExecutor = 0; | ||||
| std::string                ODBCMySQLTest::_dbConnString; | ||||
| ODBCMySQLTest::Drivers     ODBCMySQLTest::_drivers; | ||||
| const bool                 ODBCMySQLTest::bindValues[8] =  | ||||
| 	{true, true, true, false, false, true, false, false}; | ||||
|  | ||||
|  | ||||
| ODBCMySQLTest::ODBCMySQLTest(const std::string& name):  | ||||
|   | ||||
| @@ -133,6 +133,10 @@ public: | ||||
| 	static CppUnit::Test* suite(); | ||||
|  | ||||
| private: | ||||
| 	typedef Poco::Data::ODBC::Utility::DriverMap Drivers; | ||||
| 	typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr; | ||||
| 	typedef Poco::SharedPtr<SQLExecutor>         ExecPtr; | ||||
|  | ||||
| 	void dropObject(const std::string& type, const std::string& name); | ||||
| 	void recreatePersonTable(); | ||||
| 	void recreatePersonBLOBTable(); | ||||
| @@ -147,11 +151,11 @@ private: | ||||
| 	static bool init(const std::string& driver, const std::string& dsn); | ||||
| 	static bool canConnect(const std::string& driver, const std::string& dsn); | ||||
|  | ||||
| 	static Poco::Data::ODBC::Utility::DriverMap _drivers; | ||||
| 	static Drivers     _drivers; | ||||
| 	static std::string _dbConnString; | ||||
| 	static Poco::SharedPtr<Poco::Data::Session> _pSession; | ||||
| 	static Poco::SharedPtr<SQLExecutor> _pExecutor; | ||||
| 	static const bool bindValues[8]; | ||||
| 	static SessionPtr  _pSession; | ||||
| 	static ExecPtr     _pExecutor; | ||||
| 	static const bool  bindValues[8]; | ||||
| }; | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -51,21 +51,22 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::Tuple; | ||||
| using Poco::DateTime; | ||||
| using Poco::NotFoundException; | ||||
|  | ||||
|  | ||||
| const bool ODBCOracleTest::bindValues[8] = {true, true, true, false, false, true, false, false}; | ||||
| Poco::SharedPtr<Poco::Data::Session> ODBCOracleTest::_pSession = 0; | ||||
| Poco::SharedPtr<SQLExecutor> ODBCOracleTest::_pExecutor = 0; | ||||
| std::string ODBCOracleTest::_dbConnString; | ||||
| Poco::Data::ODBC::Utility::DriverMap ODBCOracleTest::_drivers; | ||||
| ODBCOracleTest::SessionPtr  ODBCOracleTest::_pSession = 0; | ||||
| ODBCOracleTest::ExecPtr ODBCOracleTest::_pExecutor = 0; | ||||
| std::string                 ODBCOracleTest::_dbConnString; | ||||
| ODBC::Utility::DriverMap    ODBCOracleTest::_drivers; | ||||
| const bool                  ODBCOracleTest::bindValues[8] =  | ||||
| 	{true, true, true, false, false, true, false, false}; | ||||
|  | ||||
|  | ||||
| ODBCOracleTest::ODBCOracleTest(const std::string& name):  | ||||
| @@ -79,10 +80,8 @@ ODBCOracleTest::~ODBCOracleTest() | ||||
| } | ||||
|  | ||||
|  | ||||
| void ODBCOracleTest::testBareboneODBC() | ||||
| void ODBCOracleTest::testBarebone() | ||||
| { | ||||
| 	if (!_pSession) fail ("Test not available."); | ||||
|  | ||||
| 	std::string tableCreateString = "CREATE TABLE Test " | ||||
| 		"(First VARCHAR(30)," | ||||
| 		"Second VARCHAR(30)," | ||||
| @@ -1297,6 +1296,15 @@ bool ODBCOracleTest::init(const std::string& driver, const std::string& dsn) | ||||
| 	 | ||||
| 	_pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession); | ||||
|  | ||||
| 	// Workaround: | ||||
| 	// | ||||
| 	// Barebone ODBC test is called initially for Oracle only. | ||||
| 	// The test framework does not exit cleanly if | ||||
| 	// Oracle tests are enabled (i.e. Oracle driver is found)  | ||||
| 	// but no tests are executed. | ||||
| 	// The exact reason for this behavior is unknown at this time. | ||||
| 	testBarebone(); | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -131,6 +131,12 @@ public: | ||||
| 	static CppUnit::Test* suite(); | ||||
|  | ||||
| private: | ||||
| 	typedef Poco::Data::ODBC::Utility::DriverMap Drivers; | ||||
| 	typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr; | ||||
| 	typedef Poco::SharedPtr<SQLExecutor>         ExecPtr; | ||||
|  | ||||
| 	static void testBarebone(); | ||||
| 	 | ||||
| 	void dropObject(const std::string& type, const std::string& name); | ||||
| 	void recreatePersonTable(); | ||||
| 	void recreatePersonBLOBTable(); | ||||
| @@ -145,12 +151,18 @@ private: | ||||
| 	static bool init(const std::string& driver, const std::string& dsn); | ||||
| 	static bool canConnect(const std::string& driver, const std::string& dsn); | ||||
|  | ||||
| 	static Poco::Data::ODBC::Utility::DriverMap _drivers; | ||||
| 	static Drivers     _drivers; | ||||
| 	static std::string _dbConnString; | ||||
| 	static Poco::SharedPtr<Poco::Data::Session> _pSession; | ||||
| 	static Poco::SharedPtr<SQLExecutor> _pExecutor; | ||||
| 	static const bool bindValues[8]; | ||||
| 	static SessionPtr  _pSession; | ||||
| 	static ExecPtr     _pExecutor; | ||||
| 	static const bool  bindValues[8]; | ||||
| }; | ||||
|  | ||||
|  | ||||
| inline void ODBCOracleTest::testBareboneODBC() | ||||
| { | ||||
| 	return testBarebone(); | ||||
| } | ||||
|  | ||||
|  | ||||
| #endif // ODBCOracleTest_INCLUDED | ||||
|   | ||||
| @@ -51,22 +51,25 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::ODBCException; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::ODBCException; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::Tuple; | ||||
| using Poco::DateTime; | ||||
| using Poco::NotFoundException; | ||||
|  | ||||
|  | ||||
| const bool ODBCPostgreSQLTest::bindValues[8] = {true, true, true, false, false, true, false, false}; | ||||
| Poco::SharedPtr<Poco::Data::Session> ODBCPostgreSQLTest::_pSession = 0; | ||||
| Poco::SharedPtr<SQLExecutor> ODBCPostgreSQLTest::_pExecutor = 0; | ||||
| std::string ODBCPostgreSQLTest::_dbConnString; | ||||
| Poco::Data::ODBC::Utility::DriverMap ODBCPostgreSQLTest::_drivers; | ||||
| ODBCPostgreSQLTest::SessionPtr  ODBCPostgreSQLTest::_pSession = 0; | ||||
| ODBCPostgreSQLTest::ExecPtr ODBCPostgreSQLTest::_pExecutor = 0; | ||||
| std::string                     ODBCPostgreSQLTest::_dbConnString; | ||||
| ODBCPostgreSQLTest::Drivers     ODBCPostgreSQLTest::_drivers; | ||||
| const bool                      ODBCPostgreSQLTest::bindValues[8] =  | ||||
| 	{true, true, true, false, false, true, false, false}; | ||||
|  | ||||
|  | ||||
| #ifdef POCO_OS_FAMILY_WINDOWS | ||||
| const std::string ODBCPostgreSQLTest::libDir = "C:\\\\Program Files\\\\PostgreSQL\\\\8.2\\\\lib\\\\"; | ||||
| #else | ||||
| @@ -1222,7 +1225,7 @@ bool ODBCPostgreSQLTest::init(const std::string& driver, const std::string& dsn) | ||||
| CppUnit::Test* ODBCPostgreSQLTest::suite() | ||||
| { | ||||
| 	if (init("PostgreSQL ANSI", "PocoDataPostgreSQLTest")) | ||||
| 	//if (init("Mammoth ODBCng Beta", "Mammoth ODBCng beta")) | ||||
| 	//if (init("Mammoth ODBCng Beta", "Mammoth ODBCng Beta")) | ||||
| 	{ | ||||
| 		CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest"); | ||||
|  | ||||
|   | ||||
| @@ -132,6 +132,10 @@ public: | ||||
| 	static CppUnit::Test* suite(); | ||||
|  | ||||
| private: | ||||
| 	typedef Poco::Data::ODBC::Utility::DriverMap Drivers; | ||||
| 	typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr; | ||||
| 	typedef Poco::SharedPtr<SQLExecutor>         ExecPtr; | ||||
|  | ||||
| 	void dropObject(const std::string& type, const std::string& name); | ||||
| 	void recreatePersonTable(); | ||||
| 	void recreatePersonBLOBTable(); | ||||
| @@ -154,11 +158,12 @@ private: | ||||
| 		/// modify the function and recompile. | ||||
| 		/// Alternative is direct database configuration for PL/pgSQL usage. | ||||
|  | ||||
| 	static Poco::Data::ODBC::Utility::DriverMap _drivers; | ||||
| 	static Drivers     _drivers; | ||||
| 	static std::string _dbConnString; | ||||
| 	static Poco::SharedPtr<Poco::Data::Session> _pSession; | ||||
| 	static Poco::SharedPtr<SQLExecutor> _pExecutor; | ||||
| 	static const bool bindValues[8]; | ||||
| 	static SessionPtr  _pSession; | ||||
| 	static ExecPtr     _pExecutor; | ||||
| 	static const bool  bindValues[8]; | ||||
|  | ||||
| 	static const std::string libDir; | ||||
| 		/// Varible determining the location of the library directory | ||||
| 		/// on the database installation system. | ||||
|   | ||||
| @@ -51,21 +51,22 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::Tuple; | ||||
| using Poco::DateTime; | ||||
| using Poco::NotFoundException; | ||||
|  | ||||
|  | ||||
| const bool ODBCSQLServerTest::bindValues[8] = {true, true, true, false, false, true, false, false}; | ||||
| Poco::SharedPtr<Poco::Data::Session> ODBCSQLServerTest::_pSession = 0; | ||||
| Poco::SharedPtr<SQLExecutor> ODBCSQLServerTest::_pExecutor = 0; | ||||
| std::string ODBCSQLServerTest::_dbConnString; | ||||
| Poco::Data::ODBC::Utility::DriverMap ODBCSQLServerTest::_drivers; | ||||
| ODBCSQLServerTest::SessionPtr ODBCSQLServerTest::_pSession = 0; | ||||
| ODBCSQLServerTest::ExecPtr    ODBCSQLServerTest::_pExecutor = 0; | ||||
| std::string                   ODBCSQLServerTest::_dbConnString; | ||||
| ODBCSQLServerTest::Drivers    ODBCSQLServerTest::_drivers; | ||||
| const bool                    ODBCSQLServerTest::bindValues[8] =  | ||||
| 	{true, true, true, false, false, true, false, false}; | ||||
|  | ||||
|  | ||||
| ODBCSQLServerTest::ODBCSQLServerTest(const std::string& name):  | ||||
|   | ||||
| @@ -134,6 +134,10 @@ public: | ||||
| 	static CppUnit::Test* suite(); | ||||
|  | ||||
| private: | ||||
| 	typedef Poco::Data::ODBC::Utility::DriverMap Drivers; | ||||
| 	typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr; | ||||
| 	typedef Poco::SharedPtr<SQLExecutor>         ExecPtr; | ||||
|  | ||||
| 	void dropObject(const std::string& type, const std::string& name); | ||||
| 	void recreatePersonTable(); | ||||
| 	void recreatePersonBLOBTable(); | ||||
| @@ -149,10 +153,10 @@ private: | ||||
| 	static bool init(const std::string& driver, const std::string& dsn); | ||||
| 	static bool canConnect(const std::string& driver, const std::string& dsn); | ||||
|  | ||||
| 	static Poco::Data::ODBC::Utility::DriverMap _drivers; | ||||
| 	static Drivers     _drivers; | ||||
| 	static std::string _dbConnString; | ||||
| 	static Poco::SharedPtr<Poco::Data::Session> _pSession; | ||||
| 	static Poco::SharedPtr<SQLExecutor> _pExecutor; | ||||
| 	static SessionPtr  _pSession; | ||||
| 	static ExecPtr     _pExecutor; | ||||
| 	static const bool bindValues[8]; | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -49,19 +49,20 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::NotFoundException; | ||||
|  | ||||
|  | ||||
| const bool ODBCSQLiteTest::bindValues[8] = {true, true, true, false, false, true, false, false}; | ||||
| Poco::SharedPtr<Poco::Data::Session> ODBCSQLiteTest::_pSession = 0; | ||||
| Poco::SharedPtr<SQLExecutor> ODBCSQLiteTest::_pExecutor = 0; | ||||
| std::string ODBCSQLiteTest::_dbConnString; | ||||
| Poco::Data::ODBC::Utility::DriverMap ODBCSQLiteTest::_drivers; | ||||
| ODBCSQLiteTest::SessionPtr  ODBCSQLiteTest::_pSession = 0; | ||||
| ODBCSQLiteTest::ExecPtr ODBCSQLiteTest::_pExecutor = 0; | ||||
| std::string                 ODBCSQLiteTest::_dbConnString; | ||||
| ODBCSQLiteTest::Drivers     ODBCSQLiteTest::_drivers; | ||||
| const bool                  ODBCSQLiteTest::bindValues[8] =  | ||||
| 	{true, true, true, false, false, true, false, false}; | ||||
|  | ||||
|  | ||||
| ODBCSQLiteTest::ODBCSQLiteTest(const std::string& name):  | ||||
|   | ||||
| @@ -128,6 +128,10 @@ public: | ||||
| 	static CppUnit::Test* suite(); | ||||
|  | ||||
| private: | ||||
| 	typedef Poco::Data::ODBC::Utility::DriverMap Drivers; | ||||
| 	typedef Poco::SharedPtr<Poco::Data::Session> SessionPtr; | ||||
| 	typedef Poco::SharedPtr<SQLExecutor>         ExecPtr; | ||||
|  | ||||
| 	void dropObject(const std::string& type, const std::string& name); | ||||
| 	void recreatePersonTable(); | ||||
| 	void recreatePersonBLOBTable(); | ||||
| @@ -142,11 +146,11 @@ private: | ||||
| 	static bool init(const std::string& driver, const std::string& dsn); | ||||
| 	static bool canConnect(const std::string& driver, const std::string& dsn); | ||||
|  | ||||
| 	static Poco::Data::ODBC::Utility::DriverMap _drivers; | ||||
| 	static Drivers     _drivers; | ||||
| 	static std::string _dbConnString; | ||||
| 	static Poco::SharedPtr<Poco::Data::Session> _pSession; | ||||
| 	static Poco::SharedPtr<SQLExecutor> _pExecutor; | ||||
| 	static const bool bindValues[8]; | ||||
| 	static SessionPtr  _pSession; | ||||
| 	static ExecPtr     _pExecutor; | ||||
| 	static const bool  bindValues[8]; | ||||
| }; | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -56,16 +56,19 @@ CppUnit::Test* ODBCTestSuite::suite() | ||||
| 	// nativeError=160  | ||||
| 	// System error 127 is "The specified procedure could not be found." | ||||
| 	// | ||||
| 	// 2) When Oracle test is loaded after DB2, the test application does not exit cleanly. | ||||
| 	//    All tests pass, though. | ||||
| 	// Workaround is to connect to DB2 after connecting to PostgreSQL. | ||||
| 	// | ||||
| 	// Workaround is to connect to DB2 after connecting to PostgreSQL and Oracle. | ||||
| 	// The reason causing these errors is not known. | ||||
| 	// 2) When Oracle driver is found, but no tests executed, the test application does not exit cleanly. | ||||
| 	// | ||||
| 	// Workaround is to run barebone ODBC test upon initialization of Oracle test. | ||||
| 	// (see ODBCOracleTest::init()) | ||||
| 	// | ||||
| 	// The reason causing the above errors is not known at this time. | ||||
|  | ||||
| 	addTest(pSuite, ODBCOracleTest::suite()); | ||||
| 	addTest(pSuite, ODBCPostgreSQLTest::suite()); | ||||
| 	addTest(pSuite, ODBCDB2Test::suite()); | ||||
| 	addTest(pSuite, ODBCMySQLTest::suite()); | ||||
| 	addTest(pSuite, ODBCOracleTest::suite()); | ||||
| 	addTest(pSuite, ODBCSQLiteTest::suite()); | ||||
| 	addTest(pSuite, ODBCSQLServerTest::suite()); | ||||
| #if defined(POCO_OS_FAMILY_WINDOWS) | ||||
|   | ||||
| @@ -56,12 +56,12 @@ | ||||
|  | ||||
|  | ||||
| using namespace Poco::Data; | ||||
| using Poco::Data::ODBC::Utility; | ||||
| using Poco::Data::ODBC::Preparation; | ||||
| using Poco::Data::ODBC::ConnectionException; | ||||
| using Poco::Data::ODBC::StatementException; | ||||
| using Poco::Data::ODBC::DataTruncatedException; | ||||
| using Poco::Data::ODBC::StatementDiagnostics; | ||||
| using ODBC::Utility; | ||||
| using ODBC::Preparation; | ||||
| using ODBC::ConnectionException; | ||||
| using ODBC::StatementException; | ||||
| using ODBC::DataTruncatedException; | ||||
| using ODBC::StatementDiagnostics; | ||||
| using Poco::format; | ||||
| using Poco::Tuple; | ||||
| using Poco::Any; | ||||
| @@ -1832,6 +1832,12 @@ void SQLExecutor::dateTime() | ||||
| 	catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } | ||||
| 	catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } | ||||
| 	assert (res == born); | ||||
|  | ||||
| 	Statement stmt = (*_pSession << "SELECT Born FROM Person", now); | ||||
| 	RecordSet rset(stmt); | ||||
|  | ||||
| 	res = rset["Born"].convert<DateTime>(); | ||||
| 	assert (res == born); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -294,6 +294,31 @@ public: | ||||
| 		throw Poco::BadCastException(); | ||||
| 	} | ||||
|  | ||||
| 	void convert(Poco::Timestamp& val) const | ||||
| 	{ | ||||
| 		throw Poco::BadCastException(); | ||||
| 	} | ||||
|  | ||||
| 	void convert(Poco::DateTime& val) const | ||||
| 	{ | ||||
| 		throw Poco::BadCastException(); | ||||
| 	} | ||||
|  | ||||
| 	void convert(Poco::LocalDateTime& val) const | ||||
| 	{ | ||||
| 		throw Poco::BadCastException(); | ||||
| 	} | ||||
|  | ||||
| 	bool isArray() const | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	virtual bool isStruct() const | ||||
| 	{ | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	void convert(std::string& val) const | ||||
| 	{ | ||||
| 		val.assign(_val.begin(), _val.end()); | ||||
|   | ||||
| @@ -36,6 +36,10 @@ | ||||
|  | ||||
| #include "Poco/Data/RecordSet.h" | ||||
| #include "Poco/Data/Session.h" | ||||
| #include "Poco/DateTime.h" | ||||
|  | ||||
|  | ||||
| using Poco::DateTime; | ||||
|  | ||||
|  | ||||
| namespace Poco { | ||||
| @@ -77,18 +81,19 @@ DynamicAny RecordSet::value(std::size_t col, std::size_t row) const | ||||
| 	switch (columnType(col)) | ||||
| 	{ | ||||
| 		case MetaColumn::FDT_BOOL: | ||||
| 		case MetaColumn::FDT_INT8:   return value<Int8>(col, row); | ||||
| 		case MetaColumn::FDT_UINT8:  return value<UInt8>(col, row); | ||||
| 		case MetaColumn::FDT_INT16:  return value<Int16>(col, row); | ||||
| 		case MetaColumn::FDT_UINT16: return value<UInt16>(col, row); | ||||
| 		case MetaColumn::FDT_INT32:	 return value<Int32>(col, row); | ||||
| 		case MetaColumn::FDT_UINT32: return value<UInt32>(col, row); | ||||
| 		case MetaColumn::FDT_INT64:  return value<Int64>(col, row); | ||||
| 		case MetaColumn::FDT_UINT64: return value<UInt64>(col, row); | ||||
| 		case MetaColumn::FDT_FLOAT:  return value<float>(col, row); | ||||
| 		case MetaColumn::FDT_DOUBLE: return value<double>(col, row); | ||||
| 		case MetaColumn::FDT_STRING: return value<std::string>(col, row); | ||||
| 		case MetaColumn::FDT_BLOB:   return value<BLOB>(col, row); | ||||
| 		case MetaColumn::FDT_INT8:      return value<Int8>(col, row); | ||||
| 		case MetaColumn::FDT_UINT8:     return value<UInt8>(col, row); | ||||
| 		case MetaColumn::FDT_INT16:     return value<Int16>(col, row); | ||||
| 		case MetaColumn::FDT_UINT16:    return value<UInt16>(col, row); | ||||
| 		case MetaColumn::FDT_INT32:	    return value<Int32>(col, row); | ||||
| 		case MetaColumn::FDT_UINT32:    return value<UInt32>(col, row); | ||||
| 		case MetaColumn::FDT_INT64:     return value<Int64>(col, row); | ||||
| 		case MetaColumn::FDT_UINT64:    return value<UInt64>(col, row); | ||||
| 		case MetaColumn::FDT_FLOAT:     return value<float>(col, row); | ||||
| 		case MetaColumn::FDT_DOUBLE:    return value<double>(col, row); | ||||
| 		case MetaColumn::FDT_STRING:    return value<std::string>(col, row); | ||||
| 		case MetaColumn::FDT_BLOB:      return value<BLOB>(col, row); | ||||
| 		case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(col, row); | ||||
| 		default: | ||||
| 			throw Poco::InvalidArgumentException("Data type not supported."); | ||||
| 	} | ||||
| @@ -100,18 +105,19 @@ DynamicAny RecordSet::value(const std::string& name, std::size_t row) const | ||||
| 	switch (columnType(name)) | ||||
| 	{ | ||||
| 		case MetaColumn::FDT_BOOL: | ||||
| 		case MetaColumn::FDT_INT8:   return value<Int8>(name, row); | ||||
| 		case MetaColumn::FDT_UINT8:  return value<UInt8>(name, row); | ||||
| 		case MetaColumn::FDT_INT16:  return value<Int16>(name, row); | ||||
| 		case MetaColumn::FDT_UINT16: return value<UInt16>(name, row); | ||||
| 		case MetaColumn::FDT_INT32:	 return value<Int32>(name, row); | ||||
| 		case MetaColumn::FDT_UINT32: return value<UInt32>(name, row); | ||||
| 		case MetaColumn::FDT_INT64:  return value<Int64>(name, row); | ||||
| 		case MetaColumn::FDT_UINT64: return value<UInt64>(name, row); | ||||
| 		case MetaColumn::FDT_FLOAT:  return value<float>(name, row); | ||||
| 		case MetaColumn::FDT_DOUBLE: return value<double>(name, row); | ||||
| 		case MetaColumn::FDT_STRING: return value<std::string>(name, row); | ||||
| 		case MetaColumn::FDT_BLOB:   return value<BLOB>(name, row); | ||||
| 		case MetaColumn::FDT_INT8:      return value<Int8>(name, row); | ||||
| 		case MetaColumn::FDT_UINT8:     return value<UInt8>(name, row); | ||||
| 		case MetaColumn::FDT_INT16:     return value<Int16>(name, row); | ||||
| 		case MetaColumn::FDT_UINT16:    return value<UInt16>(name, row); | ||||
| 		case MetaColumn::FDT_INT32:	    return value<Int32>(name, row); | ||||
| 		case MetaColumn::FDT_UINT32:    return value<UInt32>(name, row); | ||||
| 		case MetaColumn::FDT_INT64:     return value<Int64>(name, row); | ||||
| 		case MetaColumn::FDT_UINT64:    return value<UInt64>(name, row); | ||||
| 		case MetaColumn::FDT_FLOAT:     return value<float>(name, row); | ||||
| 		case MetaColumn::FDT_DOUBLE:    return value<double>(name, row); | ||||
| 		case MetaColumn::FDT_STRING:    return value<std::string>(name, row); | ||||
| 		case MetaColumn::FDT_BLOB:      return value<BLOB>(name, row); | ||||
| 		case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(name, row); | ||||
| 		default: | ||||
| 			throw Poco::InvalidArgumentException("Data type not supported."); | ||||
| 	} | ||||
|   | ||||
| @@ -91,6 +91,12 @@ bool SessionImpl::isConnected() | ||||
| } | ||||
|  | ||||
|  | ||||
| bool SessionImpl::isTransaction() | ||||
| { | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool SessionImpl::getConnected(const std::string& name) | ||||
| { | ||||
| 	return _connected; | ||||
|   | ||||
| @@ -75,6 +75,9 @@ public: | ||||
| 		/// Returns true if session is connected to the database,  | ||||
| 		/// false otherwise. | ||||
|  | ||||
| 	bool isTransaction(); | ||||
| 		/// Returns true iff a transaction is a transaction is in progress, false otherwise. | ||||
|  | ||||
| 	void setConnected(const std::string& name, bool value); | ||||
| 	bool getConnected(const std::string& name); | ||||
| 		/// Sets/gets the connected property. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Aleksandar Fabijanic
					Aleksandar Fabijanic