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 190 of file JDB.hh.
◆ JDB() [1/2]
Default constructor.
Definition at line 338 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 199 of file JDB.hh.
200 {
202
203 return server;
204 }
const Server & getServer()
Get default server.
◆ getServer()
static const Server & JDATABASE::JDB::getServer |
( |
| ) |
|
|
inlinestatic |
Get server.
- Returns
- server
Definition at line 212 of file JDB.hh.
213 {
215 }
static Server & get_server()
Get server.
◆ setServer()
static void JDATABASE::JDB::setServer |
( |
const Server & | server | ) |
|
|
inlinestatic |
Set server.
- Parameters
-
Definition at line 223 of file JDB.hh.
◆ get()
static JDB & JDATABASE::JDB::get |
( |
| ) |
|
|
inlinestatic |
Get connection to database.
- Returns
- database connection
Definition at line 234 of file JDB.hh.
235 {
237
238 return db;
239 }
◆ reset() [1/4]
static void JDATABASE::JDB::reset |
( |
| ) |
|
|
inlinestatic |
Reset connection to database.
Definition at line 245 of file JDB.hh.
246 {
248
249 if (db.get() != NULL) {
250 db->Close();
251 static_cast<std::shared_ptr<Client>&
>(db).
reset();
252 }
253 }
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 262 of file JDB.hh.
264 {
265 static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(
getServer(), usr.c_str(), pwd.c_str());
266 }
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 274 of file JDB.hh.
275 {
278
279 string buffer = cookie;
280
281 if (getFileStatus(cookie.c_str())) {
282
283 ifstream in(cookie.c_str());
284
286
287 in.close();
288 }
289
291
292 if (pos != string::npos) {
293 buffer.erase(0, pos);
294 }
295
296 static_cast<std::shared_ptr<Client>&
>(
JDB::get()) = Client::Create(
getServer(), buffer.c_str());
297 }
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 314 of file JDB.hh.
317 {
320
321 if (usr != "" && pwd != "")
323 else if (cookie != "")
329 else
331 }
#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: