#include <stdio.h>
#include <mysql.h>

int main ()
{
         int i;
         int res;
         char c;
         MYSQL mysql;

         fprintf (stdout, "Begin\n");
         mysql_init (&mysql);
         if (!mysql_real_connect (&mysql, "127.0.0.1", "root", "", "test", 0, NULL,
0))
                 fprintf (stderr, "Failed to connect to database: Error: %s\n",
mysql_error (&mysql));
         else
                 fprintf (stdout, "MySQL is up and running\n");
         mysql.reconnect = 1;
         fprintf (stdout, "Restart MySQL and hit enter (reconnect: %d)...",
mysql.reconnect);
         c = getchar ();
         (void) putc ('\n', stdout);
         for (i = 1; i < 4; i++)
                 if (res = mysql_ping (&mysql)) {
			 fprintf (stderr, "Result of ping: %d\n", res);
                         fprintf (stderr, "Error: %s\n", mysql_error(&mysql));
                 }
                 else
                         fprintf (stdout, "Ping %d Ok!\n", i);
         return (0);
}

