FAQ
Hi

I am trying to get a small test client written in C to connect to my MySQL server.

I am compiling on OS/2 with emx

The end executable is called myclnt.exe

This what happens when I run the program

[E:\mysql2\client]myclnt
Init worked
Host: 216.161.180.210
User: ginger
Pwrd: ginger
Db: desert_fox
<-- I terminated it with a control C
Process terminated by SIGINT in thread 1

[E:\mysql2\client]

I have include my makefile and the source of my program in this e-mail.

Any ideas what I may be doing wrong.

If you need any more info about my setup just ask.


The make file is as follows:
CC=gcc
INCLUDES = -I\mysql2\include
LIBS = -L\mysql2\lib

all: myclnt

client.o: client.c
$(CC) -c $(INCLUDES) client.c

myclnt: client.o
$(CC) -O2 -o myclnt.exe client.o $(LIBS) -lmysqlclient -lpthrdrtl


Here is my c code:
/* Client1.c */

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

MYSQL *conn;

int main (int argc, char *argv[])
{
char *def_host_name = "216.161.180.210";
char *def_user_name = "ginger";
char *def_password = "ginger";
char *def_db_name = "desert_fox";

conn = mysql_init(NULL);

if(conn != NULL)
{
printf("Init worked\n");
printf("Host: %s\n", def_host_name);
printf("User: %s\n", def_user_name);
printf("Pwrd: %s\n", def_password);
printf(" Db: %s\n", def_db_name);

if (mysql_real_connect (
conn, /* pointer to connection handler */
def_host_name, /* host to connect to */
def_user_name, /* user name */
def_password, /* password */
def_db_name, /* Database to connect to */
3306,
NULL,
0) == NULL) /* flags (none) */
printf("Connect Failed\n Error: %u (%s)\n", mysql_errno(conn), mysql_error(conn));

mysql_close(conn);
}
exit(0);
}



Thanks

Robert Gehrig
Webmaster at www.gdbarri.com

e-mail: webmaster@mail.gdbarri.com

Search Discussions

  • Sasha at Feb 5, 2000 at 9:20 pm

    Robert Gehrig wrote:

    Hi

    I am trying to get a small test client written in C to connect to my MySQL server.

    I am compiling on OS/2 with emx

    The end executable is called myclnt.exe

    This what happens when I run the program

    [E:\mysql2\client]myclnt
    Init worked
    Host: 216.161.180.210
    User: ginger
    Pwrd: ginger
    Db: desert_fox
    <-- I terminated it with a control C
    Process terminated by SIGINT in thread 1

    [E:\mysql2\client]

    I have include my makefile and the source of my program in this e-mail.

    Any ideas what I may be doing wrong.

    If you need any more info about my setup just ask.

    The make file is as follows:
    CC=gcc
    INCLUDES = -I\mysql2\include
    LIBS = -L\mysql2\lib

    all: myclnt

    client.o: client.c
    $(CC) -c $(INCLUDES) client.c

    myclnt: client.o
    $(CC) -O2 -o myclnt.exe client.o $(LIBS) -lmysqlclient -lpthrdrtl

    Here is my c code:
    /* Client1.c */

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

    MYSQL *conn;

    int main (int argc, char *argv[])
    {
    char *def_host_name = "216.161.180.210";
    char *def_user_name = "ginger";
    char *def_password = "ginger";
    char *def_db_name = "desert_fox";

    conn = mysql_init(NULL);

    if(conn != NULL)
    {
    printf("Init worked\n");
    printf("Host: %s\n", def_host_name);
    printf("User: %s\n", def_user_name);
    printf("Pwrd: %s\n", def_password);
    printf(" Db: %s\n", def_db_name);

    if (mysql_real_connect (
    conn, /* pointer to connection handler */
    def_host_name, /* host to connect to */
    def_user_name, /* user name */
    def_password, /* password */
    def_db_name, /* Database to connect to */
    3306,
    NULL,
    0) == NULL) /* flags (none) */
    printf("Connect Failed\n Error: %u (%s)\n", mysql_errno(conn), mysql_error(conn));

    mysql_close(conn);
    }
    exit(0);
    }

    Thanks

    Robert Gehrig
    Webmaster at www.gdbarri.com

    e-mail: webmaster@mail.gdbarri.com
    To really know what's going on, I would just trace it in gdb.

    However, I suspect that it hangs in mysql_real_connect because of either DNS
    problems or being unable to contact the server host on port 3306 ( no response).

    Can you telnet to port 3306 from the client machine?

    --
    Sasha Pachev

    +------------------------------------------------------------------+
    TcX ____ __ _____ _____ ___ == mysql@tcx.se |
    /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sasha Pachev |
    /*/ /*/ /*/ \*\_ |*| |*||*| mailto:sasha@mysql.com |
    /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Provo, Utah, USA |
    /*/ /*/ /*/\*\_/*/ \*\_/*/ |*|____ |
    ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^ |
    /*/ \*\ Developers Team |
    +------------------------------------------------------------------+
  • Paul DuBois at Feb 5, 2000 at 10:25 pm

    Robert Gehrig wrote:
    Hi

    I am trying to get a small test client written in C to connect to
    my MySQL server.

    I am compiling on OS/2 with emx

    The end executable is called myclnt.exe

    This what happens when I run the program

    [E:\mysql2\client]myclnt
    Init worked
    Host: 216.161.180.210
    User: ginger
    Pwrd: ginger
    Db: desert_fox
    <-- I
    terminated it with a control C
    Process terminated by SIGINT in thread 1

    [E:\mysql2\client]

    I have include my makefile and the source of my program in this e-mail.

    Any ideas what I may be doing wrong.

    If you need any more info about my setup just ask.

    The make file is as follows:
    CC=gcc
    INCLUDES = -I\mysql2\include
    LIBS = -L\mysql2\lib

    all: myclnt

    client.o: client.c
    $(CC) -c $(INCLUDES) client.c

    myclnt: client.o
    $(CC) -O2 -o myclnt.exe client.o $(LIBS) -lmysqlclient -lpthrdrtl

    Here is my c code:
    /* Client1.c */

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

    MYSQL *conn;

    int main (int argc, char *argv[])
    {
    char *def_host_name = "216.161.180.210";
    char *def_user_name = "ginger";
    char *def_password = "ginger";
    char *def_db_name = "desert_fox";

    conn = mysql_init(NULL);

    if(conn != NULL)
    {
    printf("Init worked\n");
    printf("Host: %s\n", def_host_name);
    printf("User: %s\n", def_user_name);
    printf("Pwrd: %s\n", def_password);
    printf(" Db: %s\n", def_db_name);

    if (mysql_real_connect (
    conn, /* pointer to connection handler */
    def_host_name, /* host to connect to */
    def_user_name, /* user name */
    def_password, /* password */
    def_db_name, /* Database to connect to */
    3306,
    NULL,
    0) == NULL) /* flags (none) */
    printf("Connect Failed\n Error: %u (%s)\n",
    mysql_errno(conn), mysql_error(conn));

    mysql_close(conn);
    }
    exit(0);
    }

    Thanks

    Robert Gehrig
    Webmaster at www.gdbarri.com

    e-mail: webmaster@mail.gdbarri.com
    To really know what's going on, I would just trace it in gdb.

    However, I suspect that it hangs in mysql_real_connect because of either DNS
    problems or being unable to contact the server host on port 3306 (
    no response).

    Can you telnet to port 3306 from the client machine?

    --
    Sasha Pachev
    A little more information on this one (Robert contacted me, but I don't
    know enough about OS/2 to know what to suggest):

    - The mysql.exe binary from his distribution can connect to the server okay.

    - The program he's trying to compile and run does connect to the server,
    because if he runs mysqladmin, it shows the connection, in "unknown"
    state (or perhaps "login"). But the connection never successfully
    completes.

    Perhaps some difference between his compiler, and the compiler used to
    build the OS/2 binary distribution? I dunno.

    --
    Paul DuBois, paul@snake.net
  • Sinisa at Feb 6, 2000 at 2:43 pm

    Robert Gehrig writes:
    Hi >
    I am trying to get a small test client written in C to connect to my MySQL server. >
    I am compiling on OS/2 with emx >
    The end executable is called myclnt.exe >
    This what happens when I run the program >
    [E:\mysql2\client]myclnt
    Init worked
    Host: 216.161.180.210
    User: ginger
    Pwrd: ginger
    Db: desert_fox
    <-- I terminated it with a control C
    Process terminated by SIGINT in thread 1 >
    [E:\mysql2\client] >
    I have include my makefile and the source of my program in this e-mail. >
    Any ideas what I may be doing wrong. >
    If you need any more info about my setup just ask.
    Hi!

    If you wish to use MYSQL * pointer, you should do:

    MYSQL *conn=NULL;

    And

    conn = mysql_init(conn);

    May be a better and a bit faster way would be:

    MYSQL conn;

    if (mysql_init(&conn)) {
    ...

    Regards,

    Sinisa

    +----------------------------------------------------------------------+
    TcX ____ __ _____ _____ ___ == mysql@tcx.se |
    /*/\*\/\*\ /*/ \*\ /*/ \*\ |*| Sinisa Milivojevic |
    /*/ /*/ /*/ \*\_ |*| |*||*| mailto:sinisa@mysql.com |
    /*/ /*/ /*/\*\/*/ \*\|*| |*||*| Larnaka, Cyprus |
    /*/ /*/ /*/\*\_/*/ \*\_/*/ |*|____ |
    ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^ |
    /*/ \*\ Developers Team |
    +----------------------------------------------------------------------+

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmysql @
categoriesmysql
postedFeb 5, '00 at 7:40p
activeFeb 6, '00 at 2:43p
posts4
users4
websitemysql.com
irc#mysql

People

Translate

site design / logo © 2022 Grokbase