In this exercise you will learn how to setup a connection to the database running inside your virtual machine (Note: All backing services needed in this course are also running locally in the VM to allow local tests and debugging).
Furthermore, you will get to know the VCAP_SERVICES
environment variable and understand how it can be used for local databases.
Continue with your solution of the last exercise. If this does not work, you can checkout the branch origin/solution-6-Deploy-Ads-On-CF
.
We want to manage the connection to the PostgreSQL database within Eclipse using the DBeaver
eclipse plugin.
Open the DBeaver
perspective (under Window
-> Perspective
-> Open Perspective
).
We have to create a new connection in the Database Navigator
view as follows:
- Right click and select
Create New Connection
- Select "PostgreSQL" from the list of connection types and hit "Next".
- Enter the following settings (also see screenshot) and proceed. All the other settings may remain at their default values. The JDBC URL will be filled automatically.
- host: localhost
- port: 5432
- database (name): test
- user: testuser
- password: test123!
- Pressing the button "Test Connection" or switching to the "Driver properties" tab will open a download screen which will download the appropriate driver for you.
- Press "Next" or "Finish" and the creation of the connection is completed.
You can connect to the database by simply double-clicking the connection in the Database Navigator
view.
If you get the error message "Can't create driver instance" when trying to connect, the PostgreSQL driver was not (successfully) downloaded. Retry by editing the connection and make sure to confirm the download.
Make sure, that the test
database appears in bold, which means that this is the current active one.
You can view the contents of a database table by double-clicking the name of the table under public
-> Tables
and then choose Data
from the main view.
Open the file localEnvironmentSetup.bat
(or localEnvironmentSetup.sh
) in an editor.
Find the definition of the VCAP_SERVICES
local variable and understand how it is used to define the database connection information.
- Cloud Foundry Environment Variables
- DBeaver for Eclipse for a convenient access of your local database.
-
© 2018 SAP SE