Ignore:
Timestamp:
02/03/24 15:58:58 (5 months ago)
Author:
Blazho <aleksandar.blazhevski@…>
Branches:
master
Children:
aea04dd
Parents:
3e572eb
Message:

added missing files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/cookbook/dbConfig/DB.java

    r3e572eb r501396e  
    1 package com.example.cookbook.dbConfig;public class DB {
     1package com.example.cookbook.dbConfig;
     2
     3
     4import org.springframework.stereotype.Component;
     5
     6
     7import java.sql.Connection;
     8import java.sql.DriverManager;
     9import java.sql.SQLException;
     10
     11@Component
     12public class DB {
     13//    private static final String SSH_HOST = "194.149.135.130";
     14//    private static final String SSH_USER = "t_cbdb";
     15//    private static final String SSH_PASSWORD = "b6cd27a3";
     16
     17    private static final String DB_URL = "jdbc:postgresql://localhost:9999/db_202324z_va_prj_cbdb";
     18    private static final String DB_USERNAME = "db_202324z_va_prj_cbdb_owner";
     19    private static final String DB_PASSWORD = "d922daf2bfec";
     20
     21
     22    private static final String LDB_URL = "jdbc:postgresql://localhost:5432/cbdb";
     23    private static final String LDB_USERNAME = "postgres";
     24    private static final String LDB_PASSWORD = "04UF@bak";
     25
     26    private static Connection connection = null;
     27
     28
     29
     30
     31
     32
     33    private static void setConnection() throws SQLException {
     34
     35        if (connection == null || connection.isClosed()){
     36            connection = DriverManager.getConnection(LDB_URL, LDB_USERNAME, LDB_PASSWORD);
     37            connection.createStatement().execute("set search_path to project");
     38        }
     39    }
     40
     41    public static Connection getConnection() throws SQLException {
     42        setConnection();
     43        return connection;
     44    }
     45
     46
     47    public static void closeConnection() throws SQLException {
     48        if (connection != null){
     49            connection.close();
     50        }
     51    }
    252}
     53
Note: See TracChangeset for help on using the changeset viewer.