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

How is data security provided in Object Oriented languages? ?

5 Answers  


#include <string.h> #include <stdio.h> #include <stdlib.h> #include<conio.h> void insert(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); insert(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void insert(char *items, int count) { register int a, b; char t; for(a=1; a < count; ++a) { t = items[a]; for(b=a-1; (b >= 0) && (t < items[b]); b--) items[b+1] = items[b]; items[b+1] = t; } } design an algorithm for Insertion Sort

0 Answers  


what is mean by design pattern

4 Answers  


can you explain how to use JavaBean in Project

3 Answers   Infosys, Satyam,


What is a template?

7 Answers  






Can a varargs method be overloaded?

0 Answers  


What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 2) 17 3) 16.5

16 Answers   TCS,


How do you make derived class as an abstract class?

1 Answers   Convergys, TCS,


what are the realtime excercises in C++?

0 Answers   IBM, Wipro,


1. Strong name 2. how to prevent a class from being inherited 3. delegates 4. default modifier for interface 5. default modifier for class 6. base class for exception 7. diff bet trigger and view in sql 8. how to exchange values from one page to another page 9. can multiple catch block ll be executed at same time 10. can u store different data types in an array & array list 11. when we ll use trigger 12. try,catch,finally usage

2 Answers  


What is the difference between Home and $Home?

2 Answers   TCS,


Why and when is a virtual destructor needed?

5 Answers  


Categories