A Maven project containing examples for connecting to a database, running stored procedures, triggers, and etc. This project uses the MySQL example database "sakila", please review the Files section below to obtain the database.
- Java Development Kit 14
- MySQL Community Server 8
- Java IDE (ex. Eclipse or IntelliJ IDEA Community)
- Download and install JDK 14.
-
Download MySQL Community Server 8
NOTE: For Windows, click on 'MySQL Installer for Windows', otherwise, click on 'MySQL Community Server'. -
Install MySQL Community. Please follow this installation guide for help.
-
Open Eclipse IDE.
-
Click File in the toolbar at the top.
-
Click Import...
-
In the pop-up, click the Git folder in the center section.
-
Click Projects from Git (with smart import).
-
Click Next at bottom of the current window.
-
Click Clone URI and click Next
-
Paste "https://github.com/katkeit/SQL-Examples" into URI section and click Next.
NOTE: The window will fill out some sections automatically. -
Click Next.
-
Ensure the directory path is where you want the project to store. Click Next.
-
Click Finish.
-
Open IntelliJ IDEA Community.
NOTE: If any existing projects are open, click File in the toolbar at the top, and click Close Project. -
On the right-hand side of the IntelliJ IDEA launcher click "Get from Version Control".
NOTE: This window will automatically appear if all currently opened projects are closed. -
On the left side of the window make sure Repository URL is selected.
-
In the center, copy and paste "https://github.com/katkeit/SQL-Examples" into the URL box.
-
Confirm where you want the files to clone to in the Directory box.
-
Click Clone at the bottom.
-
With the project open, go to File, and click 'Project Structure...'.
-
In the Project Structure window, and click the Project tab inside the Project Settings section on the left.
-
In the middle section of the window, under the Project SDK section, click the drop down menu, and select 'java version 14'.
-
Click the OK button at the bottom of the window.
-
Open MySQL Workbench 8
NOTE: For users using command line, please follow this guide to restore the database. -
Double-click on your 'Local instance MySQL80' and enter your root password. The root password would have been created during installation.
NOTE: To reset your root password on Windows, follow this guide. For Linux users, please follow this guide. -
In the Navigator window, click the Administrator tab at the bottom of the window, and click 'Data Import/Restore'.
-
In the 'Import Options' section, select 'Import from Self-Contained File', and browse for the 'sakila-schema.sql' file.
NOTE: You need to download the 'sakila database' zip file from the link in the File section below. -
At the bottom, click 'Start Import' button.
NOTE: Once the import is complete, then you can close the tab. -
Repeat Step 4 and 5, but browse for the 'sakila-data.sql' file instead.
-
In the Navigator menu, click the Schemas tab at the bottom, click the refresh button near the top, and 'sakila' database should appear.
- MySQL Example Database - Sakila
NOTE: Follow the "Configuring MySQL Community Server 8" guide inside the "Setting up and Configuring" section above.