01: /*
02: * HsqlConstraintReader.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.db.hsqldb;
13:
14: import java.sql.Connection;
15: import workbench.db.AbstractConstraintReader;
16:
17: /**
18: * Constraint reader for HSQLDB
19: * @author support@sql-workbench.net
20: */
21: public class HsqlConstraintReader extends AbstractConstraintReader {
22: private String TABLE_SQL = "select chk.check_clause \n"
23: + "from information_schema.system_check_constraints chk, information_schema.system_table_constraints cons \n"
24: + "where chk.constraint_name = cons.constraint_name \n"
25: + "and cons.constraint_type = 'CHECK' \n"
26: + "and cons.table_name = ?; \n";
27:
28: private String sql;
29:
30: public HsqlConstraintReader(Connection dbConnection) {
31: if (HsqlMetadata.supportsInformationSchema(dbConnection)) {
32: this .sql = TABLE_SQL;
33: } else {
34: this .sql = TABLE_SQL
35: .replaceAll("information_schema\\.", "");
36: }
37: }
38:
39: public String getPrefixTableConstraintKeyword() {
40: return "check(";
41: }
42:
43: public String getSuffixTableConstraintKeyword() {
44: return ")";
45: }
46:
47: public String getColumnConstraintSql() {
48: return null;
49: }
50:
51: public String getTableConstraintSql() {
52: return this.sql;
53: }
54:
55: }
|