How to Add a Database
Let's suppose we are working on the "CRM" back-end project in which we already have a Domain Model where we defined the "Company" class.
Let's start adding a new database connection in our Domain Model. Remember that, first of all, you need to create a database in the database engine you prefer (e.g. MySQL, PostgreSQL, Oracle, ...). Right-click in the Domain Model work area, then select the "Add" and then the "Database" option and type a name for the database.
Let's choose now the database type. You can choose from a set of predefined options, which are the most common database types you may want to use. Click on the drop-down menu next to the "Type" property and select a database type.
Let's configure the connection properties. Copy the Sample URL string connection and paste it next to the "URL" property. Let's now replace in the sample URL string the placeholders with the actual data, in order to obtain a new URL string able to connect the "CRM" database in our Domain Model with the existing physical one. Replace the "host" placeholder with the IP address of the workstation hosting the database (e.g., "localhost"), the "port" placeholder with the port number on which the database engine is running (e.g., "5432"). Remember that the angular brackets are part of the placeholders, and they must be removed. Finally replace the "database" placeholder with the name of the database to which you want to connect (e.g., "CRM").
Let's configure the account credential in order to allow the connection to the chosen database engine. Enter a valid username for connecting the database (e.g., "postgres") If you want to save the password in the project with encryption, you just have to flag the corresponding checkbox placed inside the "Password" property. Enter a valid password for connecting the database.
How to Test the Database Connection
Once we properly defined a database, let's test the database connection. Right-click on the database node from the Outline View and choose the "Refresh" option. The first time you make a connection with a database of a specific type, WebRatio Platform asks you to provide the JDBC driver to use for the connection. The JDBC driver is a library that is used by Java applications to connect to databases. Each database type needs its own library.
All drivers can be downloaded from the Internet. In this example we need the PostgreSQL JDBC driver. Once you download the driver, you can click on the anchor shown in the dialog select the driver from your hard drive and press the "Open" button Press the "OK" button to confirm. If everything works correctly, you should see a new element nested into the database node in the Outline View. Expand the "CRM" database node in the Outline View. As you can see a new item is now contained in the database node.