/
FirebirdDatabase.java
130 lines (101 loc) · 3.41 KB
/
FirebirdDatabase.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package liquibase.database.core;
import liquibase.database.AbstractDatabase;
import liquibase.database.DataType;
import liquibase.database.DatabaseConnection;
import liquibase.exception.DatabaseException;
/**
* Firebird database implementation.
* SQL Syntax ref: http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_60_sqlref
*/
public class FirebirdDatabase extends AbstractDatabase {
private static final DataType BOOLEAN_TYPE = new DataType("SMALLINT", false);
private static final DataType CURRENCY_TYPE = new DataType("DECIMAL(18, 4)", false);
private static final DataType UUID_TYPE = new DataType("CHAR(36)", false);
private static final DataType CLOB_TYPE = new DataType("BLOB SUB_TYPE TEXT", false);
private static final DataType BLOB_TYPE = new DataType("BLOB", false);
private static final DataType DATETIME_TYPE = new DataType("TIMESTAMP", false);
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
return conn.getDatabaseProductName().startsWith("Firebird");
}
public String getDefaultDriver(String url) {
if (url.startsWith("jdbc:firebirdsql")) {
return "org.firebirdsql.jdbc.FBDriver";
}
return null;
}
public String getTypeName() {
return "firebird";
}
@Override
public boolean supportsSequences() {
return true;
}
public DataType getBooleanType() {
return BOOLEAN_TYPE;
}
public DataType getCurrencyType() {
return CURRENCY_TYPE;
}
public DataType getUUIDType() {
return UUID_TYPE;
}
public DataType getClobType() {
return CLOB_TYPE;
}
public DataType getBlobType() {
return BLOB_TYPE;
}
public DataType getDateTimeType() {
return DATETIME_TYPE;
}
public boolean supportsInitiallyDeferrableColumns() {
return false;
}
public String getCurrentDateTimeFunction() {
return "CURRENT_TIMESTAMP";
}
public boolean supportsTablespaces() {
return false;
}
@Override
public boolean supportsDDLInTransaction() {
return false;
}
@Override
public String getTrueBooleanValue() {
return "1";
}
@Override
public String getFalseBooleanValue() {
return "0";
}
@Override
public boolean isSystemTable(String catalogName, String schemaName, String tableName) {
return tableName.startsWith("RDB$") || super.isSystemTable(catalogName, schemaName, tableName);
}
@Override
public boolean supportsAutoIncrement() {
return false;
}
@Override
public boolean supportsSchemas() {
return false;
}
@Override
public String convertRequestedSchemaToSchema(String requestedSchema) throws DatabaseException {
if (requestedSchema == null) {
return getDefaultDatabaseSchemaName();
} else {
return requestedSchema.toUpperCase();
}
}
@Override
public String getColumnType(String columnType, Boolean autoIncrement) {
String type = super.getColumnType(columnType, autoIncrement);
if (type.startsWith("BLOB SUB_TYPE <0")) {
return getBlobType().getDataTypeName();
} else {
return type;
}
}
}