This repository has been archived by the owner on Oct 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 325
/
JdbcDatabase.java
87 lines (77 loc) · 3.43 KB
/
JdbcDatabase.java
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package org.springframework.roo.addon.jpa;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* Provides information related to JDBC database configuration.
*
* @author Stefan Schmidt
* @author Alan Stewart
* @since 1.0
*/
public enum JdbcDatabase {
DATABASE_DOT_COM("DATABASE.COM", "",
"force://HOST_NAME;user=USER_NAME;password=PASSWORD"), DB2_400(
"DB2_400", "com.ibm.as400.access.AS400JDBCDriver",
"jdbc:as400://HOST_NAME"), DB2_EXPRESS_C("DB2_EXPRESS_C",
"com.ibm.db2.jcc.DB2Driver", "jdbc:db2://HOST_NAME:50000"), DERBY_CLIENT(
"DERBY_CLIENT", "org.apache.derby.jdbc.ClientDriver",
"jdbc:derby://HOST_NAME:1527/TO_BE_CHANGED_BY_ADDON;create=true"), DERBY_EMBEDDED(
"DERBY_EMBEDDED", "org.apache.derby.jdbc.EmbeddedDriver",
"jdbc:derby:TO_BE_CHANGED_BY_ADDON;create=true"), FIREBIRD(
"FIREBIRD", "org.firebirdsql.jdbc.FBDriver",
"jdbc:firebirdsql://HOST_NAME:3050"), GOOGLE_APP_ENGINE("GAE", "",
"appengine"), H2_IN_MEMORY("H2", "org.h2.Driver",
"jdbc:h2:mem:TO_BE_CHANGED_BY_ADDON;DB_CLOSE_DELAY=-1"), HYPERSONIC_IN_MEMORY(
"HYPERSONIC", "org.hsqldb.jdbcDriver",
"jdbc:hsqldb:mem:TO_BE_CHANGED_BY_ADDON"), HYPERSONIC_PERSISTENT(
"HYPERSONIC", "org.hsqldb.jdbcDriver",
"jdbc:hsqldb:file:TO_BE_CHANGED_BY_ADDON;shutdown=true"), MSSQL(
"MSSQL", "net.sourceforge.jtds.jdbc.Driver",
"jdbc:jtds:sqlserver://HOST_NAME:1433/TO_BE_CHANGED_BY_ADDON"), MYSQL(
"MYSQL", "com.mysql.jdbc.Driver", "jdbc:mysql://HOST_NAME:3306"), ORACLE(
"ORACLE", "oracle.jdbc.OracleDriver",
"jdbc:oracle:thin:@HOST_NAME:1521"), POSTGRES("POSTGRES",
"org.postgresql.Driver", "jdbc:postgresql://HOST_NAME:5432"), SYBASE(
"SYBASE", "net.sourceforge.jtds.jdbc.Driver",
"jdbc:jtds:sybase://HOST_NAME:5000/TO_BE_CHANGED_BY_ADDON;TDS=4.2");
private final String connectionString;
private final String driverClassName;
private final String key;
/**
* Constructor
*
* @param key the internal name for this type of database (required)
* @param driverClassName
* @param connectionString the JDBC connection URL template for this type of
* database (required)
*/
private JdbcDatabase(final String key, final String driverClassName,
final String connectionString) {
Validate.notBlank(connectionString, "Connection string is required");
Validate.notBlank(key, "Key is required");
this.connectionString = connectionString;
this.driverClassName = driverClassName;
this.key = key;
}
public String getConfigPrefix() {
return "/configuration/databases/database[@id='" + key + "']";
}
public String getConnectionString() {
return connectionString;
}
public String getDriverClassName() {
return driverClassName;
}
public String getKey() {
return key;
}
@Override
public String toString() {
final ToStringBuilder builder = new ToStringBuilder(this);
builder.append("name", name());
builder.append("key", key);
builder.append("driver class name", driverClassName);
builder.append("connection string", connectionString);
return builder.toString();
}
}