<<

cs1106/cs6503 2019-2020

Labsheet 0– Getting Started

Summary: This sheet guides you through some steps required to execute the DBeaver tool. Configuring the driver and con- nection settings, should only need to be done once: after the first session the tool should remember the settings for subsequent sessions.

This module will use the server cs1 running the MySQL database management system. To facilitate communication back and forth to the server, we will use the DBeaver tool. This will permit us to enter, edit and execute SQL queries easily. In this lab we will configure things to allow us to use DBeaver. You will need:

• Your computer science computer account details; you should have received a set with this information during your first Python lab last week and

• Your database account details; you should have received these by email to your umail account in recent days (from “Computer Science IT Helpdesk”, subject “[cs6503/cs1106] Database Details for for Introduction to Relational Labs” and dated “Friday, September 20th”).

If you have not received either of these, we can issue you with temporary credentials just for today, but you should go to the computer science helpdesk in the next day or two to obtain your personal computer account and/or database account details.

1. Launching DBeaver This course will use the Ubuntu which supports DBeaver.

(a) Boot Ubuntu and log in. If the machine is currently running Windows, you will need to reboot. (b) Find DBeaver. Click “Activities” in the top left corner of the desktop and type “DBeaver” into the search box. Click on the beaver icon that appears.

2. Installing the MySQL driver You will only need to do this during your first session; for subsequent sessions DBeaver will remember the settings. As DBeaver is designed to work with many different DBMSs not just MySQL, a driver (essentially some code) is needed to accomodate MySQL’s idiosyncrasies. We have placed a copy of the required driver in a folder named database-driver in your home directory. The driver itself is named -connector-java-5.1.44.jar.

(a) Click on the “Driver Manager” option in the “Database” menu. (b) Scroll down through the list of names in the panel on the left to find the one named “MySQL” (not “MySQL 8+”, just plain “MySQL”) and click “Edit”. (c) Midway down under the heading “Libraries” you will find the following highlighted in blue mysql:mysql-connector-java:RELEASE [5.1.44]. Click “Delete” and confirm.

KTH September 25, 2019 1 cs1106/cs6503 2019-2020

Figure 1: DBeaver screenshot

(d) Click “Add file”. Navigate to the driver file in the database-driver directory mentioned above and select it. (e) Back in the “Edit Driver” panel, click “OK” (botton right).

3. Establishing a connection to the DB server

(a) Click on the “New Database Connection” option in the “Database” menu. (b) Click on the “MySQL” icon in the “Select your database” panel that appears. (c) In the panel named “Connection Settings”, • In the “Server Host” field, replace “localhost” with cs1.ucc.ie. • In the fields labelled “User name”, “Database” and “Password”, enter the user name, database name and password that you received by email. Make sure you do not confuse the username and the password. • Click “Test Connection”. If a pane labelled “Connection Error” appears, reen- ter your db credentials and try again; otherwise click “OK”. • Click “Finish”.

......

4. Using DBeaver The interface for DBeaver is illustrated in Figure 1. On the left, in a pane labelled “Database Navigator” is a list of the active connections (generally just one). On the upper right is a SQL editor pane, into which you will type your query and below on the lower right is a results pane where the result of the query will appear. To create a new SQL editor pane, click “New SQL Editor” option in the “SQL Editor” menu. To execute an SQL query, notice the four small orange icons on the left of the editor pane and click the third one down (tool tip “Execute SQL Script”). The result should appear underneath.

KTH September 25, 2019 2