string StartTime = res->getDate("StartTime");
string LastModified = res->getDate("LastModified");
string Id = res->getInt("Id");
string PatientId = res->getInt("PatientId");
Following document claims these things work, but Visual Studio compiler using 8.0 mysql connector does not seem to have constructors for them. - https://docs.oracle.com/cd/B12037_01/appdev.101/b10778/reference025.htm
this seem to not provide any info why datetimes and ID's does not get returned... https://dev.mysql.com/doc/connector-cpp/1.1/en/connector-cpp-examples-results.html
Following fields get returned -
string FILE_NAME = res->getString("FileName");
string VisitID = res->getString("VisitID");
the method I'm calling that should do the stuff
void calldatab() {
for (auto& p : fs::recursive_directory_iterator("C:\\folder\\")) {
if (p.path().extension() == ".pdf") {
std::string element = p.path().string();
size_t end_pos = element.rfind("end");
string str2 = element.substr(42, end_pos);
//std::cout << str2;
string str3 = delSpaces(str2);
//cout << str3;
try
{
sql::Driver* driver;
sql::Connection* con;
//sql::Statement *stmt;
sql::ResultSet* res;
sql::PreparedStatement* pstmt;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "");
/* Connect to the MySQL test database */
con->setSchema("semaserver");
pstmt = con->prepareStatement("");
//pstmt->setInt(1, 1);
pstmt->setString(1, str3);
res = pstmt->executeQuery();
/* Fetch in reverse = descending order! */
///cikls kur izmantos mysql datu masvu
//res->afterLast();
while (res->next()) {
string FILE_NAME = res->getString("FileName");
//cout << FILE_NAME;
string StartTime = res->getString("StartTime");
string VisitID = res->getString("VisitID");
string LastModified = res->getString("LastModified");
string Id = res->getString("Id");
string PatientId = res->getString("PatientId");
std::string cmd = "copy /-y " + element + " " + "C:\\PACIENTI\\" + PatientId + '-' + StartTime + '-' + VisitID + '-' + LastModified + ".pdf";
for (auto& p2 : fs::directory_iterator("C:\\folder\\")) {
if (element != p2.path().string()) {
cout << cmd;
FILE* pipe = _popen(cmd.c_str(), "r");
if (pipe == NULL)
{
return;
}
char buffer[128];
std::string result = "";
while (!feof(pipe))
{
if (fgets(buffer, 128, pipe) != NULL)
{
result += buffer;
}
}
//std::cout << "Results: " << std::endl << result << std::endl ;
_pclose(pipe);
}
}
}
delete res;
delete pstmt;
delete con;
}
catch (sql::SQLException& e)
{
///nav implementēts vairāk info
//cout << "# ERR: SQLException in " << __FILE__;
//cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
/* what() (derived from std::runtime_error) fetches error message */
cout << "# ERR: " << e.what();
//cout << " (MySQL error code: " << e.message();
cout << "# ERR: SQLException in creation" << endl;
//cout << e.message;
}
}
}
}
with DATE and TIME fields in actual database I get failed connection to localhost, so how do I get this info? MySQL shell returns this info.