Database is in use - Cannot connect to the database with my application

310 Views Asked by At

I am using Firebird 4.0 with SuperServer installed on Microsoft Windows 2011. I am developing a win64 database application with Delphi to access the database file on a remote computer.

If I connect to the database file with IBExpert while I also try to connect to the same database with the application I am developing, I get the following error message:

[FireDAC][Phys][FB]lock time-out on wait transaction
object D:\MYFILES\DATABASE\SZERYNG\IMOVEIS_FIREBIRD\BANCO DE DADOS\DBIMOVEIS.FDB is in use

I can open more than one IBExpert and connect to the same database file but I cannot connect to the database file with my application if any other application like IBExpert is connected to the same database file.

IBExpert
FDConnection
IBExpert database registration info My application's FDConnection parameters
Database
Database File
D:\MyFiles\Database\Szeryng\Imoveis_Firebird\Banco de Dados\DBIMOVEIS.FDB D:\MyFiles\Database\Szeryng\Imoveis_Firebird\Banco de Dados\DBIMOVEIS.FDB
Server/Protocol
Protocol
Remote, TCP/IP TCPIP
Server Name
Server
127.0.0.1 127.0.0.1
Port 3040 3040
User Name
User_Name
SYSDBA SYSDBA
Charset
Character Set
ISO8859_1 ISO8859_1
Server Version Firebird 4.0
SQL Dialect 3
Client Library File
FDPhysFBDriveLink.VendorLib
c:\windows\syswow64\fbclient.dll c:\windows\system32\fbclient.dll

IBExpert database registration info:

Database File: D:\MyFiles\Database\Szeryng\Imoveis_Firebird\Banco de Dados\DBIMOVEIS.FDB
Server/Protocol: Remote, TCP/IP
Server Name: 127.0.0.1
Port: 3040
User Name: SYSDBA
Charset: ISO8859_1
Server Version: Firebird 4.0
Client Library File: c:\windows\syswow64\fbclient.dll

My application's FDConnection parameters:

Database: D:\MyFiles\Database\Szeryng\Imoveis_Firebird\Banco de Dados\DBIMOVEIS.FDB;
Protocol: TCPIP;
Server: 127.0.0.1;
Port: 3040;
User_Name: SYSDBA;
Character Set: ISO8859_1;
SQL Dialect: 3;
IBAdvanced: set_db_readonly=0;

FDPhysFBDriveLink.VendorLib = c:\windows\system32\fbclient.dll; 

My application does not use the embedded Firebird client. How can I solve this problem?

2

There are 2 best solutions below

0
user13964273 On

This error can be caused during attach to a database by Database Parameters Block including one of following options: isc_dpb_disable_wal, isc_dpb_set_read_only or dpb_set_db_replica. Former will throw the error unconditionally the rest only if the connection is not alone.

Also an attempt of dropping of the database with more than one connection will result in this error but I don't think that this is the case.

0
IMeMine On

After I have removed from the IBAdvanced parameter of FDConnection the set_db_readonly=0, now my application can connect to the database while IBExpert or any other application is already connect to the same database.

I have included the set_db_readonly=0 parameter in the IBAdvanced parameter of the FDConnection as suggested by the help of FireDAC to set the database as read\write.