mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-18 03:29:47 +02:00
SF [2643953] Improve Data::Session connection
This commit is contained in:
@@ -62,7 +62,8 @@ public:
|
||||
virtual const std::string& name() const;
|
||||
/// Returns the name associated with this connector.
|
||||
|
||||
virtual Poco::AutoPtr<Poco::Data::SessionImpl> createSession(const std::string& connectionString);
|
||||
virtual Poco::AutoPtr<Poco::Data::SessionImpl> createSession(const std::string& connectionString,
|
||||
std::size_t timeout = Poco::Data::SessionImpl::CONNECT_TIMEOUT_DEFAULT);
|
||||
/// Creates a MySQL SessionImpl object and initializes it with the given connectionString.
|
||||
|
||||
static void registerConnector();
|
||||
|
@@ -59,12 +59,18 @@ public:
|
||||
~SessionHandle();
|
||||
/// Destroy handle, close connection
|
||||
|
||||
void init(MYSQL* mysql = 0);
|
||||
/// Initializes the handle iff not initialized.
|
||||
|
||||
void options(mysql_option opt);
|
||||
/// Set connection options
|
||||
|
||||
void options(mysql_option opt, bool b);
|
||||
/// Set connection options
|
||||
|
||||
void options(mysql_option opt, unsigned int i);
|
||||
/// Set connection options
|
||||
|
||||
void connect(const char* host, const char* user, const char* password, const char* db, unsigned int port);
|
||||
/// Connect to server
|
||||
|
||||
|
@@ -62,7 +62,8 @@ public:
|
||||
static const std::string MYSQL_REPEATABLE_READ;
|
||||
static const std::string MYSQL_SERIALIZABLE;
|
||||
|
||||
SessionImpl(const std::string& connectionString);
|
||||
SessionImpl(const std::string& connectionString,
|
||||
std::size_t timeout = CONNECT_TIMEOUT_DEFAULT);
|
||||
/// Creates the SessionImpl. Opens a connection to the database
|
||||
///
|
||||
/// Connection string format:
|
||||
@@ -81,6 +82,15 @@ public:
|
||||
Poco::Data::StatementImpl* createStatementImpl();
|
||||
/// Returns an MySQL StatementImpl
|
||||
|
||||
void open(const std::string& connection = "");
|
||||
/// Opens a connection to the database.
|
||||
|
||||
void close();
|
||||
/// Closes the connection.
|
||||
|
||||
bool isConnected();
|
||||
/// Returns true if connected, false otherwise.
|
||||
|
||||
void begin();
|
||||
/// Starts a transaction
|
||||
|
||||
@@ -90,12 +100,6 @@ public:
|
||||
void rollback();
|
||||
/// Aborts a transaction
|
||||
|
||||
void close();
|
||||
/// Closes the connection
|
||||
|
||||
bool isConnected();
|
||||
/// Returns true if connected, false otherwise.
|
||||
|
||||
bool canTransact();
|
||||
/// Returns true if session has transaction capabilities.
|
||||
|
||||
@@ -163,10 +167,10 @@ private:
|
||||
return getValue<T>(pResult, val);
|
||||
}
|
||||
|
||||
std::string _connector;
|
||||
SessionHandle _handle;
|
||||
bool _connected;
|
||||
bool _inTransaction;
|
||||
std::string _connector;
|
||||
SessionHandle _handle;
|
||||
bool _connected;
|
||||
bool _inTransaction;
|
||||
Poco::FastMutex _mutex;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user