English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

You will have to use the C header file to have access to the C functions that allow the connections. The program will look something like this:

#include
#include

main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

char *server = "mysql-server.ucl.ac.uk";
char *user = "ucabwww";
char *password = "secret";
char *database = "ucabwww";

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(0);
}

/* send SQL query */
if (mysql_query(conn, "SELECT * FROM people WHERE age > 30")) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(0);
}

res = mysql_use_result(conn);

/* output fields 1 and 2 of each row */
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s %s\n", row[1], row[2]);

/* Release memory used to store results and close connection */
mysql_free_result(res);
mysql_close(conn);
}

Give this a shot and see if it helps. If you get any errors, list them . . . chances are if it isn't a syntax error, you may have a package missing.

2007-01-26 21:37:03 · answer #1 · answered by Runa 7 · 0 0

PLEASE CLICK ON-
http://www.yolinux.com/TUTORIALS/LinuxTutorialTomcat.html

2007-01-26 21:37:29 · answer #2 · answered by Udit D 4 · 1 0

fedest.com, questions and answers