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

Definition of Object Oriented Programming in single line?

33 Answers   Impact Systems, Q3 Technologies, TCS,


Can a destructor be called directly?

0 Answers  


what is multithreading in c++ , what is difference between multithreading and singlethreading.

4 Answers  


what is the difference between <stdio.h>and "stdio.h"?

5 Answers  


What is new keyword in oops?

0 Answers  


Differences between inline functions and non-inline functions?

4 Answers   Ness Technologies,


what are abstract classes and how they impliment , with example

2 Answers  


Who invented oop?

0 Answers  


What is polymorphism in oops with example?

0 Answers  


Write a program to demonstrate the use of 'Composition' in C++

2 Answers  


sir i want to know which posting to apply since i am BE CSE.. also want to know what are the rounds there for my interview...Expecting for ur valuable answer....

2 Answers  


some one give d clear explanation for polymorphism

3 Answers  


Categories