1
2
3
4
5
6
7
8
9 package com.wakaleo.schemaspy.util;
10
11
12
13
14
15
16
17 public final class JDBCHelper {
18
19
20 private JDBCHelper() {
21 }
22
23
24
25
26
27 private static final String[][] DATABASE_TYPES_MAP = {
28 {"jdbc:derby:", "derby"},
29 {"jdbc:db2:", "db2"},
30 {"jdbc:firebirdsql:", "firebirdsql"},
31 {"jdbc:hsqldb:hsql:", "hsqldb"},
32 {"jdbc:informix-sqli:", "informix-sqli"},
33 {"jdbc:microsoft:sqlserver:", "mssql"},
34 {"jdbc:jtds:", "mssql-jtds"},
35 {"jdbc:mysql:", "mysql"},
36 {"jdbc:oracle:oci8:", "ora"},
37 {"jdbc:oracle:thin:", "orathin"},
38 {"jdbc:postgresql:", "pgsql"},
39 {"jdbc:sybase:Tds:", "sybase"}
40 };
41
42
43
44
45
46
47
48
49 public static String extractDatabaseType(final String jdbcUrl) {
50 String result = null;
51 for (String[] databaseTypeEntry : DATABASE_TYPES_MAP) {
52 String jdbcPrefix = databaseTypeEntry[0];
53 if (jdbcUrl.startsWith(jdbcPrefix)) {
54 result = databaseTypeEntry[1];
55 }
56 }
57 return result;
58 }
59 }