#include #include #include "mysql_connection.h" #include #include #include #include #include #include using namespace std; int main(void) { string t[6] ={ "SELECT * FROM teachers ORDER BY sename;", "DELETE FROM teachers WHERE sename='Фесенко';", "SELECT * FROM teachers ORDER BY sename;", "DELETE FROM teachers ORDER BY sename LIMIT 4;", "SELECT * FROM teachers ORDER BY sename;", "SELECT * FROM teachers;"}; try { sql::Driver *driver; sql::Connection *con; sql::ResultSet *res; sql::Statement *stmt; sql::PreparedStatement *pstmt; string s; driver = get_driver_instance(); con = driver->connect("tcp://127.0.0.1:3306", // 127.0.0.1 - адреса сервера // 3306 — номер порту; "root", // обліковий запис користувача "!@#123Qwe" // пароль ); stmt = con->createStatement(); stmt->execute("USE school;"); delete stmt; for (int j=0; j<6; j++) { cout << endl << t[j] << endl; pstmt = con->prepareStatement(t[j]); res = pstmt->executeQuery(); while (res->next()) { bool yes = true; for (int k=1; yes; k++) try { s=res->getString(k); if (s=="") s="null"; cout << s+" "; } catch (sql::SQLException &e) {yes = false;} cout <