Re:Re:Re: UNABLE TO CONNECT TO MYSQL SERVER

From: Biswajit Paul <biswajit@dont-contact.us>
Date: Tue, 16 Mar 2004 13:49:27 +0530 (IST)

On Mon, 15 Mar 2004, Biswajit Paul wrote:

> Yah !! It only works fine when SQUID runs in
> NON DAEMON Mode.
>
> I do not think MySQL functions assumes there is
> a terminal. I used them in other applications which
> runs in Daemon Mode, it worked fine.
>
> CAN U FIGURE OUT THE CAUSE NOW ??

No, and I have never in the 20 years of programming I have done seen such
symptoms unless one is calling a function which requires a terminal.

Regards
Henrik

  HELLO HENRIK,

       Surprising for me too. Can you do one favour for me.
U plz try my code in your setup.Lets find whats happens ...

Regards

    Biswajit

"

   MY CODE :

------------- src/access_log.c ----------------------

/* global variable */

static MYSQL mysql;

  static void accessLogSquid(AccessLogEntry * al){

                     .
                     .
                     .

      /* Logging to MYSql Database */

        mysql_CONNECT();

                     .
                     .
                     .

         mysql_close(&mysql);
    }

int mysql_CONNECT(){

        char host[20];
        char db[6]="SQUID";
        char usedb[10]="USE SQUID";

        gethostname(host,20);

        mysql_init(&mysql);

        mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"squid");

        if(!mysql_real_connect(&mysql,"","","",db,0,NULL,0)){

          if(!mysql_real_connect(&mysql,host,"","",db,0,NULL,0)){
                debug(1, 1) ("\n Error: %s\n",mysql_error(&mysql));
                mysql_close(&mysql);
                return 0;
              }
           }

if(mysql_query(&mysql,usedb)){
         debug(1, 1) ("\n Error: %s\n",mysql_error(&mysql));
         mysql_close(&mysql);
         return(0);
      }

  return 0;

   }
Received on Tue Mar 16 2004 - 06:35:00 MST

This archive was generated by hypermail pre-2.1.9 : Thu Apr 01 2004 - 12:00:04 MST