Use C ++ Builder to develop multi-layer database applications

Source: Internet
Author: User
Use C ++ Builder to develop multi-layer database applications-general Linux technology-Linux programming and kernel information. The following is a detailed description. I. Implementation of Multi_Tier Structure

The Multi_Tier proposed by C ++ Builder is to take BDE, SQLLink, and DataModule in the previous Client/Server front-end applications to another NT Server, also called the application Server, the front-end server only leaves applications and DBClient. DLL, And the DataModule moved to the Application Server becomes a COM program, which transfers SQL to the back-end database through BDE and SQL Link and accesses data from the back-end database; then, the Tdatasetprovider component compresses the read Dataset and splits it into a segment of data packet, which is passed to the front-end machine through the DCOM mechanism and the DBClient on the front-end machine. DLL restores the received Data packet to DataSet and sends it to the TclientDataSet component in the program. The Data Control component can operate on the TclientDataSet as a Data source. The COM program correctly writes the modified DataSe back-end database.

Compared with the Client/Server structure, the Multi_Tier structure has many advantages:

1. greatly reduce the burden on database servers. Because an application server is added and the Connection processing of many Client machines is taken over, the database server only needs to process the Connection of the application server) the increase in the number affects the system performance.

2. Easy installation of front-end machine applications. In the Multi_Tier structure, BDE, SQL Link, and DataModule in the previous Client/Server front-end applications are obtained to a few application servers. The front-end machine is only responsible for UseInterface processing, only one simple EXE file (including DBClient. DLL), you can develop front-end applications on the application server and copy them to each front-end machine through the network.

II. Environment Configuration

1. backend database server:

The intermediate software provided by the database system and database. In this article, ORACLE 7.3 and ORACLE8 and SQL * NET 2.3 can be installed on the VMS system.

2. Application Server:

(1) install Windows NT on the PC Server to make it a Microsoft NT Server.
(2) ensure that the network is smooth, that is, the network layer communication protocol (TCP/TIP, IPX ...) .
(3) install the middleware provided by the database system. This article is an ORACLE for nt SQL * NET product provided by ORACLE. Run the SQL * NET Easy Configuration tool to set the TNS connection parameters of ORACLE, add a database alias to connect to the back-end ORACLE database server.
(4) install BDE Administrator and set the parameters of BDE. The specific step is to create a new alias in Databases. This article is ORACLE2, where the parameters are changed:
SERVERNAME: the alias of the ORACLE database server defined in step 1.
Net protocol: TNS
User name: oracle user name/Password
(5) install the C ++ builder 5 software for development and use it to develop applications on the application server and client.

3. Front-end client:

(1) install the Operating System Windows 95/98. This document uses Windows 98 to ensure that the front-end machines and application servers are connected on the TCP/IP layer.

(2) copy the DBClient. DLL from the \ Winnt \ System32 directory of the NT Server to the \ Windows \ System on the local machine.

(3) If the operating system is Windows 95, you must install the DCOM program, because Windows 98 and Windows NT Workstation already contain the DCOM program and do not need to install it separately.

(4) applications are developed on the application server and replicated over the network.

3. Implementation steps

The following is an example of the Multi_Tier structure database management program that maintains the material inventory table. You can maintain the inventory table of the ORACLE database on the Alpha machine through the intermediate NT application server on the Windows 98 server at the front end:

1. Development of applications on the Application Server:

(1) open a NEW project and click [RemoteDataModule] in the main function menu [NEW] to fill in the Coclass Name item. Here is KCBB.

(2) Place the DATABASE, TABLE, and DataSetProvider components on RemoteDataModule and set the attributes as follows:
Aliasname ORACLE2 of Database1
Databasename TEST of Database1
Database1 Connected TRUE
Databasename TEST of Table1
Tablename KCB of Table1
Active TRUE of Table1
(These six rows are connected to the table KCB of the backend database oracle2)
DataSetProvider's Dataset TABLE1
Exported TRUE of DataSetProvider
(These two rows are used to pass the table KCB as the DATASET to the front-end program by the DataSetProvider component)
(3) Add a Lable component in Forms1 and write "the server application has been started" on it. This will appear on the screen during running, indicating that the program has been called.
(4) run the program and register it.
To connect the front-end program to this COM program, you must register it in the registry of the server. You can run Regedit. EXE according to the coclass name? Why is it true? How can I find out why I am not doing this? Br/>
2. Front-End program development:

(1) open a new project, drag a DCOMConnection component, a ClientDataSet component, DataSource component, and Dbgrid component to FORM1, and set the attributes as follows:
DCOMConnection1's Computername application server machine name
Servername PROJECT1.KCBB (COM registration name) of DCOMConnection1)
Remoteserver DCOMCONNECTION1 of ClientDataSet1
Provider TABLE1 of ClientDataSet1
Active true of ClientDataSet1
(These five lines connect to the COM program of the application server, and the receiving table KCB serves as the Dataset of the Local Machine)
DATASET ClientDataSet1 of DataSource
Dbgrid DataSource performance1
(These two rows use the Dbgrid component to operate the Dataset on the local machine)

(2) drag 7 buttons as function buttons to add, modify, delete, cancel, write, re-read, and return. Because BC ++ B provides the ActionList component, which includes StandardAction, you can use these standard actions to compile the Dataset editing function, you only need to point the Action attribute of the Button to the corresponding ActionList item according to the function assigned by each Button.

3. Copy the debugged front-end program to all front-end machines and run the debugging. A database application with a Multi_Tier structure can be put into use.

This article describes a method for developing database applications with the Multi_Tier structure and needs to be further improved, for example, how to improve the data transmission efficiency and error handling during data transmission requires further programming.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.