Skip to content
Snippets Groups Projects
Commit a3763838 authored by Mads Lundegaard's avatar Mads Lundegaard
Browse files

Merge branch 'setup-db-connection' into 'dev'

Setup db connection

See merge request !10
parents 8f59d22d c3b51943
No related branches found
No related tags found
2 merge requests!13Weekly Merge To Master,!10Setup db connection
Pipeline #73581 passed
......@@ -3,6 +3,7 @@
target/
.idea/
*.properties
# User-specific stuff
.idea/**/workspace.xml
......
<?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
......@@ -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*
......
......@@ -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>
......
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;
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment