Skip to content
Snippets Groups Projects
Commit 9d721904 authored by Agsha Athalla Nurkareem's avatar Agsha Athalla Nurkareem
Browse files

feat: soap database setup

parent cd4f4f5e
No related merge requests found
DB_URL = jdbc:mysql://soap-db:3306/eatsnow-soap-service
DB_USER = user
DB_PASS = password
\ No newline at end of file
-- Create the Logging table
CREATE TABLE logging (
req_desc TEXT NOT NULL,
ip VARCHAR(255) NOT NULL,
endpoint VARCHAR(255) NOT NULL,
timestamp DATETIME NOT NULL
);
-- Create the Review table
CREATE TABLE review (
review_id INT AUTO_INCREMENT PRIMARY KEY,
content TEXT NOT NULL,
rating FLOAT NOT NULL,
id_user INT NOT NULL,
name_user VARCHAR(255) NOT NULL,
profile_img VARCHAR(255) NOT NULL,
id_restaurant INT NOT NULL
);
\ No newline at end of file
package com.eatsnowsoap.core;
import java.sql.*;
import io.github.cdimascio.dotenv.Dotenv;
public class Database {
private Connection connection;
private Dotenv dotenv = Dotenv.load();
private String DB_URL = dotenv.get("DB_URL");
private String DB_USER = dotenv.get("DB_USER");
private String DB_PASS = dotenv.get("DB_PASS");
public Database(){
try{
this.connection = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
System.out.println("Connected to the database!");
} catch (Exception e){
e.printStackTrace();
System.out.println("Failed to connect to the database!");
}
}
public Connection getConnection() {
return this.connection;
}
public void closeConnection(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment