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.



Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed..

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

Post New Answer

More OOPS Interview Questions

What is cohesion in oop?

0 Answers  


Why do while loop is used?

0 Answers  


What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?

0 Answers   NIIT, SRA,


What does enum stand for?

0 Answers  


Can anyone please explain runtime polymorphism with a real time example??at what ciscumstances we go for it??

1 Answers  






What is the problem with multiple inheritance?

0 Answers  


Will I be able to get a picture in D drive to the c++ program? If so, help me out?

0 Answers  


any one please tell me the purpose of operator overloading

0 Answers   Amazon,


what is difference between thread and programme.

1 Answers   NCC,


write knight tour problem which is present in datastructure

0 Answers  


What is overloading and its types?

0 Answers  


can we create and enter the data & hide files using programmes ?

2 Answers   Wipro,


Categories