Hall-D Software
alpha
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
DESDBProviderMySQL.h
Go to the documentation of this file.
1
// $Id$
2
//
3
// File: DESDBProviderMySQL.h
4
// Creator: sdobbs
5
//
6
// Interface for EventStore database connection
7
//
8
9
#ifndef _DESDBProviderMySQL_
10
#define _DESDBProviderMySQL_
11
12
#include "
DESDBProvider.h
"
13
14
#include <iostream>
15
#include <sstream>
16
17
#include <JANA/jerror.h>
18
#include <JANA/JException.h>
19
#include <JANA/JStreamLog.h>
20
#include <mysql.h>
21
22
23
using namespace
jana;
24
using namespace
std;
25
26
27
class
DESDBProviderMySQL
:
public
DESDBProvider
{
28
public
:
29
DESDBProviderMySQL
(
string
connection_str);
30
virtual
~
DESDBProviderMySQL
();
31
32
bool
Open();
33
34
// accessors
35
bool
GetGrades(vector<string> &grades);
36
bool
GetSkims(vector<string> &grades,
string
timestamp,
string
grade);
37
38
protected
:
39
// MySQL connection information
40
string
user_name
;
41
string
password
;
42
string
host_name
;
43
string
database
;
44
int
port
;
45
46
MYSQL *
DBptr
;
47
MYSQL_RES *
DBresult
;
48
bool
is_connected
;
49
50
// allow for connecting/disconnecting to MySQL DB so that we don't always keep
51
// the connection open
52
bool
Connect();
53
void
Disconnect();
54
inline
bool
IsConnected
() {
return
is_connected; }
55
56
// misc functions
57
inline
string
FormatMySQLError
(
string
mysql_func_name) {
58
stringstream ss;
59
ss << mysql_func_name <<
" failed: Error "
<< mysql_errno(DBptr)
60
<<
" ("
<< mysql_error(DBptr) <<
")"
;
61
return
ss.str();
62
}
63
64
};
65
66
#endif // _DESDBProviderMySQL_
DESDBProviderMySQL
Definition:
DESDBProviderMySQL.h:27
DESDBProviderMySQL::user_name
string user_name
Definition:
DESDBProviderMySQL.h:40
DESDBProviderMySQL::is_connected
bool is_connected
Definition:
DESDBProviderMySQL.h:48
DESDBProviderMySQL::password
string password
Definition:
DESDBProviderMySQL.h:41
DESDBProviderMySQL::DBresult
MYSQL_RES * DBresult
Definition:
DESDBProviderMySQL.h:47
DESDBProviderMySQL::FormatMySQLError
string FormatMySQLError(string mysql_func_name)
Definition:
DESDBProviderMySQL.h:57
DESDBProvider.h
DESDBProvider
Definition:
DESDBProvider.h:23
DESDBProviderMySQL::port
int port
Definition:
DESDBProviderMySQL.h:44
DESDBProviderMySQL::DBptr
MYSQL * DBptr
Definition:
DESDBProviderMySQL.h:46
DESDBProviderMySQL::IsConnected
bool IsConnected()
Definition:
DESDBProviderMySQL.h:54
DESDBProviderMySQL::database
string database
Definition:
DESDBProviderMySQL.h:43
DESDBProviderMySQL::host_name
string host_name
Definition:
DESDBProviderMySQL.h:42
libraries
EVENTSTORE
DESDBProviderMySQL.h
Generated on Fri Jul 26 2019 14:00:31 for Hall-D Software by
1.8.5