Coverage Summary for Class: ConnectionType (net.sf.persism)
Class |
Class, %
|
Method, %
|
Line, %
|
ConnectionType |
100%
(1/1)
|
100%
(11/11)
|
96.2%
(50/52)
|
1 package net.sf.persism;
2
3 enum ConnectionType {
4 Oracle("%", "\"", "\""),
5
6 MSSQL(null, "[", "]"),
7
8 @Deprecated
9 JTDS(null, "[", "]"),
10
11 Derby(null, "\"", "\""),
12
13 H2(null, "\"", "\""),
14
15 MySQL(null, "`", "`"),
16
17 PostgreSQL(null, "\"", "\""),
18
19 SQLite(null, "[", "]"),
20
21 Firebird(null, "\"", "\""),
22
23 HSQLDB(null, "\"", "\""),
24
25 UCanAccess(null, "[", "]"),
26
27 Informix(null, "", ""),
28
29 Other(null, "", "")
30 ;
31
32 private final String schemaPattern;
33 private final String keywordStartDelimiter;
34 private final String keywordEndDelimiter;
35
36 ConnectionType(String schemaPattern, String keywordStartDelimiter, String keywordEndDelimiter) {
37 this.schemaPattern = schemaPattern;
38 this.keywordStartDelimiter = keywordStartDelimiter;
39 this.keywordEndDelimiter = keywordEndDelimiter;
40 }
41
42 public static ConnectionType get(String connectionUrl) {
43 if (connectionUrl == null) {
44 return null;
45 }
46
47 if (connectionUrl.startsWith("jdbc:h2")) {
48 return H2;
49 }
50
51 if (connectionUrl.startsWith("jdbc:jtds")) {
52 return JTDS;
53 }
54
55 if (connectionUrl.startsWith("jdbc:sqlserver")) {
56 return MSSQL;
57 }
58
59 if (connectionUrl.startsWith("jdbc:oracle")) {
60 return Oracle;
61 }
62
63 if (connectionUrl.startsWith("jdbc:sqlite")) {
64 return SQLite;
65 }
66
67 if (connectionUrl.startsWith("jdbc:derby")) {
68 return Derby;
69 }
70
71 if (connectionUrl.startsWith("jdbc:mysql")) {
72 return MySQL;
73 }
74
75 if (connectionUrl.startsWith("jdbc:postgresql")) {
76 return PostgreSQL;
77 }
78
79 if (connectionUrl.startsWith("jdbc:firebirdsql")) {
80 return Firebird;
81 }
82
83 if (connectionUrl.startsWith("jdbc:hsqldb")) {
84 return HSQLDB;
85 }
86
87 if (connectionUrl.startsWith("jdbc:ucanaccess")) {
88 return UCanAccess;
89 }
90
91 if (connectionUrl.startsWith("jdbc:informix")) {
92 return Informix;
93 }
94
95 return Other;
96 }
97
98 public String getSchemaPattern() {
99 return schemaPattern;
100 }
101
102 public String getKeywordStartDelimiter() {
103 return keywordStartDelimiter;
104 }
105
106 public String getKeywordEndDelimiter() {
107 return keywordEndDelimiter;
108 }
109
110 public boolean supportsReadingFromClobType() {
111 return ConnectionType.H2 == this || ConnectionType.Oracle == this || ConnectionType.HSQLDB == this || ConnectionType.Derby == this;
112 }
113
114 public boolean supportsReadingFromBlobType() {
115 return ConnectionType.Oracle == this;
116 }
117
118 public boolean supportsSpacesInTableNames() {
119 return Util.isNotEmpty(this.keywordStartDelimiter);
120 }
121
122 public boolean supportsNonAutoIncGenerated() {
123 return ConnectionType.PostgreSQL == this || ConnectionType.MSSQL == this;
124 }
125 }