Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

UniDAC usage tutorial (1): connect to a database

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Download the latest version of UniDAC

Universal Data Access Components (UniDAC) is a general database access component that provides direct access to multiple databases, such as Delphi, C++Builder, Lazarus (and Free Pascal), Mac OS X, iOS, Android, Linux and 64 and 32-bit FreeBSD for Windows. We will focus our long-term experience on this widget to provide unified database connection access (such as oracle, Microsoft SQL, etc.). This means that you can easily switch different databases between your projects and create cross-database application interfaces.

This article describes the process of connecting to databases with different providers and the meaning of connection parameters.

Common connection Properties

Provider

User name and password

Server

Database

Port

Provider specific properties

Oracle

SQL Server

MySQL

InterBase

PostgregSQL

SQLite

Common connection Properties

Each database server needs its own set of parameters for the connection (username, password, and so on). Some parameters are the same for multiple servers, but the meaning of the parameters may vary from server to server. UNIDO provides all types of parameters for supported database servers. If a parameter is not used for a provider, it is disabled in the connection dialog box and is not used for the connection. UNIDO supports the following parameters:

Provider

This is the first parameter that should be set. It specifies the provider and other available parameters that will be used for the connection.

User name and password

These properties are used by each database provider to authenticate client applications.

Server

Typically, this property is used to provide the name or IP address of a computer on the same network as the database server. If the server property of the SQL Server, MySQL, and Interbase providers is empty, unidac attempts to connect to the localhost.

Oracle-- in client mode, you should specify the server name that appears in the tnsnames.ora configuration file. You can also set the homename option to specify the installed client to use in client mode.

If you connect to the Oracle server in direct mode, you should specify the value of the server property in a special format: host:port:sid. The host is the IP address or DNS name of the server, the port is the port number on which the server is listening, and sid is the Oracle system identifier of the server.

SQL Server-- should specify the name or IP address of the computer on the network on which SQL Server is running. If your SQL Server uses a different port than the default port, you can connect to that port by specifying the port number: hostname, port number.

ASE, MySQL, and PostgreSQL-- you should specify the name or IP address of the computer on the network where the database server is running.

ODBC-- you should specify the ODBC data source name (DSN), the file name containing the data source information (file DSN), or the ODBC connection string

DB2-- should specify a database name for the server property

Database

This property is used for Access, Advantage, SAP Sybase ASE, DBF, Interbase, MySQL, NextUSB, PostgreSQL, SQL Server, and SQLite providers. It specifies the initial database for the connection. On SAP Sybase ASE, MySQL, and SQL Server, database values can be changed when the connection is active and not reconnected. If no database is allocated, the behavior of UniDAC depends on the selected provider:

MySQL-- will not select the current database. This means that you need to explicitly specify the database name in the query.

The default database for the current SQL Server login of SQL Server and ASE-- will be used as the default database for the connection. This property is used to provide the database file name in order to connect to the SQL Server Compact Edition.

Port

This property is used for SAP Sybase ASE, MySQL, and PostgreSQL providers. It specifies the port number of the TCP/IP connection.

The MySQL-- default value is 3306.

The PostgreSQL-- default value is 5432.

The ASE-- default value is 5000.

Provider specific properties

In addition to the connection options described above, there are several specific options to manage the connection behavior of each provider. These options are described in each provider's provider-specific Notes article: Oracle, SQL Server, MySQL, Interbase, PostgreSQL, and SQLite. Open the article corresponding to the provider you are interested in, and find a description of the specific options for tuniconnection in the article. Several important specific connection options are described below.

Oracle

Using the Oracle provider, you can connect to the server in two modes: client mode and direct mode. Connecting in client mode requires an Oracle client to be installed on the client. Connections in direct mode do not require an Oracle client, but this mode has some limitations. For more information, see the Connecting in Direct Mode section of the article (using UNIDO in conjunction with Oracle).

SQL Server

The SQL Server provider can connect through one of three client types that can be changed using the OLEDBProvider-specific tuniconnection option. By default, this option is set to prauto. This value indicates that the provider will first attempt to open the SQL native provider. If this provider is not available, the OLE DB provider opens. To connect to the SQL Server Compact version, the OledBProvider option must be set to prcompact. This value takes effect for all specific options whose names begin with compact. The version of SQL Server Compact to use should be specified in CompactVersion specific options. By default, the SQL Server Compact version is selected based on the database file version. If the file does not exist, or if it is not a valid database file, the CompactVersion option is used to determine the server version to load.

MySQL

The mysql provider can connect directly to the mysql server or use the client library libmysqld.dll. This behavior is controlled by a directly specific option. By default, Direct is set to true. If you switch directly to false, you need to deploy libmysqld.dll in your application.

In order to connect to a database with mysql embedded server, you should switch the value of the embedded-specific option to true. Its default value is false. If Embedded is set to true, the value of direct is ignored. Embedded server libraries with shared directories should be deployed with the application. The data path should be specified in the configuration file of the embedded server.

InterBase

The Intelbase provider can connect to the server through network protocols such as TCP/IP, NetBEUI, and SPX. The network protocol that will be used for the connection can be specified with protocol-specific options.

PostgreSQL

The PostgreSQL provider connects directly to the PostgreSQL server without using the PostgreSQL client library.

SQLite

The SQLite provider can connect to the database using the sqlite client library sqlite3. You can use an external SQLite3 library or an embedded sqlite3 engine. This behavior is controlled by options. By default, direct is set to false, in which case the sqlite provider searches for client libraries in the directory specified in the path environment variable. If the database file does not exist, SQLite can create the file automatically. To do this, you should use ForceCreateDatabase-specific options.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report