Firebird UDF, Error ESQLDatabaseError : 08003 at the second call in the proc lazarus / 16-Databases ---------------------------------------------------------------------- newbie_fpc · 2021-06-03 11:20 Hi! I would like to ask some help. In advance, I'm sorry for my english grammar mistakes. So I wrote an UDf for firebird and it is okay at the first call, but at the next call an exception occurs in tha DLL when query.open() or conn.Connected := true or conn.open(), so a connect happens. I have lines for logging and i see that the first call attempt doesnt have any problem, executed successfully, but the next ones. The exception: ESQLDatabaseError : 08003 - TIBConnection : DoInternalConnect :  -connection shutdown ---------------------------------------------------------------------- newbie_fpc · 2021-06-03 14:02 I also have tried other Connection classes (TSQLConnector,TIBConnection,TSQLConnection), and each one caused the same. It seems to me, that the problem is with the connection, because if i commented the query.open()/conn.Connected:=true/conn.Open() lines then there is no problem in the UDF. So maybe the connection in the first attempt gets stuck somehow? ---------------------------------------------------------------------- newbie_fpc · 2021-06-04 07:46 I forgot these "details": -Firebird 2.5.8 64bit -Lazarus 2.0.12 -FPC 3.2.0 -DLL compiled 64bit ---------------------------------------------------------------------- korba812 · 2021-06-04 16:55 Probably your function in the UDF library triggers an exception that cannot be handled by Firebird, which results in the database connection being dropped. Wrap your function in try..except block and log exception details: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function udf(param: integer): integer;begin  try    ...your code  except    on e: exception do      ... save exception information to file  end;end; ---------------------------------------------------------------------- newbie_fpc · 2021-06-05 19:24 Thank you for your answer. I've already tried that you suggest and this was the logged exception: ESQLDatabaseError : 08003 - TIBConnection : DoInternalConnect :  -connection shutdown ---------------------------------------------------------------------- korba812 · 2021-06-05 19:54 Are you using SQLDB components in the UDF library and the exception occurs in the UDF library or exception comes from a client application that connects to a Firebird server using the UDF library? ---------------------------------------------------------------------- newbie_fpc · 2021-06-08 07:05 Yes. Exception occurs in the DLL when it tries to connect (query.open() or conn.open() or connected := true), ALTOUGH it works at the first attempt, the next try fail with that expection. So I cant understand what is the cause, because then it should not work at the first try when I debug either. I test/debug the UDF running a procedure in IBExpert. ---------------------------------------------------------------------- korba812 · 2021-06-08 19:57 Are you using a shared connection? For example, the TIBConnection component is declared as a global variable and you use it between function calls? Hard to guess without the code. Could you please show the code how you use these components in UDF library? ---------------------------------------------------------------------- newbie_fpc · 2021-06-09 10:11 Here is the code. The defined IBExpoert UDF calls this function. I tried it as local and global variables, too. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   function getToken(params: PChar):PChar;stdcall; // cdecl  var    Client: TFPHttpClient;    Response : TStringList;    wwwParams, Token: string;    sClientId, sClientSecret, sRedirectURI, sAuthCode, sAccessToken, sRefreshToken, sTokenType: string;    iAuthPeriod, iGoogleapi_params_id: integer;     jData, jData2 : TJSONData;    jObject, jObject2 : TJSONObject;     conn: TSQLConnector;    query: TSQLQuery;     hiba,jsonstring:string;  begin    try      begin      InitializeLogger();        logger.Info('getToken calling...');       // input params        hiba:= '';        token:= '';        jsonstring := StrPas(params);        jData2 := GetJSON(jsonstring);        jObject2 := TJSONObject(jData2);        iGoogleapi_params_id := jObject2.Get('paramsID', 0);        hostname := jObject2.Get('hostname', '');        database := jObject2.Get('databasename', '');        user := jObject2.Get('user', '');        password := jObject2.Get('password', '');         logger.Debug('Input params (database variable''s value): ' + database);         database := ReplaceString(database,'\\','\');              // database initialize        conn:=TSQLConnector.Create(nil);        conn.ConnectorType:='Firebird';        conn.HostName:=hostname;      conn.DatabaseName:=database;        conn.UserName:=user;        conn.Password:=password;        conn.LoginPrompt:=false;        conn.Transaction:=TSQLTransaction.Create(Conn);        //Conn.Transaction.Params.Add('isc_tpb_read_commited'); // WITH THESE THERE IS NO DIFFERENCE        //Conn.Transaction.Params.Add('isc_tpb_concurrency');        //Conn.Transaction.Params.Add('isc_tpb_nowait');        // https://wiki.freepascal.org/SqlDBHowto        conn.OnLog:= @loggerDB.LogDBEvents;        logger.Info('conn.OnLog @loggerDB.LogDBEvents');        conn.LogEvents:= LogAllEventsExtra; //= [detCustom, detPrepare, detExecute, detFetch, detCommit, detRollBack]        logger.Info('LogEvents enums set');        logger.Info('conn initialized...');         query := TSQLQuery.Create(conn);        query.DataBase := conn;        logger.Info('TSQLQuery initialized...');         // query the database        logger.Info('query database');        logger.Debug('Database exists: ' + BoolToStr(FileExists(conn.DatabaseName),'Y','N'));        logger.Debug('Database connected: ' + BoolToStr(conn.Connected = true,'Y,'N'));        logger.Debug('Database is not nil: ' + BoolToStr(conn <> nil,'Y','N'));        query.SQL.Text:= 'select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = :PARAMS_ID';        query.ParamByName('PARAMS_ID').AsInteger:= iGoogleapi_params_id;      //SQLTransaction1.active:= true; // setting Active to True will call StartTransaction, setting it to False will call TDBTransaction.EndTransaction        logger.Debug('before query.Open; , ' + query.SQL.Text);        logger.Debug('Database exists: ' + BoolToStr(FileExists(conn.DatabaseName),'I','N'));        logger.Debug('Database connected: ' + BoolToStr(conn.Connected = true,'I','N'));        logger.Debug('Database is not nil: ' + BoolToStr(conn <> nil,'I','N'));        if (FileExists(conn.DatabaseName)) then        begin          query.Open;          logger.Debug('after query.Open;');            sClientId := query.FieldByName('CLIENT_ID').AsString;            sClientSecret := query.FieldByName('CLIENT_SECRET').AsString;            sRedirectURI := query.FieldByName('REDIRECT_URI').AsString;            sAuthCode := query.FieldByName('AUTHCODE').AsString;          logger.Debug('query successfully executed: ' + sRedirectURI);          query.Close;        logger.Info('query GOOGLEAPI_PARAMS closed...');          //conn.Transaction.Commit; // = SQLTransaction1.active:= false;  // WITH THIS LINE THERE IS NO DIFFERENCE        end;        conn.close(); // = conn.Connected:=false;        logger.Debug('conn.close()');       // POST request preparing        wwwParams := 'client_id='+trim(sClientId)                  +'&client_secret='+trim(sClientSecret)                  +'&grant_type='+'authorization_code'                  +'&redirect_uri='+ EncodeURLElement(trim(sRedirectURI))                +'&code='+trim(sAuthCode);        Client := TFPHttpClient.Create(nil);        Client.AddHeader('User- Agent','Mozilla/5.0 (compatible; fpweb)');        Client.AddHeader('Content-Type','application/x-www-form-urlencoded');        Client.AddHeader('Accept', 'application/json');          //Client.AllowRedirect := true;          //Client.UserName:=USER;        //Client.Password:=PW;          //client.RequestBody := TRawByteStringStream.Create(Params);         // a request response objektum initialize        Response := TStringList.Create;        logger.Debug('before client.FormPost token');        client.FormPost('https://accounts.google.com/o/oauth2/token',  wwwParams, Response);        Token := Response.Text;        // this is only a minimal sampling of what can be done with this API        // create from string        jData := GetJSON(Token);         logger.Debug('jData := GetJSON(Token)');        logger.Debug('before Token.Contains(''access_token'')');        // if it does not contains ('access_token'), then something went wrong        if (Token.Contains('access_token')) then        begin          // output as a flat string          //s := jData.AsJSON;          // output as nicely formatted JSON          //s := jData.FormatJSON;          // cast as TJSONObject to make access easier          jObject := TJSONObject(jData);          // retrieve value of access_token        sAccessToken := jObject.Get('access_token', '');          sRefreshToken := jObject.Get('refresh_token', '');          sTokenType := jObject.Get('token_type', '');          iAuthPeriod := jObject.Get('expires_in', 0);          //sScope := jObject.Get('scope');           query.close();          logger.Info('GOOGLEAPI_PARAMS table update token');          //conn.open();          //conn.StartTransaction;          query.SQL.Text:= 'update GOOGLEAPI_PARAMS set REFRESH_TOKEN=:REFRESH_T OKEN,ACCESS_TOKEN=:ACCESS_TOKEN,TOKEN_TYPE=:TOKEN_TYPE, ' +             'AUTH_EXPIRES=:AUTH_EXPIRES,AUTH_PERIOD=:AUTH_PERIOD ' +             'WHERE ID = :params_id';          query.ParamByName('params_id').AsInteger:= igoogleapi_params_id;        query.ParamByName('REFRESH_TOKEN').AsString:= sRefreshToken;        query.ParamByName('ACCESS_TOKEN').AsString:= sAccessToken;          query.ParamByName('TOKEN_TYPE').AsString:= sTokenType;          // AUTH_EXPIRES = Now+(AUTH_PERIOD-AuthExpiryMargin(=10, fpoauth2-ben látható))          query.ParamByName('AUTH_EXPIRES').AsDateTime:= Now()+(iAuthPeriod-10);          query.ParamByName('AUTH_PERIOD').AsInteger:= iAuthPeriod;          query.ExecSQL();          query.Close;          //SQLTransaction1.active:= false;          //conn.Transaction.Commit;          //conn.close();          //logger.Debug('conn.close()');      end;       end    except      on E:EUpdateError do      begin        hiba := 'EUpdateError : ' + E.Context + ' - ' + E.Message;        logger.Error(hiba);      end;      on E:ESQLDatabaseError do      begin        hiba := 'ESQLDatabaseError : ' + E.SQLState + ' - ' + E.Message;        logger.Error(hiba);      end;      on E:EDatabaseError do      begin        hiba := 'EDatabaseError : ' + ' - ' + E.Message;        logger.Error(hiba);      end;      on E:Exception do      begin        hiba := 'Exception : ' + E.Message;      logger.Error(hiba);      end    end;     try      begin        if ((hiba <> '') and (Token = '')) then          Result := PChar(hiba)//PAnsiChar(AnsiString(hiba))        else          Result := PChar(Token);//PAnsiChar(AnsiString(Token));        logger.Debug('Result: ' + StrPas(Result));         if (Client <> nil) then        begin          FreeAndNil(Client);          logger.Info('FreeAndNil(Client);');        end;        if (Response <> nil) then        begin          FreeAndNil(Response);          logger.Info('FreeAndNil(Response);');        end;        if (jData <> nil) then        begin          FreeAndNil(jData);          logger.Info('FreeAndNil(jData);');        end;         if (jData2 <> nil) then        begin          FreeAndNil(jData2);          logger.Info('FreeAndNil(jData2);');        end;        if (conn <> nil) then        begin          FreeAndNil(conn);          logger.Info('FreeAndNil(conn);');        end;        logger.Info('FreeAndNil ending');        FreeAndNil(loggerDB);        FreeAndNil(logger);      end    except      on E:EDatabaseError do    begin        hiba := 'EDatabaseError : ' + E.Message;        logger.Error(hiba);      end;      on E:EAccessViolation do      begin        hiba := 'EAccessViolation : ' + E.Message;        logger.Error(hiba);      end;      on E:exception do      begin      hiba := 'Something bad happened : ' + E.Message;        logger.Error(hiba);      end    end;  end; ---------------------------------------------------------------------- newbie_fpc · 2021-06-09 11:03 And this is the log's content: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  [2021-06-09 12:54:31.968 Info] Logger created [2021-06-09 12:54:31.968 Info] loggerDB created [2021-06-09 12:54:31.968 Debug] loggerDB.SetLogger(logger); [2021-06-09 12:54:31.968 Info] getToken calling [2021-06-09 12:54:31.968 Debug] Input params (database variable): D:\database.FDB [2021-06-09 12:54:31.968 Info] conn.OnLog @loggerDB.LogDBEvents [2021-06-09 12:54:31.968 Info] LogEvents enums set [2021-06-09 12:54:31.968 Info] conn initialized [2021-06-09 12:54:31.968 Info] TSQLQuery initialized [2021-06-09 12:54:31.968 Info] query database [2021-06-09 12:54:31.968 Debug] Database exists: I [2021-06-09 12:54:31.968 Debug] Database connected: N [2021-06-09 12:54:31.968 Debug] Database is not nil: I [2021-06-09 12:54:31.968 Debug] before query.Open;, select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = :PARAMS_ID  [2021-06-09 12:54:31.968 Debug] Database exists: I [2021-06-09 12:54:31.968 Debug] Database connected: N [2021-06-09 12:54:31.968 Debug] Database is not nil: I [2021-06-09 12:54:31.983 Debug] Prepare:  TQuerySQLStatement : select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = :PARAMS_ID [2021-06-09 12:54:31.983 Debug] ActualSQL: select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = ? [2021-06-09 12:54:31.983 Debug] Prepare:  TQuerySQLStatement : select ind.rdb$index_name, ind.rdb$relation_name, ind.rdb$unique_flag, ind_seg.rdb$field_name, rel_con.rdb$constraint_type, ind.rdb$index_type from rdb$index_segments ind_seg, rdb$indices ind left outer join rdb$relation_constraints rel_con on rel_con.rdb$index_name = ind.rdb$index_name where (ind_seg.rdb$index_name = ind.rdb$index_name) and (ind.rdb$relation_name='GOOGLEAPI_PARAMS') order by ind.rdb$index_name; [2021-06-09 12:54:31.983 Debug] Execute:  TQuerySQLStatement : select ind.rdb$index_name, ind.rdb$relation_name, ind.rdb$unique_flag, ind_seg.rdb$field_name, rel_con.rdb$constraint_type, ind.rdb$index_type from rdb$index_segments ind_seg, rdb$indices ind left outer join rdb$relation_constraints rel_con on rel_con.rdb$index_name = ind.rdb$index_name where (ind_seg.rdb$index_name = ind.rdb$index_name) and (ind.rdb$relation_name='GOOGLEAPI_PARAMS') order by ind.rdb$index_name; [2021-06-09 12:54:31.983 Debug] Fetch:    select ind.rdb$index_name, ind.rdb$relation_name, ind.rdb$unique_flag, ind_seg.rdb$field_name, rel_con.rdb$constraint_type, ind.rdb$index_type from rdb$index_segments ind_seg, rdb$indices ind left outer join rdb$relation_constraints rel_con on rel_con.rdb$index_name = ind.rdb$index_name where (ind_seg.rdb$index_name = ind.rdb$index_name) and (ind.rdb$relation_name='GOOGLEAPI_PARAMS') order by ind.rdb$index_name; [2021-06-09 12:54:31.983 Debug] Fetch:    select ind.rdb$index_name, ind.rdb$relation_name, ind.rdb$unique_flag, ind_seg.rdb$field_name, rel_con.rdb$constraint_type, ind.rdb$index_type from rdb$index_segments ind_seg, rdb$indices ind left outer join rdb$relation_constraints rel_con on rel_con.rdb$index_name = ind.rdb$index_name where (ind_seg.rdb$index_name = ind.rdb$index_name) and (ind.rdb$relation_name='GOOGLEAPI_PARAMS') order by ind.rdb$index_name; [2021-06-09 12:54:31.983 Debug] Fetch:    select ind.rdb$index_name, ind.rdb$relation_name, ind.rdb$unique_flag, ind_seg.rdb$field_name, rel_con.rdb$constraint_type, ind.rdb$index_type from rdb$index_segments ind_seg, rdb$indices ind left outer join rdb$relation_constraints rel_con on rel_con.rdb$index_name = ind.rdb$index_name where (ind_seg.rdb$index_name = ind.rdb$index_name) and (ind.rdb$relation_name='GOOGLEAPI_PARAMS') order by ind.rdb$index_name; [2021-06-09 12:54:31.983 Debug] Fetch:    select ind.rdb$index_name, ind.rdb$relation_name, ind.rdb$unique_flag, ind_seg.rdb$field_name, rel_con.rdb$constraint_type, ind.rdb$index_type from rdb$index_segments ind_seg, rdb$indices ind left outer join rdb$relation_constraints rel_con on rel_con.rdb$index_name = ind.rdb$index_name where (ind_seg.rdb$index_name = ind.rdb$index_name) and (ind.rdb$relation_name='GOOGLEAPI_PARAMS') order by ind.rdb$index_name; [2021-06-09 12:54:31.983 Debug] Fetch:    select ind.rdb$index_name, ind.rdb$relation_name, ind.rdb$unique_flag, ind_seg.rdb$field_name, rel_con.rdb$constraint_type, ind.rdb$index_type from rdb$index_segments ind_seg, rdb$indices ind left outer join rdb$relation_constraints rel_con on rel_con.rdb$index_name = ind.rdb$index_name where (ind_seg.rdb$index_name = ind.rdb$index_name) and (ind.rdb$relation_name='GOOGLEAPI_PARAMS') order by ind.rdb$index_name; [2021-06-09 12:54:31.983 Debug] Execute:  TQuerySQLStatement : select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = :PARAMS_ID [2021-06-09 12:54:31.983 Debug] ParamValue: Parameter "PARAMS_ID" value : "1" [2021-06-09 12:54:31.983 Debug] Fetch:    select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = :PARAMS_ID [2021-06-09 12:54:31.983 Debug] Fetch:    select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = :PARAMS_ID [2021-06-09 12:54:31.983 Debug] after query.Open; [2021-06-09 12:54:31.983 Debug] query successfully executed: urn:ietf:wg:oauth:2.0:oob [2021-06-09 12:54:31.983 Info] query GOOGLEAPI_PARAMS end [2021-06-09 12:54:31.983 Debug] Rollback: Rolling back transaction [2021-06-09 12:54:31.983 Debug] conn.close() [2021-06-09 12:54:31.983 Debug] before client.FormPost token [2021-06-09 12:54:32.390 Debug] jData := GetJSON(Token) [2021-06-09 12:54:32.390 Debug] before Token.Contains('access_token') [2021-06-09 12:54:32.390 Debug] Result: {  "error": "invalid_grant",  "error_description": "Bad Request"}  [2021-06-09 12:54:32.390 Info] FreeAndNil(Client); [2021-06-09 12:54:32.390 Info] FreeAndNil(Response); [2021-06-09 12:54:32.390 Info] FreeAndNil(jData); [2021-06-09 12:54:32.390 Info] FreeAndNil(jData2); [2021-06-09 12:54:32.390 Info] FreeAndNil(conn); [2021-06-09 12:54:32.390 Info] FreeAndNil ending [2021-06-09 12:54:40.105 Info] Logger created [2021-06-09 12:54:40.105 Info] loggerDB created [2021-06-09 12:54:40.105 Debug] loggerDB.SetLogger(logger); [2021-06-09 12:54:40.105 Info] getToken calling [2021-06-09 12:54:40.105 Debug] Input params (database variable): D:\database.FDB [2021-06-09 12:54:40.105 Info] conn.OnLog @loggerDB.LogDBEvents [2021-06-09 12:54:40.105 Info] LogEvents enums set [2021-06-09 12:54:40.105 Info] conn initialized [2021-06-09 12:54:40.105 Info] TSQLQuery initialized [2021-06-09 12:54:40.105 Info] query database [2021-06-09 12:54:40.105 Debug] Database exists: I [2021-06-09 12:54:40.105 Debug] Database connected: N [2021-06-09 12:54:40.105 Debug] Database is not nil: I [2021-06-09 12:54:40.105 Debug] before query.Open;, select CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHCODE from GOOGLEAPI_PARAMS WHERE ID = :PARAMS_ID  [2021-06-09 12:54:40.105 Debug] Database exists: I [2021-06-09 12:54:40.105 Debug] Database connected: N [2021-06-09 12:54:40.105 Debug] Database is not nil: I [2021-06-09 12:54:40.108 Error] ESQLDatabaseError : 08003 - TIBConnection : DoInternalConnect :  -connection shutdown [2021-06-09 12:54:40.108 Debug] Result: ESQLDatabaseError : 08003 - TIBConnection : DoInternalConnect :  -connection shutdown [2021-06-09 12:54:40.108 Error] EAccessViolation : Access violation ---------------------------------------------------------------------- korba812 · 2021-06-09 15:39 You seem to be using SQLDB correctly, but... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function getToken(params: PChar):PChar;stdcall; // cdeclShould be 'cdecl' Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         if ((hiba <> '') and (Token = '')) then          Result := PChar(hiba)//PAnsiChar(AnsiString(hiba))        else          Result := PChar(Token);//PAnsiChar(AnsiString(Token)); In case you are returning cstring you must use the ib_util_malloc function to allocate the memory, otherwise the memory will not be properly disposed by the server and a memory leak will occur. See: https://firebirdsql.org/en/writing-udfs-for- interbase/#writing_udfs_in_delphi_for_windows_platforms I can see you are still using global variables (logger, loggerDB). Don't do this until you are sure they are thread-safe. See: https://ww w.ibexpert.net/ibe/pmwiki.php?n=Doc.CreatingUDFsInDelphi#IssuesToBe ---------------------------------------------------------------------- newbie_fpc · 2021-07-01 08:12 I'm sorry for late reaction, i did not have time for this. Thanks for the tips, I'll try them today. ---------------------------------------------------------------------- newbie_fpc · 2021-07-13 08:19 I tried those you suggested. I'm not using global varialbes now and tried ib_util_malloc function and cdecl convention, but the situation is the same. The procedure still gets "ESQLDatabaseError : 08003 - TIBConnection : DoInternalConnect : -connection shutdown" response from the 2nd run and so on. There is something may help or useful info. Although I dont remember how it worked previously in IBExpert sql editor, but the "select udf_function(...) from rdb$database" works well, multiple times. There is no TIBConnection : DoInternalConnect : -connection shutdown. ---------------------------------------------------------------------- korba812 · 2021-07-13 18:48 I looked again at the log you attached earlier and I didn't notice the last message: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [2021-06-09 12:54:40.108 Error] EAccessViolation : Access violation Maybe that's the reason. Try to find out what causes this exception. ---------------------------------------------------------------------- Fantablup · 2021-07-13 18:56 Quote from: newbie_fpc on June 03, 2021, 01:20:35 pmThe exception: ESQLDatabaseError : 08003 - TIBConnection : DoInternalConnect :  -connection shutdown I tried the IBConnection just for fun yesterday, and i got the same error. I just tried it in the designer with setting active. The first time i set active, it works.. Then i set active false, and again setting to active. Now i get this error. And none other components like Zeos DBconnection is working either after this. I have to restart Lazarus for it to work again. I guess it is something with the IBConnection. ---------------------------------------------------------------------- korba812 · 2021-07-13 19:10 Quote from: Fantablup on July 13, 2021, 08:56:00 pmQuote from: newbie_fpc on June 03, 2021, 01:20:35 pmThe exception: ESQLDatabaseError : 08003 - TIBConnection : DoInternalConnect :  -connection shutdown I tried the IBConnection just for fun yesterday, and i got the same error. I just tried it in the designer with setting active. The first time i set active, it works.. Then i set active false, and again setting to active. Now i get this error. And none other components like Zeos DBconnection is working either after this. I guess it is something with the IBConnection. For test I created a simple UDF library using IBConnection and it works fine. Your problem may not be related to this problem. In this case, the IBConnection component is created each time the UDF is called, not reused. ---------------------------------------------------------------------- newbie_fpc · 2021-08-06 14:45 I couldn't solve the problem, so i started using ZeosDBO instead of TIBConnection. Thanks for the help, suggestions.