A.Y. 2020 // Group 67 // Danelutti, Di Dio Lavore, Franchini
IntelliJ project with source code for the Databases 2 class optional project. The purpose is to deploy a Java EE application with a MySQL database.
You'll need to download the following tools:
- TomEE
- MySQL
- Connector/J (choose the Platform Indipended version)
- Clone this repository
git clone https://github.com/LucaDanelutti/db2-2020-Danelutti-DiDioLavore-Franchini
# or
gh repo clone LucaDanelutti/db2-2020-Danelutti-DiDioLavore-Franchini
- Download and uncompress TomEE somewhere
- Download and install MySQL
- Open the project folder with IntelliJ IDEA Ultimate
- In the menu bar, Run > Edit Configurations...
- Click '+' in the top left and select TomEE Server > Local
- If needed, click Configure... (beside Application Server) and point to the TomEE folder
- Select a TomEE version
- Leave everything else on default settings
- In the Deployment tab, under Deploy at the server startup click '+' and select Artifact... and choose the one ending with ":war exploded"
- Click Apply
- If you haven't configured MySQL yet, do it now and take note of the credentials
- Create a schema called
marketing_application
- In IntelliJ navigate to _View > Tool Windows > Database, click '+' and select Data Source > MySQL and fill in with your database connection credentials
- In Database field, specify
marketing_application
and test the connection - Click Apply
- In the Database panel, select marketing_application under your database, right click and select Run SQL script...
- Select
sql-dump/marketing_application.sql
and run it - Navigate to the TomEE folder, and open
conf/tomee.xml
- Between the
<tomee>...</tomee>
tags, add the following code, replacing SERVER, USERNAME and PASSWORD with the credentials the application will use to connect to the database
<Resource id="MarketingApplicationDB" type="DataSource">
JdbcDriver com.mysql.cj.jdbc.Driver
JdbcUrl jdbc:mysql://SERVER:3306/marketing_application
UserName USERNAME
Password PASSWORD
</Resource>
- Download Connector/J, uncompress it and drop mysql-connector-java- in /lib
- Run the server with Shift + F10 (or click the green play button); if it's not clickable, close and reopen IntelliJ
- Once the browser opens, try logging in with username
user1
and passworduser
- If the setup was successful, you'll see a welcome page. If you get a 404 error page you probably didn't setup tomee.xml at step 20; if you can't get the server to load, you probably haven't installed TomEE or Connector/J correctly.