MCPcopy Create free account
hub / github.com/Kitware/VTK / Open

Method Open

IO/MySQL/vtkMySQLDatabase.cxx:116–154  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

114
115//------------------------------------------------------------------------------
116bool 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//------------------------------------------------------------------------------
157void vtkMySQLDatabase::Close()

Callers 4

CreateDatabaseMethod · 0.95
DropDatabaseMethod · 0.95
TestMySQLTableReadWriteFunction · 0.45
TestMySQLDatabaseFunction · 0.45

Calls 3

IsOpenMethod · 0.95
GetServerPortMethod · 0.80
assertFunction · 0.50

Tested by 2

TestMySQLTableReadWriteFunction · 0.36
TestMySQLDatabaseFunction · 0.36