* * *

Author Topic: TIBConfigService unavailable database  (Read 1578 times)

RedOctober

  • Full Member
  • ***
  • Posts: 218
TIBConfigService unavailable database
« on: February 28, 2018, 10:59:52 pm »
I am unable to use the TIBConfigService due to it always erroring out with "unavailable database".

My TIBConfigService component is named:  fb_cg

I configure the following settings and parameters:

  fb_cg.ServerName := 'SRV1/3050';
  fb_cg.Params.Add('USER_NAME=SYSDBA');
  fb_cg.Params.Add('PASSWORD=masterkey');
  fb_cg.LoginPrompt := False;
  fb_cg.DatabaseName := 'D:\Firebird\jet_txt.fdb';  // <-- Exists!

There are no other connections to the database.  I'm issuing my command as:

          fb_cg.Active := True;
          //fb_cg.ServiceStart;  //  Not required for the Config service!
          fb_cg.SetSweepInterval(150);

The last command is where the error occurs.  What am I doing wrong?

Thanks in advance for any help you can provide.

Platform: Lazarus 1.8.1, FBC 3.0.5, IBX 2.1.0

tonyw

  • Full Member
  • ***
  • Posts: 117
    • MWA Software
Re: TIBConfigService unavailable database
« Reply #1 on: March 01, 2018, 12:47:25 am »
Your code should work assuming that the database really does exist. There are two things to look at:

1. Check the Protocol specified in the component properties. Is it TCP, or do you have a good reason to set it to anything else?

2. Remove the '/3050' from the servername. This is the default for TCP and may be getting in the way - especially if you are not using TCP. If using TCP, make sure that SRV1 is a valid domain name.

P.S. IBX 2.2 should be released tomorrow. To quote from the draft release notice " A major new example application (DBAdmin) is now included. This illustrates the use of IBX for Day-to-Day Database Administration tasks including User Management, Backup/Restore and Database Validation and Repair. It is also intended to provided a useable application that users may use directly or incorporate into their own toolsets. It also demonstrates User Management using Firebird 3 virtual tables and SQL statements."

The example includes the use of SetSweepInterval and running a commanded sweep.

RedOctober

  • Full Member
  • ***
  • Posts: 218
Re: TIBConfigService unavailable database
« Reply #2 on: March 01, 2018, 03:05:27 am »
I'm actually looking for a replacement for FlameRobin, which doesn't run on Microsoft Server Essentials 2016. I've been building one myself, but as you can tell, it's taking longer than I'd hoped.  If IBX wd come with a FlameRobin work-alike, I'd use it, and dump mine.

rvk

  • Hero Member
  • *****
  • Posts: 3441
Re: TIBConfigService unavailable database
« Reply #3 on: March 01, 2018, 04:00:30 am »
What problem are you having with FlameRobin on Server Essentials 2016?

There are two (I think) Lazarus open source alternatives. One is Turbobird (can't recall the other). Although they are not yet as stable as FlameRobin.

RedOctober

  • Full Member
  • ***
  • Posts: 218
Re: TIBConfigService unavailable database
« Reply #4 on: March 01, 2018, 04:56:55 am »
TurboBird is a long dead project and doesn't work on Microsoft Server Essentials 2016.  It crashes.  And FlameRobin's widget set doesn't work either.  It crashes.

I tried following the instructions to rebuild FlameRobin here:

http://flamerobin.blogspot.ca/2015/11/flamerobin-building-instructions-for.html

but I can never get all the settings correct, so the compile never works.

I'm not sure why the authors didn't just do a recompile and post it somewhere where we can all get it. That would have taken a lot less work than typing up all those instructions for the rest of us to follow.

RedOctober

  • Full Member
  • ***
  • Posts: 218
Re: TIBConfigService unavailable database
« Reply #5 on: March 01, 2018, 07:41:48 pm »
I installed the IBX 2.2.0 version, released just today.  The FBAdmin example is extremely complex, so it's kind of difficult to see where my app is going wrong, and what is going right in the example.  I'm assuming the error message "Unavailable Database" must be caused by something simple... like, there is either and attachment that shouldn't exist (I have switched off all my database components) or, there isn't an attachment that should exist.  In the FBAdmin example, it actually appears that a server properties component is activated, just before the .SetSweepInterval command.  I tried that in my project and it did not help.  Any suggestions are welcome.

rvk

  • Hero Member
  • *****
  • Posts: 3441
Re: TIBConfigService unavailable database
« Reply #6 on: March 01, 2018, 08:05:26 pm »
It just works for me. Try this:
  • Open Lazarus and choose Project > New Project
  • Choose Application > Ok
  • Drop a Button on the form
  • Drop a TIBConfigService (from the Firebird Admin tab) on the form
  • Double click the Button and write this between the begin/end
Code: Pascal  [Select]
  1.   IBConfigService1.ServerName := 'SRV1/3050';
  2.   IBConfigService1.Params.Clear; // <- do not forget this if you use Params.add
  3.   IBConfigService1.Params.Add('USER_NAME=SYSDBA');
  4.   IBConfigService1.Params.Add('PASSWORD=masterkey');
  5.   IBConfigService1.LoginPrompt := False;
  6.   IBConfigService1.DatabaseName := 'D:\Firebird\jet_txt.fdb';
  7.   IBConfigService1.Active := True;
  8.   IBConfigService1.SetSweepInterval(150);
  9.   Showmessage('done');

I just tried it and it sets the SweepInterval of the DB to 150.

I also noticed you have a weird Lazarus version. Lazarus 1.8.1 FPC 3.0.5 seems like a very old trunk version. It's not standard release. Always use the latest trunk or a stable (even) release.

tonyw

  • Full Member
  • ***
  • Posts: 117
    • MWA Software
Re: TIBConfigService unavailable database
« Reply #7 on: March 02, 2018, 12:37:27 am »
I installed the IBX 2.2.0 version, released just today.  The FBAdmin example is extremely complex, so it's kind of difficult to see where my app is going wrong, and what is going right in the example.  I'm assuming the error message "Unavailable Database" must be caused by something simple... like, there is either and attachment that shouldn't exist (I have switched off all my database components) or, there isn't an attachment that should exist.  In the FBAdmin example, it actually appears that a server properties component is activated, just before the .SetSweepInterval command.  I tried that in my project and it did not help.  Any suggestions are welcome.

You may find it easier to understand the IB Services components if you read section 2.8 of https://mwasoftware.co.uk/downloads/send/5-ibx-current/179-firebirdservermgmtusingibx. This pdf is also included in the ibx 2.2 zip and is intended to reduce confusion in how the IB Services components work.

I am actually very critical of the original Borland design for the IB Services. It looks like it was thrown together without much thought on how it should be used and confuses the user by having a very different operational model from TIBDatabase. The design really should have had a separate "services" connection component which represents the services connection in the same way that TIBDatabase represents the database connection. The remaining IBServices components then reference the services connection component in the same way that (e.g.) TIBQuery links to the database component. Instead, the Borland design had each of the services components creating a separate connection to the server rather than sharing a common connection.

However, although I would have liked to redesign this area, I have seen it as important that Delphi users of IBX should be able to move an application from Delphi to Lazarus with the minimum of effort and so have never changed the basic approach of the IBServices components and, instead, tried to make work them work as best as possible.

The DBAdmin application uses all the IBServices components and instead of making each one create a separate connection to the server, the design allows them to share the same connection. It uses a TIBServerProperties component as the primary services component i.e. this is the one used to manage the services API connection, and the components' "assign" method is then used to share the connection with the other IBServices components. That is, when an IBServices component such a TIBConfigService is needed, it is activated by a common function that first checks to make sure that the IBServerProperties1 component is active and logged into the server and then copies the connection handle to the TIBConfigService component.

Returning to your application, the problem will be in the setting of one of the component properties. My guess is that you have not set the protocol to TCP. Note also that the servername should not have included a port number. IBX 2.2 IBServices components do now include a "PortNo" property that allows you to set a non-default port number if you need this.

RedOctober

  • Full Member
  • ***
  • Posts: 218
Re: TIBConfigService unavailable database
« Reply #8 on: March 02, 2018, 12:52:54 am »
All good info Tony.  Thanks.  I'll proceed with debugging based on your examples, and those given by other posters.  I'll post back here what I find.

RedOctober

  • Full Member
  • ***
  • Posts: 218
Re: TIBConfigService unavailable database
« Reply #9 on: March 02, 2018, 08:13:07 pm »
Hi rvk and tonyw:

Assuming:
...
fb_db: TIBDatabase;
fb_cg: TIBConfigService;
...


The entire problem was caused by the different requirements of the IBX Components .DatabaseName property.

In TIBDatabase.DatabaseName it can, and sometimes must, contain:

fb_db.DatabaseName := host + '/' + port + ':' + database_file_name;

Example:  'SRV1/3051:D:\app_vlt\db\fdb\jet_txt.fdb'

However, the TIBConfigService.DatabaseName must never contain the server or port, and must ONLY contain the database file name.  (This confusion was made worse by the "just prior" release version of IBX not having a .PortNo property, so I had to "stick" the port somewhere, like on the end of the Server name.

Example:

fb_cg.DatabaseName := 'D:\app_vlt\db\fdb\jet_txt.fdb';

Now with version 2.2.0 we have a .PortNo property which helps us to know where to put the port number.  However, one still cannot simply do:

fb_cg.DatabaseName := fb_db.DatabaseName;

Which is what caused my confusion for the last few days.

Problem now solved.  I can now set my Sweep Interval and other Firebird configuration settings.



tonyw

  • Full Member
  • ***
  • Posts: 117
    • MWA Software
Re: TIBConfigService unavailable database
« Reply #10 on: March 03, 2018, 01:00:01 am »
Good to know that you have found your problem.

As I said earlier, the design of the IBServices components is confusing when compared with TIBDatabase. However, what you are now pointing to is a naming convention that IBX has picked up from Firebird and dates back to InterBase. That is the "DatabaseName" when used in the Firebird Database API (in IBX TIBDatabase) is really a "Connect String". That is, like a URL it includes the name of the server, the path to the database file, a protocol identifier and even a port no - all in the same string. The Firebird 3 release notes give examples of all the possible combinations.

On the other hand, when used in the Services API, the "DatabaseName" is no more than the path to the database file on the server.

What is happening here is that the Services API connection is to a server rather than a database and the DatabaseName is simply a parameter to a command sent after the connection has been established to the server. It can only be the path to the database file as the server, protocol and port no. are now implicit in the connection over which the command is sent.

The Services API does have its own connect string format. In fact this is almost identical to the Database API, except that the database path is replaced by the string 'service_mgr'. So if

myserver:/var/lib/firebird/data/mydatabase.fdb

is a connect string to a database file on "myserver"  for a TCP connection then

myserver:service_mgr

is a connect string to the services API on "myserver" again using TCP.

Of course you don't see this in IBX because the IBServices components hide it from you by having the separate  ServerName, Protocol and PortNo properties. Some of the IBServices components (e.g. TValidationService) need to refer to a specific Database (on the server) and so they additionally have a DatabaseName property - but that is the name of a database file on the server - so it is just the path to the database file on the server.

If you think you have now got your head around this, just remember that Firebird 3 has made this even more complicated by adding an "expected_db" parameter to the Services API Params property. And, guess what, the value of this is a path to a database file on the server, but not necessarily the same database as used in the DatabaseName property. - and has nothing to do with the connect string either. This parameter was introduced because of the Firebird 3 capability to have alternative security databases. It tells the server that you are logging in using user credentials in the security database linked to the user database given by the expected_db parameter.

All pretty straightforward really ;)
« Last Edit: March 03, 2018, 01:01:50 am by tonyw »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus