/
FirebirdDatabasePlatform.java
109 lines (88 loc) · 4.42 KB
/
FirebirdDatabasePlatform.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
package org.jumpmind.db.platform.firebird;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.sql.Types;
import javax.sql.DataSource;
import org.jumpmind.db.platform.AbstractJdbcDatabasePlatform;
import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.DatabasePlatformInfo;
import org.jumpmind.db.platform.DatabasePlatformSettings;
/*
* The platform implementation for the Firebird database.
* It is assumed that the database is configured with sql dialect 3!
*/
public class FirebirdDatabasePlatform extends AbstractJdbcDatabasePlatform {
/* The standard Firebird jdbc driver. */
public static final String JDBC_DRIVER = "org.firebirdsql.jdbc.FBDriver";
/* The subprotocol used by the standard Firebird driver. */
public static final String JDBC_SUBPROTOCOL = "firebirdsql";
/*
* Creates a new Firebird platform instance.
*/
public FirebirdDatabasePlatform(DataSource dataSource, DatabasePlatformSettings settings) {
super(dataSource, settings);
DatabasePlatformInfo info = getPlatformInfo();
info.setMaxIdentifierLength(31);
info.setSystemForeignKeyIndicesAlwaysNonUnique(true);
info.setCommentPrefix("/*");
info.setCommentSuffix("*/");
info.addNativeTypeMapping(Types.ARRAY, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.BINARY, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.BIT, "SMALLINT", Types.SMALLINT);
info.addNativeTypeMapping(Types.CLOB, "BLOB SUB_TYPE TEXT", Types.LONGVARCHAR);
info.addNativeTypeMapping(Types.DISTINCT, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.BLOB, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.DOUBLE, "DOUBLE PRECISION");
info.addNativeTypeMapping(Types.FLOAT, "DOUBLE PRECISION", Types.DOUBLE);
info.addNativeTypeMapping(Types.JAVA_OBJECT, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.LONGVARBINARY, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.LONGVARCHAR, "BLOB SUB_TYPE TEXT");
info.addNativeTypeMapping(Types.NULL, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.OTHER, "BLOB", Types.LONGVARBINARY);
// This is back-mapped to REAL in the model reader
info.addNativeTypeMapping(Types.REAL, "FLOAT");
info.addNativeTypeMapping(Types.REF, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.STRUCT, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping(Types.TINYINT, "SMALLINT", Types.SMALLINT);
info.addNativeTypeMapping(Types.VARBINARY, "BLOB", Types.LONGVARBINARY);
info.addNativeTypeMapping("BOOLEAN", "SMALLINT", "SMALLINT");
info.addNativeTypeMapping("DATALINK", "BLOB", "LONGVARBINARY");
info.setDefaultSize(Types.VARCHAR, 254);
info.setDefaultSize(Types.CHAR, 254);
info.setNonBlankCharColumnSpacePadded(true);
info.setBlankCharColumnSpacePadded(true);
info.setCharColumnSpaceTrimmed(false);
info.setEmptyStringNulled(false);
ddlReader = new FirebirdDdlReader(this);
ddlBuilder = new FirebirdDdlBuilder(info);
}
@Override
protected void createSqlTemplate() {
this.sqlTemplate = new FirebirdJdbcSqlTemplate(dataSource, settings, null);
}
public String getName() {
return DatabaseNamesConstants.FIREBIRD;
}
public String getDefaultCatalog() {
return null;
}
public String getDefaultSchema() {
return null;
}
}