forked from JavaOPs/topjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfiles.java
More file actions
31 lines (26 loc) · 926 Bytes
/
Copy pathProfiles.java
File metadata and controls
31 lines (26 loc) · 926 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
31
package ru.javawebinar.topjava;
public class Profiles {
public static final String
POSTGRES_DB = "postgres",
HSQL_DB = "hsqldb";
public static final String ACTIVE_DB = POSTGRES_DB;
public static final String
JDBC = "jdbc",
JPA = "jpa",
DATAJPA = "datajpa";
public static final String REPOSITORY_IMPLEMENTATION = DATAJPA;
// 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 resolve DB profile");
}
}
}
}