FireDAC question: How to check that a server is running on a remote server without know a database name?


FireDAC question: How to check that a server is running on a remote server without know a database name?

My problem comes when I ask the user the data of the server, where my application is going to create the databases to run.

With MSSQL I have a "solution". I connect to the database "master" that I think always exists.

But with Firebird?

I thinking about trying to create a database on the server, but I believe this is so intrusive. True?

Comments

  1. SQL Server has a known system db. Doesn't Firebird?

    ReplyDelete
  2. I've checked that Firebird, has a database called security2.fdb, but...

    a) It is in the application folder. (I think is not secure gain access to it).

    b) The user must inform about the Data Folder on the server, and of course, program files subfolder can't be because is not allowed as read/write.

    ReplyDelete
  3. I glanced the docs. FireBird has rdb$database.

    I assume you get a hostname and a port from the config input?
    You could use a TCPClient and connect to the port? If you can connect, it is most likely there?

    I assume you also would get login credentials?
    If the port check succeed, try logging in and running something like "select current_connection from rdb$database"?

    You could also check current_role if you have the rights to create a database?

    Note that I have very little experience with Firebird.

    ReplyDelete
  4. Connection params to Firebird, are like these:

    Database=FBSrv:C:\fb\ADDEMO_FB21.FDB
    User_Name=sysdba
    Password=masterkey

    I ask the user for:
    HostName
    DataFolder
    UserName
    Password

    User and password shall be of an administrator account.

    But, the main problem is... DataFolder. I don't want force the installer, to allow access to system folders on the server, only for check connectivity.

    ReplyDelete
  5. Solved!

    I try to create a new database with a name that I'm sure does not exist on the server:

    FDataBase := TfwTools.GetNewDocID;

    And to the Connection component for the test I add the next two parameters:

    DBConnection.Params.Add('OpenMode=OpenOrCreate');
    DBConnection.Params.Add('DropDatabase=Yes' );

    Oh Yes!

    The only problem is, what happens if the database, previously exists. I shall be pretty sure that this never happens.


    I've checked that, as I do not add metadata to this database, it's never physically created. But the system assures that is possible create it.

    I think is a good solution.


    Ah! and Interbase has the same pair of parameters. This is great!

    ReplyDelete
  6. I use the component "TIBServerProperties" which unfortunately is not firedac component. You can found it at "Interbase Admin" palette.
    ----------------
    var
    IBSP_: TIBServerProperties;
    begin
    ...
    set the properties like "Protocol", "Port" ans "Server"
    ...
    IBSP_.Active := True;
    if IBSP_.Active then
    begin
    IBSP_.FetchVersionInfo;
    if IBSP_.VersionInfo.ServerVersion <> 'WI-V2.1.3.18185 Firebird 2.1' then
    ...
    and so on
    --------------

    ReplyDelete
  7. Firebird is a clone from Interbase 6.0 so they are compatible in this area. To connect with an existing database - you can use also the alias of the database - look at the file aliases.conf which is in the Firebird root directory. The database administrator can edit this file so the end user (or you) don't must to know the real path to the database.

    After version 3.0.2
    The file aliases.conf is replaced by databases.conf in the Firebird root directory. The format for database aliases has not changed so you can copy/paste the contents of your existing aliases.conf file into databases.conf successfully.

    ReplyDelete
  8. You can try to connect to the Firebird's default security database, available under alias security.db
    No need to specify a file path, simply hostname:security.db

    ReplyDelete
  9. For testing if server is alive I do a simple connection by socket to the specified port, if it is ok then the server is alive and can connect to it.

    ReplyDelete
  10. Juan C. Cilleruelo You don't need a data folder. In Firebird installation folder there is a file databases.conf where you could register databases like dbname = c:\Databases\test.fdb.
    Then in the connection you ask for: host, port, dbname.

    ReplyDelete
  11. R Gosp

    The premise is that I don't have any control over the server. The user or the organization is the owner of his own server.

    I want to install my application on a computer and create/configure the needed databases into the server selected by the user.

    I can't modify anything on the server but the new databases.

    {---------------}

    Returning to the original problem, I need, with FireDAC (this is essential) test if the server can be reached with the parameters given by the user:

    I ask for this parameters:
    HostName
    DataFolder
    UserName
    Password

    and with the HostName and the DataFolder and the DatabaseName (I know his name and extensión), I form the Database parameter.

    Database=FBSrv:C:\fb\ADDEMO_FB21.FDB

    {----------------------------}

    I don't want a user with Administrator access to the server or with advanced knowledge of Firebird.

    I want to explain to the user that he can install Firebird Server as default, and use it with my program.

    I think that the method of trying to create a dummy database is valid.

    Thank you at all!

    ReplyDelete

Post a Comment