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 package org.riverock.dbrevision.db;
27
28 import java.sql.Connection;
29 import java.sql.PreparedStatement;
30 import java.sql.ResultSet;
31 import java.sql.DatabaseMetaData;
32 import java.util.List;
33
34 import org.riverock.dbrevision.annotation.schema.db.DbDataFieldData;
35 import org.riverock.dbrevision.annotation.schema.db.DbField;
36 import org.riverock.dbrevision.annotation.schema.db.DbForeignKey;
37 import org.riverock.dbrevision.annotation.schema.db.DbSequence;
38 import org.riverock.dbrevision.annotation.schema.db.DbTable;
39 import org.riverock.dbrevision.annotation.schema.db.DbView;
40
41
42
43
44
45
46 public abstract class Database {
47 private Connection conn = null;
48
49
50
51
52 public enum Family {
53 ORACLE, MYSQL, DB2, SQLSERVER, HYPERSONIC, MAXDB, INTERBASE, POSTGREES
54 }
55
56
57
58
59
60
61 public Database(Connection conn) {
62 this.conn = conn;
63 }
64
65 public void setConnection(Connection conn) {
66 this.conn = conn;
67 }
68
69
70
71
72
73
74 public Connection getConnection() {
75 return conn;
76 }
77
78
79
80
81
82 public abstract Family getFamily();
83
84 abstract public void setBlobField(
85 String tableName, String fieldName, byte[] bytes,
86 String whereQuery,
87 Object[] objects, int[] fieldTyped
88 );
89
90
91
92
93
94
95 public abstract boolean isBatchUpdate();
96
97 public abstract boolean isNeedUpdateBracket();
98
99 public abstract boolean isByteArrayInUtf8();
100
101 public abstract boolean isSchemaSupports();
102
103 public abstract String getDefaultSchemaName(DatabaseMetaData databaseMetaData);
104
105 public abstract String getClobField(ResultSet rs, String nameFeld);
106
107 public abstract byte[] getBlobField(ResultSet rs, String nameField, int maxLength);
108
109 public abstract void createTable(DbTable table);
110
111 public abstract void createView(DbView view);
112
113 public abstract void createSequence(DbSequence seq);
114
115 public abstract void dropTable(DbTable table);
116
117 public abstract void dropTable(String nameTable);
118
119 public abstract void dropSequence(String nameSequence);
120
121 public abstract void dropConstraint(DbForeignKey impPk);
122
123 public abstract void addColumn(DbTable table, DbField field);
124
125 public abstract void createForeignKey(DbTable view);
126
127 public abstract String getOnDeleteSetNull();
128
129 public abstract String getDefaultTimestampValue();
130
131 public abstract List<DbView> getViewList(String schemaPattern, String tablePattern);
132
133 public abstract List<DbSequence> getSequnceList(String schemaPattern);
134
135 public abstract String getViewText(DbView view);
136
137 public abstract void setLongVarbinary(PreparedStatement ps, int index, DbDataFieldData fieldData);
138
139 public abstract void setLongVarchar(PreparedStatement ps, int index, DbDataFieldData fieldData);
140
141
142
143
144
145
146
147 public abstract String getClobField(ResultSet rs, String nameFeld, int maxLength);
148
149 public abstract boolean testExceptionTableNotFound(Exception e);
150
151 public abstract boolean testExceptionIndexUniqueKey(Exception e, String index);
152
153 public abstract boolean testExceptionIndexUniqueKey(Exception e);
154
155 public abstract boolean testExceptionTableExists(Exception e);
156
157 public abstract boolean testExceptionViewExists(Exception e);
158
159 public abstract boolean testExceptionSequenceExists(Exception e);
160
161 public abstract boolean testExceptionConstraintExists(Exception e);
162
163
164
165
166 public abstract int getMaxLengthStringField();
167 }