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 maximum number of concurrent
threads that the InnoDB plug-in can create.
Answer / sreenivasulu
Requirements
Make sure you have development environment installed such as gcc, mysql development package etc. Following is the list summarize the list of packages to compile program:
mysql: MySQL client programs and shared library
mysqlclient: Backlevel MySQL shared libraries (old libs)
mysql-devel: Files for development of MySQL applications (a must have)
mysql-server: Mysql server itself
gcc, make and other development libs: GNU C compiler
/* Simple C program that connects to MySQL Database server*/
#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 ? | 5 Yes | 0 No |
When will a constructor executed?
What do you mean by Encapsulation?
WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE
how much classes are used in c++
What is the difference between pass by reference and pass by value?
What is difference between #define and const?
char* ptr = "Rahul"; *ptr++; printf("%s",ptr); What will be the output
WILL I GET A guaranteed JOB AFTER DOING bsc()IT) and GNIIT from an NIIT CENTRE??
21 Answers Biocon, MIT, NIIT,
what is the need of abstraction? what is abstraction?what is the abstraction for stack?
Name an advantage of array over linked list?
24 Answers GML, IBM, Software Solutions,
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.
what is object slicing