Write a C/C++ program that connects to a MySQL server and
checks if the InnoDB plug-in is installed on it. If so, your
program should print the total number of disk writes by MySQL.
Answer Posted / raja bhar
#include <mysql.h>
#include <stdio.h>
main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "PASSWORD"; /* set me first */
char *database = "mysql";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, "show tables")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);
/* close connection */
mysql_free_result(res);
mysql_close(conn);
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Give an example of run-time polymorphism/virtual functions.
Describe the setting up of my member functions to avoid overriding by the derived class?
What are c++ storage classes?
describe private access specifiers?
What does std :: flush do?
which of the following is not an secondary constant a) array b) real c) union
How can you link a c++ program to c functions?
When does a name clash occur in c++?
What is the type of this pointer in c++?
What are the effects after calling the delete this operator ?
What do you understand by pure virtual function? Write about its use?
Why do we need function?
what are the decision making statements in C++? Explain if statement with an example?
Do you know what are static and dynamic type checking?
What is the function to call to turn an ascii string into a long?