------------------------------------------------------------------------------
| 114 | |
| 115 | //------------------------------------------------------------------------------ |
| 116 | bool vtkMySQLDatabase::Open(const char* password) |
| 117 | { |
| 118 | if (this->IsOpen()) |
| 119 | { |
| 120 | vtkGenericWarningMacro("Open(): Database is already open."); |
| 121 | return true; |
| 122 | } |
| 123 | |
| 124 | assert(this->Private->Connection == nullptr); |
| 125 | |
| 126 | if (this->Reconnect) |
| 127 | { |
| 128 | my_bool recon = true; |
| 129 | mysql_options(&this->Private->NullConnection, MYSQL_OPT_RECONNECT, &recon); |
| 130 | } |
| 131 | |
| 132 | this->Private->Connection = |
| 133 | mysql_real_connect(&this->Private->NullConnection, this->GetHostName(), this->GetUser(), |
| 134 | (password && strlen(password) ? password : this->Password), this->GetDatabaseName(), |
| 135 | this->GetServerPort(), nullptr, 0); |
| 136 | |
| 137 | if (this->Private->Connection == nullptr) |
| 138 | { |
| 139 | vtkErrorMacro(<< "Open() failed with error: " << mysql_error(&this->Private->NullConnection)); |
| 140 | return false; |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | vtkDebugMacro(<< "Open() succeeded."); |
| 145 | |
| 146 | if (this->Password != password) |
| 147 | { |
| 148 | delete[] this->Password; |
| 149 | this->Password = password ? vtksys::SystemTools::DuplicateString(password) : nullptr; |
| 150 | } |
| 151 | |
| 152 | return true; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | //------------------------------------------------------------------------------ |
| 157 | void vtkMySQLDatabase::Close() |