forked from knastnt/JavaRush-Training-Topjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfiles.java
More file actions
30 lines (26 loc) · 900 Bytes
/
Profiles.java
File metadata and controls
30 lines (26 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package ru.javawebinar.topjava;
public class Profiles {
public static final String
JDBC = "jdbc",
JPA = "jpa",
DATAJPA = "datajpa";
public static final String REPOSITORY_IMPLEMENTATION = DATAJPA;
public static final String
POSTGRES_DB = "postgres",
HSQL_DB = "hsqldb",
HEROKU = "heroku";
// Get DB profile depending of DB driver in classpath
public static String getActiveDbProfile() {
try {
Class.forName("org.postgresql.Driver");
return POSTGRES_DB;
} catch (ClassNotFoundException ex) {
try {
Class.forName("org.hsqldb.jdbcDriver");
return Profiles.HSQL_DB;
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Could not find DB driver");
}
}
}
}