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 sequence.
31: *
32: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
33: */
34: public class GeneratorDetailsTab extends BasePreparedStatementTab {
35: private static final StringManager s_stringMgr = StringManagerFactory
36: .getStringManager(GeneratorDetailsTab.class);
37:
38: /**
39: * This interface defines locale specific strings. This should be
40: * replaced with a property file.
41: */
42: private interface i18n {
43:
44: // i18n[firebird.genDetails=Details]
45: String TITLE = s_stringMgr.getString("firebird.genDetails");
46: // i18n[firebird.seqDetails=Display sequence details]
47: String HINT = s_stringMgr.getString("firebird.seqDetails");
48: }
49:
50: /** Logger for this class. */
51: private final static ILogger s_log = LoggerController
52: .createLogger(GeneratorDetailsTab.class);
53:
54: public GeneratorDetailsTab() {
55: super (i18n.TITLE, i18n.HINT, true);
56: }
57:
58: protected PreparedStatement createStatement() throws SQLException {
59: ISession session = getSession();
60: IDatabaseObjectInfo doi = getDatabaseObjectInfo();
61:
62: String sql = "SELECT CAST('" + doi.getSimpleName()
63: + "' AS VARCHAR(31)) as generator_name, " + "gen_id("
64: + doi.getSimpleName() + ", 0) as current_value "
65: + "from rdb$database";
66:
67: if (s_log.isDebugEnabled()) {
68: s_log.debug("Preparing SQL: " + sql);
69: }
70: PreparedStatement pstmt = session.getSQLConnection()
71: .prepareStatement(sql);
72: return pstmt;
73: }
74: }
|