mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 18:45:10 +01:00
Adding property to SQLite SessionImpl as solution for issue #248
This commit is contained in:
parent
98db64fa04
commit
0ba87ea2c2
@ -117,6 +117,10 @@ public:
|
||||
const std::string& connectorName() const;
|
||||
/// Returns the name of the connector.
|
||||
|
||||
protected:
|
||||
void setConnectionTimeout(const std::string& prop, const Poco::Any& value);
|
||||
Poco::Any getConnectionTimeout(const std::string& prop);
|
||||
|
||||
private:
|
||||
std::string _connector;
|
||||
sqlite3* _pDB;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/Data/DataException.h"
|
||||
#include "Poco/NumberParser.h"
|
||||
#include "sqlite3.h"
|
||||
#include <cstdlib>
|
||||
|
||||
@ -51,6 +52,7 @@ SessionImpl::SessionImpl(const std::string& fileName, std::size_t loginTimeout):
|
||||
addFeature("autoCommit",
|
||||
&SessionImpl::autoCommit,
|
||||
&SessionImpl::isAutoCommit);
|
||||
addProperty("connectionTimeout", &SessionImpl::setConnectionTimeout, &SessionImpl::getConnectionTimeout);
|
||||
}
|
||||
|
||||
|
||||
@ -212,6 +214,19 @@ void SessionImpl::setConnectionTimeout(std::size_t timeout)
|
||||
}
|
||||
|
||||
|
||||
void SessionImpl::setConnectionTimeout(const std::string& prop, const Poco::Any& value)
|
||||
{
|
||||
int timeout = Poco::RefAnyCast<std::size_t>(value);
|
||||
setConnectionTimeout(timeout);
|
||||
}
|
||||
|
||||
|
||||
Poco::Any SessionImpl::getConnectionTimeout(const std::string& prop)
|
||||
{
|
||||
return Poco::Any(_timeout/1000);
|
||||
}
|
||||
|
||||
|
||||
void SessionImpl::autoCommit(const std::string&, bool)
|
||||
{
|
||||
// The problem here is to decide whether to call commit or rollback
|
||||
|
Loading…
Reference in New Issue
Block a user