cancel
Showing results for 
Search instead for 
Did you mean: 

mysql source

prem_4
Occasional Advisor

mysql source

hi all!

does anyone know which file in the mysql source provides a listener class or that supports extensibility.

3 REPLIES
benoit Bruckert
Honored Contributor

Re: mysql source

HI,
What do you mean by listener class ??
in order to access mysql from your own program (C,C++), you have the libmysqlclient which provide apis.

regards
Benoit
Une application mal pansée aboutit à une usine à gaze (GHG)
prem_4
Occasional Advisor

Re: mysql source

can u be more precise . does this take me to the core of database server

can u provide me an example
benoit Bruckert
Honored Contributor

Re: mysql source

Hi, here is a very simple program to connect to the database "mybase", hosted on "mysqlhost", connection on default port (3306), uding user "user" with password "password" .
this program connect to this database, query select * from lot and print the first 4 columns of the result.

/* a simple demo client */

#include

#include
#include
#include
#include

int
main(void)
{
MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;

assert(mysql_init(&mysql) != NULL);
/* this only works in 3.23 */
assert(mysql_options(&mysql, MYSQL_READ_DEFAULT_GROUP, "simple") == 0);
if (mysql_real_connect(&mysql, "mysqlhost", "user", "password", "mybase", 0, NULL, 0) == NULL) {
fprintf(stderr, "error on connect: %s\n", mysql_error(&mysql));
exit(EXIT_FAILURE);
}
if (mysql_real_query(&mysql, "select * from lot", 17) != 0) {
fprintf(stderr, "error on query: %s\n", mysql_error(&mysql));
exit(EXIT_FAILURE);
}
if ((res = mysql_store_result(&mysql)) == NULL) {
fprintf(stderr, "error on store: %s\n", mysql_error(&mysql));
exit(EXIT_FAILURE);
}

printf("resultat:\n");
while ((row = mysql_fetch_row(res))) {
printf(" %s %s %s %s\n", row[0],row[1],row[2],row[3]);
}

mysql_free_result(res);
mysql_close(&mysql);
exit(EXIT_SUCCESS);
}
Une application mal pansée aboutit à une usine à gaze (GHG)