Auxiliary class for connection to data base.
More...
#include <JDB.hh>
|
static const Server & | getServer () |
| Get server.
|
|
static void | setServer (const Server &server) |
| Set server.
|
|
static JDB & | get () |
| Get connection to database.
|
|
static void | reset () |
| Reset connection to database.
|
|
static void | reset (const std::string &usr, const std::string &pwd) |
| Reset connection to database.
|
|
static void | reset (const std::string &cookie) |
| Reset connection to database.
|
|
static void | reset (const std::string &usr, const std::string &pwd, const std::string &cookie) |
| Reset connection to database.
|
|
Auxiliary class for connection to data base.
Definition at line 191 of file JDB.hh.
◆ JDB() [1/2]
Default constructor.
Definition at line 339 of file JDB.hh.
◆ JDB() [2/2]
JDATABASE::JDB::JDB |
( |
const JDB & | | ) |
|
|
private |
◆ get_server()
static Server & JDATABASE::JDB::get_server |
( |
| ) |
|
|
inlinestaticprivate |
Get server.
- Returns
- server
Definition at line 200 of file JDB.hh.
201 {
203
204 return server;
205 }
const Server & getServer()
Get default server.
◆ getServer()
static const Server & JDATABASE::JDB::getServer |
( |
| ) |
|
|
inlinestatic |
Get server.
- Returns
- server
Definition at line 213 of file JDB.hh.
214 {
216 }
static Server & get_server()
Get server.
◆ setServer()
static void JDATABASE::JDB::setServer |
( |
const Server & | server | ) |
|
|
inlinestatic |
Set server.
- Parameters
-
Definition at line 224 of file JDB.hh.
◆ get()
static JDB & JDATABASE::JDB::get |
( |
| ) |
|
|
inlinestatic |
Get connection to database.
- Returns
- database connection
Definition at line 235 of file JDB.hh.
236 {
238
239 return db;
240 }
◆ reset() [1/4]
static void JDATABASE::JDB::reset |
( |
| ) |
|
|
inlinestatic |
Reset connection to database.
Definition at line 246 of file JDB.hh.
247 {
249
250 if (db.get() != NULL) {
251 db->Close();
252 static_cast<std::shared_ptr<Client>&
>(db).
reset();
253 }
254 }
static void reset()
Reset connection to database.
static JDB & get()
Get connection to database.
◆ reset() [2/4]
static void JDATABASE::JDB::reset |
( |
const std::string & | usr, |
|
|
const std::string & | pwd ) |
|
inlinestatic |
Reset connection to database.
- Parameters
-
usr | user name |
pwd | pass word |
Definition at line 263 of file JDB.hh.
265 {
266 static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(
getServer(), usr.c_str(), pwd.c_str());
267 }
static const Server & getServer()
Get server.
◆ reset() [3/4]
static void JDATABASE::JDB::reset |
( |
const std::string & | cookie | ) |
|
|
inlinestatic |
Reset connection to database.
- Parameters
-
Definition at line 275 of file JDB.hh.
276 {
279
280 string buffer = cookie;
281
282 if (getFileStatus(cookie.c_str())) {
283
284 ifstream in(cookie.c_str());
285
287
288 in.close();
289 }
290
292
293 if (pos != string::npos) {
294 buffer.erase(0, pos);
295 }
296
297 static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(
getServer(), buffer.c_str());
298 }
static const char PREFIX_COOKIE
Cookie prefix.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
◆ reset() [4/4]
static void JDATABASE::JDB::reset |
( |
const std::string & | usr, |
|
|
const std::string & | pwd, |
|
|
const std::string & | cookie ) |
|
inlinestatic |
Reset connection to database.
An attempt to make a connection to the database is made in the following order, using:
- user name and password, if neither empty;
- given cookie, if not empty;
- private cookie file (created with JCookie.sh);
- public cookie (defined by environment variable DBCOOKIE);
- Parameters
-
usr | user name |
pwd | password |
cookie | persistent cookie |
Definition at line 315 of file JDB.hh.
318 {
321
322 if (usr != "" && pwd != "")
324 else if (cookie != "")
330 else
332 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
const char * getPrivateCookie()
Get private cookie.
const char * getPublicCookie()
Get public cookie.
◆ operator=()
JDB & JDATABASE::JDB::operator= |
( |
const JDB & | | ) |
|
|
private |
The documentation for this class was generated from the following file: