|
|
| version 1.15, 2001/05/17 12:51:05 | version 1.16, 2001/05/17 13:23:28 |
|---|---|
| Line 54 private: | Line 54 private: |
| /// @param request_url protocol://[driver-dependent] | /// @param request_url protocol://[driver-dependent] |
| SQL_Connection& SQL_Driver_manager::get_connection(const String& request_url, | SQL_Connection& SQL_Driver_manager::get_connection(const String& request_url, |
| Table *protocol2driver_and_client) { | Table *protocol2driver_and_client) { |
| ////__asm int 3; | |
| Pool& pool=request_url.pool(); // request pool | Pool& pool=request_url.pool(); // request pool |
| // we have table for locating protocol's library | // we have table for locating protocol's library |
| Line 69 SQL_Connection& SQL_Driver_manager::get_ | Line 70 SQL_Connection& SQL_Driver_manager::get_ |
| result=0; | result=0; |
| } | } |
| if(!result) { // no cached connection or it were unpingabe: connect/reconnect | char *request_url_cstr; |
| if(result) | |
| request_url_cstr=0; // no need to connect, just reassign services & they can use | |
| else { // no cached connection or it were unpingabe: connect/reconnect | |
| int pos=request_url.pos("://", 3); | int pos=request_url.pos("://", 3); |
| if(pos<0) | if(pos<0) |
| PTHROW(0, 0, | PTHROW(0, 0, |
| Line 77 SQL_Connection& SQL_Driver_manager::get_ | Line 81 SQL_Connection& SQL_Driver_manager::get_ |
| "no protocol specified"); // NOTE: not THROW, but PTHROW | "no protocol specified"); // NOTE: not THROW, but PTHROW |
| // make global_url C-string on global pool | // make global_url C-string on global pool |
| char *request_url_cstr=request_url.cstr(String::UL_AS_IS); | request_url_cstr=request_url.cstr(String::UL_AS_IS); |
| char *global_url_cstr=(char *)malloc(strlen(request_url_cstr)+1); | char *global_url_cstr=(char *)malloc(strlen(request_url_cstr)+1); |
| strcpy(global_url_cstr, request_url_cstr); | strcpy(global_url_cstr, request_url_cstr); |
| // make global_url string on global pool | // make global_url string on global pool |
| Line 156 SQL_Connection& SQL_Driver_manager::get_ | Line 160 SQL_Connection& SQL_Driver_manager::get_ |
| } | } |
| // allocate in global pool | // allocate in global pool |
| // associate with services[request], deassociates at close | // associate with services[request] |
| result=new(this->pool()) SQL_Connection(this->pool(), | result=new(this->pool()) SQL_Connection(this->pool(), global_url, *driver); |
| global_url, *driver, request_url_cstr); | |
| } | } |
| // associate with services[request] | // associate with services[request] (deassociates at close) |
| result->set_services(new(pool) SQL_Driver_services_impl(pool, request_url)); | result->set_services(new(pool) SQL_Driver_services_impl(pool, request_url)); |
| SAPI::log(pool, "get_connection: %p", result); | // if not connected yet, do that now, when result has services |
| if(request_url_cstr) | |
| result->connect(request_url_cstr); | |
| // return it | |
| return *result; | return *result; |
| } | } |
| void SQL_Driver_manager::close_connection(const String& url, | void SQL_Driver_manager::close_connection(const String& url, |
| SQL_Connection& connection, | SQL_Connection& connection) { |
| Pool& pool) { | |
| SAPI::log(pool, "close_connection: %p", &connection); | |
| // deassociate from services[request] | // deassociate from services[request] |
| connection.set_services(0); | connection.set_services(0); |
| put_connection_to_cache(url, connection); | put_connection_to_cache(url, connection); |