0% found this document useful (0 votes)
16 views

Tutorial 3

The document discusses implementing a database client application that connects to a RESTDataWare server. It describes adding a RDWPoolerDB component to the server to expose the database, and using RestDwDatabase and RestDwClientSQL components in the client to connect to the server and execute SQL queries against the database.

Uploaded by

jeffersonrain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Tutorial 3

The document discusses implementing a database client application that connects to a RESTDataWare server. It describes adding a RDWPoolerDB component to the server to expose the database, and using RestDwDatabase and RestDwClientSQL components in the client to connect to the server and execute SQL queries against the database.

Uploaded by

jeffersonrain
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chapter 4

Your First Database Client


During first steps I did focus on Server Application, and now is time to understand how
RESTDataWare works at Client Side. But first let’s prepare our server to send a database for
our client.

Implementing restaurant API


Last chapter I introduce to you the aim of app “Restaurant API”. To implement it, remember
both approaches I’ve introduced in first chapter: 1. DwPoolerDb; 2. DwServerEvents. Can
you understand the main difference between them?

Goals
1. Implement a RAD Client which connects at Database direct in our Server.

2. Implement an API that exposes the behavior of Restaurant for any language.

I hope you had already implemented the structure presented at Image 8. The architecture of
RestDWPooler. This diagram show how to configure a full functional database on server,
that is just enough available to consume in another Client Application. Don’t worry if you
didn’t understand yet. I will implement that structure again step by step.

A RAD Server using RDWPoolerDB


The easiest way to create a CRUD that consumes RDW server is to connect RDWPoolerDb.
In your Server DataModule, let configure a RDWPoolerDb. As you put this component in
a Datamodule that’s inherited from TServerMethodDataModule, it is already available to
consume in Client. The only property you need to setup on a RDWPollerDb is the Driver of
Connection you are using.

In this example I’m using the Firedac Connection, because this I’ve putted the
component TRestDWDriverFD. Look at your “RestDataware Core Drivers” palete if you have
already installed the driver you want. Other drivers are available to install at RDW Folder, for
example Unidac, Zeos, etc. In component Driver has a property to setup your connection.
And it is all! That is the secret to keep simple to configure and to flexible scale your
application in the future. You can easily change to another database or aggregate another
connection for different purposes.
Each Connection you want to configure you need to put another RDWPoolerDb and another Driver.

20
We create our Server that has RDWPoolerDb, which provides full access to our
Database. I don’t know which database you are using, to prove you the database layer
doesn’t mind. I mean the database looks like a classical Delphi Client-Server application. The
RestDataware will create ever mechanics you need to access this database remotely.

If you did not configure your database connection correctly the connection error will appear
on your client.

Save your server application, and then compile it. I recommend you open another Delphi to
create the client. You can also add a new application for current project group. Save as
Client.DPR

A RAD Crud using RestDWClientSQL


To create the Client run the server in background and open the new project called
Client.DPR. Put a component RestDwDatabase which provides an Image of your
RDWPoolerDb(Server) .

Server RDWPoolerDb  RestDwDatabase Client

To Configure RestDwDatabase you need to fill the properties

PoolerPort The same port you server is running Example: 8082


PoolerService The IP your server is published 127.0.0.1
Password The authentication you put on server Testserver
Login The authentication you put on server Testserver
Encoding The encoding of Server esUTF8
PoolerName The connection you want ConRestaurant
You can test if your server is running correctly in design time. Choose the property
“PoolerName” and click the pooler name you configure on server.

Now you are ready to implement your SQL on Client Side.

Add a component of pallete RestDataware Core DB, the component

RestDwClientSQL

21
Connect RestDwClientSQL to RestDwDatabase. Fill the SQL text. You can use the
RestDwClientSQLEditor to perform the SQL you want. As you can see the tables of
connection appear on left side, also the fields of selected table. Everithing is very familiar if
you have used Delphi already. Add a grid and connect to see the magic have done.

Image 10. RestDwClientSQL Editor

Image 11. A delphi form consuming RestDw in Design Time

22
Contact
If you have some question about RestDW have a look at installation guide, otherwise you
can send to me an e-mail at [email protected].

Visit official web-site https://www.restdw.com.br/

Join our community using Telegran, Skype or Facebook.

You will find me at RestDW Skype Group 1

You can read my profile in Linked’in

Visit my github to get some Delphi example. I will publish exclusive contents about RestDw
library.

23

You might also like