1 package liquibase.database.core;
2
3 import liquibase.database.AbstractDatabase;
4 import liquibase.database.DatabaseConnection;
5 import liquibase.exception.DatabaseException;
6
7 public class UnsupportedDatabase extends AbstractDatabase {
8
9 public int getPriority() {
10 return -1;
11 }
12
13 @Override
14 public void setConnection(DatabaseConnection conn) {
15 super.setConnection(conn);
16 if (currentDateTimeFunction == null) {
17 currentDateTimeFunction = findCurrentDateTimeFunction();
18 }
19 }
20
21 /**
22 * Always returns null or DATABASECHANGELOG table may not be found.
23 */
24 @Override
25 public String getDefaultCatalogName() throws DatabaseException {
26 return null;
27 }
28
29 /**
30 * Always returns null or DATABASECHANGELOG table may not be found.
31 */
32 @Override
33 protected String getDefaultDatabaseSchemaName() throws DatabaseException {
34 return null;
35 }
36
37 public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
38 return false;
39 }
40
41 public String getDefaultDriver(String url) {
42 return null;
43 }
44
45 public String getTypeName() {
46 return "unsupported";
47 }
48
49 public boolean supportsInitiallyDeferrableColumns() {
50 return false;
51 }
52
53 public String getCurrentDateTimeFunction() {
54 return currentDateTimeFunction;
55 }
56
57 private String findCurrentDateTimeFunction() {
58 // todo: reintroduce try {
59 // String nowFunction = null;
60 // String dateFunction = null;
61 // String dateTimeFunction = null;
62 // String timeStampFunction = null;
63 //
64 // String[] timeDateFunctions = getConnection().getMetaData().getTimeDateFunctions().split(",");
65 // for (String functionName : timeDateFunctions) {
66 // String function = functionName.trim().toUpperCase();
67 // if (function.endsWith("TIMESTAMP")) {
68 // timeStampFunction = functionName.trim();
69 // }
70 // if (function.endsWith("DATETIME")) {
71 // dateTimeFunction = functionName.trim();
72 // }
73 // if (function.endsWith("DATE")) {
74 // dateFunction = functionName.trim();
75 // }
76 // if ("NOW".equals(function)) {
77 // nowFunction = functionName.trim();
78 // }
79 // }
80 //
81 // if (nowFunction != null) {
82 // return "{fn "+nowFunction+"()"+"}";
83 // } else if (timeStampFunction != null) {
84 // return "{fn "+timeStampFunction+"()"+"}";
85 // } else if (dateTimeFunction != null) {
86 // return "{fn "+dateTimeFunction+"()"+"}";
87 // } else if (dateFunction != null) {
88 // return "{fn "+dateFunction+"()"+"}";
89 // } else {
90 // return "CURRENT_TIMESTAMP";
91 // }
92 //
93 // } catch (SQLException e) {
94 // throw new RuntimeException(e);
95 // }
96 return "CURRENT_TIMESTAMP";
97 }
98
99 // todo: reintroduce? @Override
100 // protected boolean canCreateChangeLogTable() throws DatabaseException {
101 // //check index size. Many drivers just return 0, so it's not a great test
102 // int maxIndexLength;
103 // try {
104 // maxIndexLength = getConnection().getMetaData().getMaxIndexLength();
105 //
106 // return maxIndexLength == 0
107 // || maxIndexLength >= 150 + 150 + 255 //id + author + filename length
108 // && super.canCreateChangeLogTable();
109 // } catch (SQLException e) {
110 // throw new DatabaseException(e);
111 // }
112 // }
113
114 public boolean supportsTablespaces() {
115 return false;
116 }
117 }