Library

How to make Firebird 3 connect like 2.5 with embedded connection string

As you know, if you specify just the path to the database in the connection string (without localhost or server name or xnet), Firebird 3 connects to the database as an embedded server: 

C:\HQbird\Firebird30>isql -user SYSDBA d:\30test.fdb
Database: d:\30test.fdb, User: SYSDBA
SQL> set list on;
SQL> select MON$remote_protocol, mon$remote_process, mon$user from mon$attachments where mon$attachment_id=current_connection;

MON$REMOTE_PROTOCOL             <null>
MON$REMOTE_PROCESS              <null>
MON$USER                        SYSDBA

As you can see, Firebird does not perform authentication in case of an embedded connection - the password is absent, and MON$REMOTE_PROTOCOL is null

If you want to connect to the local database as XNET user, with authentication, the standard way is to specify XNET as a protocol.

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey xnet://d:\30test.fdb
Database: xnet://d:\30test.fdb, User: SYSDBA
SQL> set list on;
SQL> select MON$remote_protocol, mon$remote_process, mon$user from mon$attachments where mon$attachment_id=current_connection;

MON$REMOTE_PROTOCOL             XNET
MON$REMOTE_PROCESS              C:\HQbird\Firebird30\isql.EXE
MON$USER                        SYSDBA        ​

However, it is possible to "prohibit" embedded connections, if you change the order of providers in firebird.conf to the following:

Providers = Loopback, Engine12,  Remote

In this case, it will be not possible to connect as embedded without a password, because Firebird will use XNET

C:\HQbird\Firebird30>isql -user SYSDBA  d:\30test.fdb
Statement failed, SQLSTATE = 28000
Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
Use CONNECT or CREATE DATABASE to specify a database
SQL>

In case of the connection with username and password, the connection will be established as XNET, like in Firebird 2.5

C:\HQbird\Firebird30>isql -user SYSDBA -pass masterkey d:\30test.fdb
Database: d:\30test.fdb, User: SYSDBA
SQL> set list on;
SQL> select MON$remote_protocol, mon$remote_process, mon$user from mon$attachments where mon$attachment_id=current_connection;

MON$REMOTE_PROTOCOL             XNET
MON$REMOTE_PROCESS              C:\HQbird\Firebird30\isql.EXE
MON$USER                        SYSDBA