Local data source: Using Firebird Database

xiaoxiao2021-03-19  223

I use it to do local data sources. I would like to use Wilson's XMLDBClient, but the information is very small. Firebird is selected. Because the Firebird database can embed (Embed) to the application.

The Firebird database, from the Interbase database, Borland's product is eventually unable to win in the market (remember to bring such a database when using Delphi, it will bring such a database). However, they did not give up this project, but put it to the development source organization, continued to develop, let him continue their lives on the network. SCC gave him a name called Firebird.

As a result, lost to the east, the Sangu, Firebird got a new job.

Firebird is small. The syntax is very like DB2. Performance is good.

Firtbird is running by the running version on WIN and Linux, respectively. I use two versions of Firebird-1.5.2.4731_Embed_win32 and firebed_win32 and firebird-1.5.2.4731_win32. Download from http://www.ibphoenix.com/

There are also two installations of Classical and SuperServer under Win (there is an Embed version). After installation, the WIN system will start two service processes, FBGUARD, and FBSERVER.

Firebird has two profiles aliases.conf and firebird.conf. Aliases is used to configure the database alias. Firebird.conf is used to configure some of the running parameters of the database, such as rootpath, and so on.

Firebird offers several tools like IsQL. This tool is a tool for command line executes commands. In addition to simple features, it is directly to execute SQL. For example, after entering the connection, enter the database name, username, and password, plus ";", you can: Connect c: /firbird/employee.fdb user sysdba password masterkey;

The default user is sysdba, the password is MasterKey. Note that each command can span more lines, but the last must have a ";" will only be executed. The path of the database can be simplified by editing the alias.config file, such as directly connect ROYDB ..., just add ROYDB = C: /Firbird/employee.fdb in the Alias ​​configuration file.

FIRDBIRD provides a class library for use under .NET: firebirdsql.data.firebird.dll. The class inside provides a package of multi-Firebird database access. Like FBCommand: Component, IDBCommand, IDisposable, Icloneable; FBConnection: Component, IDBConnection, IDisposable, Icloneable; FBDataAdapter: DBDataAdapter, IDBDataAdapter, iDataAdapter, etc.

Firebird database Embed: Database can "light"

It can be "light" again, that means it uses the database locally. Do an Embed DB.

Embed's DB still has most of the database features, only two DLL files and two profiles (Firebirdsql.Data.firebird.dll are needed under .NET). Such a database can be packaged directly with a relaxed application. Because there is no need on the target machine, as long as these two DLLs can smoothly complete the use of the database.

Of course, Embed's DB lost some of the original features, such as do not support multi-user common use, no security control, etc. These restrictions can be accepted if they are only used for local data sources.

Instructions. Just when the new fbconnection, you can change the connection string to: _Connectionstring = "Database = ROY; user = sysdba; password = masterkey; server type = 1"; note, the ROY database is configured in the Alias ​​configuration file Ok, User and Password can write casually, as long as there is two items; the most critical is that Server type = 1 This represents the data source that uses Embed. If Type = 1 is not specified, it means using a normal database. This is the feature provided by Firebirdsql.Data.firebird.dll. As for the Firebird's Readme

Client access can be only via the local protocol, ie NOT a TCP / IP connection string that includes the server name "localhost" or IP address 127.0.0.1. The embedded server supports only the IPServer "local connect" to a database file path without A Server Name. The Client Must Have Exclusive Access To The Database File.

The lower side is a constructor of a class I package, which is determined by ISEMBED which database version:

public FireBirdDbHelper (bool isEmbed) {if (isEmbed) _connectionString = "Database = roy; User = SYSDBA; Password = masterkey; server type = 1"; else _connectionString = @ "Database = D: /firebird/Firebird-1.5.2.4731_win32 /examples/employee.fdb;user=sysdba;password=masterkey;diaalect=3 ;server=localhost "; _Connection = new fbconnection (_ConnectionString);

转载请注明原文地址:https://www.9cbs.com/read-130206.html

New Post(0)