- This lesson will teach you the following concepts
- Installing a local HFSQL server
- Creating an application that is using a HFSQL Client/Server database
- Adapting an application to use a HFSQL Client/Server database
- Adapting the example
- Features available in HFSQL Client/Server mode
Lesson 5.2. Implementing a Client/Server database
This lesson will teach you the following concepts
- Installing a local HFSQL server.
- Creating an application that is using a HFSQL Client/Server database.
- Adapting an application to manage a HFSQL Client/Server database.
- Features available in Client/Server mode.
Estimated time: 10 mn
In this lesson, we are going to perform all operations required to develop and to deploy an application that is using a HFSQL Client/Server database.
Installing a local HFSQL server
The first operation to perform consists in installing a HFSQL server.
This server can be installed locally on the development computer (that's what we are going to do). In deployment, this server can be installed on a specific computer.
The HFSQL server setup program is available on the WINDEV setup media. If you do not have this media, the HFSQL server setup is also available on our site (www.windev.com
- To install the HFSQL server locally:
- Start the WINDEV setup program.
- Choose "HFSQL Client/Server Setup".
- Then, select "Install or update a HFSQL Client/Server server".
- Accept the license agreement.
- Choose the platform ("For Windows on this computer").
- If HFSQL servers are already installed on the current computer, select "Install a new server".
- Select the setup directory and specify the server name and port. The port 4900 will be used by default.
|Don't forget to open this port on the firewall in order to connect to the HFSQL server from another computer.|
- Install the HFSQL Control Center if it is not already present or accessible from your computer.
|The HFSQL Control Center is required to manage the HFSQL Client/Server database.|
- The wizard proposes to configure the sending of notifications in order to identify the server dysfunctions in real time. In our example, go to the next step and indicate that the setting will be performed "Later".
- The wizard proposes to configure the authentication via Active Directory. In our example, go to the next step directly.
- Validate (or not) the participation in product improvement by allowing us to collect information regarding the use of product. This optional and anonymous collect allows PC SOFT to improve the product features.
- The setup is performed. By default, to connect to the server in administrator mode, use the "admin" user without password. This password can be changed in this last wizard step.
|For security reasons, don't forget to change the administrator password.|
Creating an application that is using a HFSQL Client/Server database
Creating a WINDEV application that is using a HFSQL Client/Server database is child's play. You must:
- Create the project by asking to create a new database.
- Create the analysis by specifying that the databases used by the project will be "HFSQL Client/Server" databases.
- Specify the characteristics of the connection to the HFSQL Client/Server server that will be used.
- When creating a data file in the analysis, indicate that this data file is in Client/Server mode and specify the connection used.
|You can also describe the connection to the HFSQL server by programming. See the online help for more details: HDescribeConnection.|
Adapting an application to use a HFSQL Client/Server database
Switching a database from HFSQL Classic mode to Client/Server mode is the most common operation.
WINDEV proposes several methods to perform this switch:
- perform this adaptation in the data model editor.
- perform this adaptation from the HFSQL Control Center.
To better understand the different steps, we are going to switch the application that was created in Part 3 to Client/Server mode by using the first method, the data model editor.
Adapting the example
|If you did not perform the operations in the previous lessons, you can follow this lesson by opening a corrected project: in the WINDEV home page (Ctrl + <), click "Tutorial" and select "Full application (Answer)".|
- To adapt the project:
- Open the "WD Full Application" project if necessary.
- In the project explorer, select (if necessary) the project configuration "Windows 32-bit executable".
- Load the analysis of your project in the data model editor: click among the quick access buttons. The data model editor is displayed.
- On the "Analysis" pane, in the "Connection" group, click "New connection". A wizard is opened, allowing you to create a connection.
- Select the type of connection to create: "HFSQL Client/Server".
- Go to the next step.
- In the following steps, specify:
- the server name (name of your computer for example) and the port number. Go to the next step.
- the user name and password (leave this information empty to use the administrator). Go to the next step.
- the database name ("WD Full Application" in our example). Go to the next step.
- Type the connection name (keep the proposed name).
- Go to the next step and validate. The connection to the database is automatically created. The wizard proposes to associate the different data files found in the analysis with the connection that was just created.
- Click "Yes".
- In the next step, select all the data files proposed:
Go to the next step.
- Then, the wizard proposes to copy the data files onto the server. Validate ("Copy now").
- Select the analysis files that will be copied onto the server: in our case, all data files found in the EXE directory.
- Go to the next step and validate.
- The data files in the analysis are automatically changed into HFSQL Client/Server data files and associated with the selected connection.
- Generate the analysis: on the "Analysis" pane, in the "Analysis" group, click "Generation". An automatic modification of data files is automatically performed. The automatic modification of data files can be canceled if all the data files are updated.
|Switching to Client/Server mode: tips|
- Check the code of your project: in HFSQL Client/Server mode, the HSubstDir statements, ... are useless
- Depending on the parameters specified when creating the connection, the connection defined in the analysis can be modified by HOpenConnection and HChangeConnection.
- HOpenConnection is used to go back to HFSQL Classic mode: all you have to do is specify the path of directory containing the HFSQL Classic data files.
- The development project was successfully adapted. You may also have to adapt the deployed application (if the deployed application is using HFSQL Classic data files for example). This operation is configured when creating the setup program of the application.
Features available in HFSQL Client/Server mode
HFSQL Client/Server proposes several features:
These features will not be described here (some of them have been presented in this tutorial in HFSQL Classic mode).
Click [Add] to post a comment