Electroneum
Loading...
Searching...
No Matches
epee::ado_db_helper::per_thread_connection_pool Class Reference

#include <ado_db_helper.h>

Public Member Functions

bool init (const std::string &connection_string, const std::string &login, const std::string &pass)
ADODB::_ConnectionPtr & get_db_connection ()
bool check_status ()

Detailed Description

Definition at line 931 of file ado_db_helper.h.

Member Function Documentation

◆ check_status()

bool epee::ado_db_helper::per_thread_connection_pool::check_status ( )
inline

Definition at line 984 of file ado_db_helper.h.

985 {
986 ADODB::_ConnectionPtr& rconn = get_db_connection();
987 if(!ado_db_helper::execute_helper(rconn, "SET CLIENT_ENCODING TO 'SQL_ASCII'"))
988 {
989
990 try{
991 HRESULT res = rconn->Close();
992 }
993 catch(...)
994 {
995
996 };
998
999 HRESULT res = rconn->Open(_bstr_t(m_connection_string.c_str()), _bstr_t(m_login.c_str()), _bstr_t(m_password.c_str()), NULL);
1000 if(res != S_OK)
1001 {
1002 LOG_PRINT("Failed to restore connection to local AI DB", LOG_LEVEL_1);
1003 return false;
1004 }
1005 CATCH_TRY_SECTION(false);
1006 }
1007
1008 return true;
1009 }
#define CATCH_TRY_SECTION(ret_val)
#define BEGIN_TRY_SECTION()
const char * res
bool execute_helper(ADODB::_CommandPtr cmd, _variant_t *pcount_processed=NULL)
Here is the call graph for this function:

◆ get_db_connection()

ADODB::_ConnectionPtr & epee::ado_db_helper::per_thread_connection_pool::get_db_connection ( )
inline

Definition at line 945 of file ado_db_helper.h.

946 {
947
948 //soci::session
949
950 m_db_connections_lock.lock();
951 boost::shared_ptr<ADODB::_ConnectionPtr>& conn_ptr = m_db_connections[::GetCurrentThreadId()];
952 m_db_connections_lock.unlock();
953 if(!conn_ptr.get())
954 {
955 conn_ptr.reset(new ADODB::_ConnectionPtr());
956 ADODB::_ConnectionPtr& conn = *conn_ptr.get();
957 //init new connection
958
960 //_bstr_t str = _bstr_t("Provider=SQLOLEDB;Data Source=SRV1;Integrated Security=SSPI;Initial Catalog=dispatcher;");
961
962 if(S_OK != conn.CreateInstance(__uuidof(ADODB::Connection)))
963 {
964 LOG_ERROR("Failed to Create, instance, was CoInitialize called ???!");
965 return conn;
966 }
967
968 HRESULT res = conn->Open(_bstr_t(m_connection_string.c_str()), _bstr_t(m_login.c_str()), _bstr_t(m_password.c_str()), NULL);
969 if(res != S_OK)
970 {
971 LOG_ERROR("Failed to connect do DB, connection str:" << m_connection_string);
972 return conn;
973 }
974 CATCH_TRY_SECTION_MESS(conn, "while creating another connection");
975 LOG_PRINT("New DB Connection added for threadid=" << ::GetCurrentThreadId(), LOG_LEVEL_0);
976 ado_db_helper::execute_helper(conn, "set enable_seqscan=false;");
977 return conn;
978 }
979
980 return *conn_ptr.get();
981 }
#define CATCH_TRY_SECTION_MESS(ret_val, mess_where)
#define LOG_ERROR(x)
Definition misc_log_ex.h:98
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool epee::ado_db_helper::per_thread_connection_pool::init ( const std::string & connection_string,
const std::string & login,
const std::string & pass )
inline

Definition at line 934 of file ado_db_helper.h.

935 {
936 m_connection_string = connection_string;
937 m_login = login;
938 m_password = pass;
939 if(!get_db_connection().GetInterfacePtr())
940 return false;
941
942 return true;
943 }
Here is the call graph for this function:

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/ado_db_helper.h