01: package org.firebirdsql.squirrel.tab;
02:
03: /*
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: import java.sql.PreparedStatement;
19: import java.sql.SQLException;
20:
21: import net.sourceforge.squirrel_sql.client.session.ISession;
22: import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BasePreparedStatementTab;
23: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
24: import net.sourceforge.squirrel_sql.fw.util.StringManager;
25: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
26: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
27: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
28:
29: /**
30: * This class will display the details for a Firebird domain.
31: *
32: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
33: */
34: public class DomainDetailsTab extends BasePreparedStatementTab {
35:
36: private static final StringManager s_stringMgr = StringManagerFactory
37: .getStringManager(DomainDetailsTab.class);
38:
39: /** SQL that retrieves the data. */
40: private static String SQL = "select rdb$field_name, "
41: + "rdb$validation_source, "
42: + "rdb$computed_source, "
43: + "rdb$default_source, "
44: + "rdb$field_length, "
45: + "rdb$field_scale, "
46: + "rdb$field_type, "
47: + "rdb$field_sub_type, "
48: + "rdb$missing_source, "
49: + "rdb$edit_string, "
50: + "rdb$character_length, "
51: + "rdb$collation_name, "
52: + "rdb$character_set_name, "
53: + "rdb$field_precision "
54: + "rdb$description "
55: + "from rdb$fields f "
56: + "left outer join rdb$character_sets cs on cs.rdb$character_set_id = f.rdb$character_set_id "
57: + "left outer join rdb$collations cl on (cl.rdb$collation_id = f.rdb$collation_id and cl.rdb$character_set_id = f.rdb$character_set_id) "
58: + "where " + " rdb$field_name = ?";
59:
60: /**
61: * This interface defines locale specific strings. This should be
62: * replaced with a property file.
63: */
64: private interface i18n {
65: // i18n[firebird.details=Details]
66: String TITLE = s_stringMgr.getString("firebird.details");
67: // i18n[firebird.domainDetails=Display domain details]
68: String HINT = s_stringMgr.getString("firebird.domainDetails");
69: }
70:
71: /** Logger for this class. */
72: private final static ILogger s_log = LoggerController
73: .createLogger(DomainDetailsTab.class);
74:
75: public DomainDetailsTab() {
76: super (i18n.TITLE, i18n.HINT, true);
77: }
78:
79: protected PreparedStatement createStatement() throws SQLException {
80: ISession session = getSession();
81: IDatabaseObjectInfo doi = getDatabaseObjectInfo();
82: if (s_log.isDebugEnabled()) {
83: s_log.debug("Preparing SQL: " + SQL);
84: }
85: PreparedStatement pstmt = session.getSQLConnection()
86: .prepareStatement(SQL);
87: if (s_log.isDebugEnabled()) {
88: s_log.debug("setString param: " + doi.getSimpleName());
89: }
90: pstmt.setString(1, doi.getSimpleName());
91: return pstmt;
92: }
93: }
|