forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionHandle.h
More file actions
100 lines (69 loc) · 1.78 KB
/
SessionHandle.h
File metadata and controls
100 lines (69 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//
// SesssionHandle.h
//
// Library: Data/MySQL
// Package: MySQL
// Module: SessionHandle
//
// Definition of the SessionHandle class.
//
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_MySQL_SessionHandle_INCLUDED
#define Data_MySQL_SessionHandle_INCLUDED
#include <mysql.h>
#include "Poco/Data/MySQL/MySQLException.h"
namespace Poco {
namespace Data {
namespace MySQL {
class SessionHandle
/// MySQL session handle
{
public:
explicit SessionHandle(MYSQL* mysql);
/// Creates session handle
~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, const char* c);
/// 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
void close();
/// Close connection
void startTransaction();
/// Start transaction
void commit();
/// Commit transaction
void rollback();
/// Rollback transaction
void reset();
/// Reset connection with dababase and clears session state, but without disconnecting
bool ping();
/// Checks if the connection is alive.
operator MYSQL* ();
private:
SessionHandle(const SessionHandle&);
SessionHandle& operator=(const SessionHandle&);
private:
MYSQL* _pHandle;
};
//
// inlines
//
inline SessionHandle::operator MYSQL* ()
{
return _pHandle;
}
} } } // namespace Poco::Data::MySQL
#endif // Data_MySQL_SessionHandle_INCLUDED