diff --git a/.gitignore b/.gitignore index 14e974d2d29ac37222bb57568181e8f2f2118cf0..e48e2dfd8f1f0d8b88c2d86a3074ed5db53e9f85 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ target/ .idea/ +*.properties # User-specific stuff .idea/**/workspace.xml diff --git a/ImageApplication.iml b/ImageApplication.iml index 17c32733b6a4d708a270f93539323b1e277f363a..e89efabfbd3951717fbebe1d0639cc11592a8044 100644 --- a/ImageApplication.iml +++ b/ImageApplication.iml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="ExternalSystem" externalSystem="Maven" /> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11"> <output url="file://$MODULE_DIR$/target/classes" /> <output-test url="file://$MODULE_DIR$/target/test-classes" /> @@ -10,13 +11,22 @@ </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:13" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:mac:13" level="project" /> - <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:13" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:mac:13" level="project" /> - <orderEntry type="library" name="Maven: org.openjfx:javafx-base:13" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-base:mac:13" level="project" /> - <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:13" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:mac:13" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:slf4j-simple:1.7.30" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:13" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:win:13" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:13" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:win:13" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-base:13" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-base:win:13" level="project" /> + <orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.19" level="project" /> + <orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:13" level="project" /> + <orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:win:13" level="project" /> + <orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.2" level="project" /> </component> </module> \ No newline at end of file diff --git a/README.md b/README.md index 0350b6326c9edbc5a36e6f11ff88aa71ed5c9faf..f9fbb2ae64bdbc21cf1a1138eb67c74463bfa30c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ #### IntelliJ: *Follow these steps to run the project:* -- Open the Maven Projects window in `View -> Tool Windows -> Maven` and click on `ImageApplication -> Plugins -> javafx -> javafx:run` to execute the project +- Open the Maven Projects window in `View -> Tool Windows -> Maven` and click on `ImageApplication -> Plugins -> javafx -> javafx:compile` and then `javafx:run` to execute the project ## Questions or need help *Link to [our wiki](https://gitlab.stud.idi.ntnu.no/eirsteir/team-14-software-engineering/-/wikis/home) page, maybe add contact info* diff --git a/pom.xml b/pom.xml index fba6fe0e2b96298b5fcd39430189ee09c7092e9a..7520166c0fee469fdbd002a31a0f46d09ccd0aea 100644 --- a/pom.xml +++ b/pom.xml @@ -10,16 +10,31 @@ <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <version>1.7.30</version> + </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>13</version> </dependency> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>8.0.19</version> + </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-fxml</artifactId> <version>13</version> </dependency> + <dependency> + <groupId>com.zaxxer</groupId> + <artifactId>HikariCP</artifactId> + <version>3.4.2</version> + </dependency> </dependencies> <build> <plugins> diff --git a/src/main/java/NTNU/IDATT1002/App.java b/src/main/java/NTNU/IDATT1002/App.java index 1edc0bd5753db883e0d7be0319bc9473ae1895d4..0e62956adc3330e09888e7ba18ee60c6c18f9af7 100644 --- a/src/main/java/NTNU/IDATT1002/App.java +++ b/src/main/java/NTNU/IDATT1002/App.java @@ -1,5 +1,6 @@ package NTNU.IDATT1002; +import NTNU.IDATT1002.database.DBConnection; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; @@ -8,7 +9,6 @@ import javafx.stage.Stage; import java.io.IOException; - public class App extends Application { private static Scene scene; diff --git a/src/main/java/NTNU/IDATT1002/database/DBConnection.java b/src/main/java/NTNU/IDATT1002/database/DBConnection.java new file mode 100644 index 0000000000000000000000000000000000000000..294643e120cdaf8e9469ae7d39b964e6a3d7f69f --- /dev/null +++ b/src/main/java/NTNU/IDATT1002/database/DBConnection.java @@ -0,0 +1,33 @@ +package NTNU.IDATT1002.database; + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; + +import java.sql.Connection; +import java.sql.SQLException; + +/** + * Class for connecting to the database. This will load configurations and create a connection pool. +*/ +public class DBConnection { + + private static HikariDataSource dataSource; + + /** + * Load configuration and setup the data source + */ + static{ + HikariConfig config = new HikariConfig("datasource.properties" ); + dataSource = new HikariDataSource(config); + } + + /** + * Establish a connection pool to the database + * + * @return Connection to the database + * @throws SQLException + */ + public static Connection getConnection() throws SQLException { + return dataSource.getConnection(); + } +} \ No newline at end of file