Revision: 5810
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=5810&view=rev
Author: manningr
Date: 2010-08-21 17:37:29 +0000 (Sat, 21 Aug 2010)
Log Message:
-----------
Initial changes to convert from Ant build to Maven build
Added Paths:
-----------
trunk/sql12/plugins/db2/pom.xml
trunk/sql12/plugins/db2/src/main/
trunk/sql12/plugins/db2/src/main/java/
trunk/sql12/plugins/db2/src/main/java/net/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2JCCExceptionFormatter.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2Plugin.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableIndexExtractorImpl.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableTriggerExtractorImpl.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SchemaExpander.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SequenceParentExpander.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/UDFParentExpander.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/IndexDetailsTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/ProcedureSourceTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/SequenceDetailsTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/TableSourceTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/TriggerDetailsTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/TriggerSourceTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/UDFDetailsTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/UDFSourceTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/ViewSourceTab.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/types/
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/types/DB2XmlTypeDataTypeComponent.java
trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/types/DB2XmlTypeDataTypeComponentFactory.java
trunk/sql12/plugins/db2/src/main/resources/
trunk/sql12/plugins/db2/src/main/resources/doc/
trunk/sql12/plugins/db2/src/main/resources/net/
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/plugins/db2/
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/plugins/db2/I18NStrings.properties
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/plugins/db2/tab/
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/plugins/db2/tab/I18NStrings.properties
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/plugins/db2/types/
trunk/sql12/plugins/db2/src/main/resources/net/sourceforge/squirrel_sql/plugins/db2/types/I18NStrings.properties
trunk/sql12/plugins/db2/src/test/
trunk/sql12/plugins/db2/src/test/java/
trunk/sql12/plugins/db2/src/test/java/net/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/DB2PluginTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/exp/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableIndexExtractorImplTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableTriggerExtractorImplTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SchemaExpanderTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SequenceParentExpanderTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/exp/UDFParentExpanderTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/IndexDetailsTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/ProcedureSourceTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/SequenceDetailsTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/TableSourceTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/TriggerDetailsTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/TriggerSourceTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/UDFDetailsTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/UDFSourceTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/tab/ViewSourceTabTest.java
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/types/
trunk/sql12/plugins/db2/src/test/java/net/sourceforge/squirrel_sql/plugins/db2/types/DB2XmlTypeDataTypeComponentFactoryTest.java
Removed Paths:
-------------
trunk/sql12/plugins/db2/doc/
trunk/sql12/plugins/db2/plugin_build.xml
trunk/sql12/plugins/db2/src/net/
Property Changed:
----------------
trunk/sql12/plugins/db2/
Property changes on: trunk/sql12/plugins/db2
___________________________________________________________________
Added: svn:ignore
+ target
.settings
.project
.classpath
Deleted: trunk/sql12/plugins/db2/plugin_build.xml
===================================================================
--- trunk/sql12/plugins/db2/plugin_build.xml 2010-08-21 17:36:49 UTC (rev 5809)
+++ trunk/sql12/plugins/db2/plugin_build.xml 2010-08-21 17:37:29 UTC (rev 5810)
@@ -1,88 +0,0 @@
-<?xml version="1.0"?>
-<!--
- This is an Apache Ant build file to build the SQL script plugin
- for distribution.
--->
-<project name="plugin-db2" default="build" basedir=".">
- <target name="init">
- <tstamp/>
- <property name="internal_name" value="db2"/>
- <property name="version" value="0.01"/>
-
- <property name="debug" value="on"/>
- <property name="optimize" value="off"/>
- <property name="deprecation" value="on"/>
- <property name="targetVM" value="1.6"/>
-
- <echo message="---------------- ${internal_name} ${version} ----------------"/>
-
- <property environment="env"/>
- </target>
- <target name="initdirs" unless="p_plugin.work_dir">
- <property name="dist_dir" value="../../../squirrel-sql-dist/squirrel-sql"/>
- <property name="plugins_dist_dir" value="${dist_dir}/plugins"/>
- <property name="p_plugin.work_dir" value="${plugins_dist_dir}/${internal_name}/work"/>
- <property name="p_plugin.core_libs_dir" value="${dist_dir}/core/dist/lib"/>
- <property name="p_plugin.dist_dir" value="${dist_dir}/core/dist/plugins"/>
- </target>
- <!--
- ==================================================================
- Compile the plugin.
- No parameters.
- ==================================================================
- -->
- <target name="build" depends="init, initdirs">
- <property name="obj_dir" value="${p_plugin.work_dir}/obj"/>
-
- <mkdir dir="${obj_dir}"/>
- <mkdir dir="${p_plugin.dist_dir}"/>
-
- <javac srcdir="src"
- destdir="${obj_dir}"
- deprecation="${deprecation}"
- debug="${debug}"
- optimize="${optimize}"
- includeJavaRuntime="yes"
- source="${targetVM}"
- target="${targetVM}">
-
- <classpath>
- <fileset dir="${p_plugin.core_libs_dir}">
- <include name="**/*.*"/>
- </fileset>
- </classpath>
- </javac>
- <copy todir="${obj_dir}" >
- <fileset dir="src" >
- <include name="**/*.gif"/>
- <include name="**/*.jpg"/>
- <include name="**/*.jpeg"/>
- <include name="**/*.xml"/>
- <include name="**/*.xsl"/>
- <include name="**/*.properties"/>
- </fileset>
- </copy>
-
- <jar jarfile="${p_plugin.dist_dir}/${internal_name}.jar" compress="false">
- <fileset dir="${obj_dir}">
- <include name="**/*.*"/>
- </fileset>
- </jar>
-
- <copy todir="${p_plugin.dist_dir}/${internal_name}" >
- <fileset dir="doc" >
- <include name="**/*.*"/>
- </fileset>
- </copy>
-
-
- <jar jarfile="${p_plugin.dist_dir}/${internal_name}/src.jar" compress="false">
- <fileset dir=".">
- <include name="src/**/*.*"/>
- <include name="plugin_build.xml"/>
- </fileset>
- </jar>
- </target>
-
-</project>
-
Added: trunk/sql12/plugins/db2/pom.xml
===================================================================
--- trunk/sql12/plugins/db2/pom.xml (rev 0)
+++ trunk/sql12/plugins/db2/pom.xml 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,135 @@
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>net.sf.squirrel-sql.plugins</groupId>
+ <artifactId>squirrelsql-plugins-parent-pom</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <groupId>net.sf.squirrel-sql.plugins</groupId>
+ <artifactId>db2</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Db2 Plugin</name>
+ <description>Db2 Plugin</description>
+ <inceptionYear>2001</inceptionYear>
+ <developers>
+ <developer>
+ <name>Gerd Wagner</name>
+ <roles>
+ <role>Administrator</role>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ <developer>
+ <name>Rob Manning</name>
+ <roles>
+ <role>Developer</role>
+ <role>Release Manager</role>
+ </roles>
+ </developer>
+ </developers>
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License</name>
+ <url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+ <url>http://www.squirrelsql.org/</url>
+ <scm>
+ <connection>scm:svn:https://squirrel-sql.svn.sourceforge.net/svnroot/squirrel-sql/trunk/sql12/</connection>
+ <developerConnection>scm:svn:http://squirrel-sql.svn.sourceforge.net/viewvc/squirrel-sql/trunk/sql12/</developerConnection>
+ <url>http://squirrel-sql.svn.sourceforge.net/viewvc/squirrel-sql/trunk/sql12/</url>
+ </scm>
+ <issueManagement>
+ <system>SourceForge Tracker</system>
+ <url>http://sourceforge.net/tracker/?group_id=28383%26atid=393414</url>
+ </issueManagement>
+ <ciManagement>
+ <system>Hudson</system>
+ <url>https://www.squirrel-sql.org/hudson/</url>
+ </ciManagement>
+ <dependencies>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>fw</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>squirrel-sql</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>squirrel-sql</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.squirrel-sql</groupId>
+ <artifactId>squirrelsql-test-utils</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>${source-plugin-version}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire-plugin-version}</version>
+ <configuration>
+ <parallel>${surefire-parallel-type}</parallel>
+ <threadCount>${surefire-thread-count}</threadCount>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>${jar-plugin-version}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>${assembly-plugin-version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>${findbugs-plugin-version}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>${pmd-plugin-version}</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>${checkstyle-plugin-version}</version>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <!--
+ Since generating javadoc can be time-consuming, this is not done unless a "javadoc" profile is activated.
+ -->
+ <profile>
+ <id>javadoc</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc-plugin-version}</version>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
\ No newline at end of file
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2JCCExceptionFormatter.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/DB2JCCExceptionFormatter.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2JCCExceptionFormatter.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2JCCExceptionFormatter.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,103 @@
+package net.sourceforge.squirrel_sql.plugins.db2;
+/*
+ * Copyright (C) 2007 Christoph Schmitz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+import java.lang.reflect.Method;
+
+import net.sourceforge.squirrel_sql.fw.util.ExceptionFormatter;
+
+/**
+ * Formats an exception of the new DB2 JCC driver, where the human-readable
+ * error message needs to be obtained from a DB2SqlCa object.
+ *
+ * Invokes DB2 specific methods via reflection in order to avoid the need for
+ * the proprietary DB2 class files for compilation.
+ *
+ * @author Christoph Schmitz <sch...@us...>
+ */
+public class DB2JCCExceptionFormatter implements ExceptionFormatter {
+
+ /*
+ * As the JCC driver code is obfuscated, we do not check the full class
+ * name, but resort to checking a prefix and suffix instead.
+ *
+ * In my version, the full class name is "com.ibm.db2.jcc.c.SqlException"
+ */
+
+ // Prefix for the JCC SqlException class name
+ private static final String JCC_EXCEPTION_PREFIX = "com.ibm.db2.jcc";
+
+ // Class name for the JCC SqlException class
+ private static final String JCC_EXCEPTION_CLASS = "SqlException";
+
+ // Names of the various methods we need to invoke
+ private static final String METHOD_GET_SQLCA = "getSqlca";
+
+ private static final String METHOD_GET_SQL_STATE = "getSqlState";
+
+ private static final String METHOD_GET_SQL_CODE = "getSqlCode";
+
+ private static final String METHOD_GET_MESSAGE = "getMessage";
+
+ /**
+ * Checks if this {@link Throwable} is a DB2 JCC SqlException
+ * (com.ibm.db2.jcc.*.SqlException) by testing for the proper prefix and
+ * suffix of the class name
+ *
+ * @see net.sourceforge.squirrel_sql.fw.util.ExceptionFormatter#formatsException(Throwable)
+ */
+ public boolean formatsException(Throwable t) {
+ if (t == null) {
+ return false;
+ } else {
+ String className = t.getClass().getName();
+ return className.startsWith(JCC_EXCEPTION_PREFIX)
+ && className.endsWith(JCC_EXCEPTION_CLASS);
+ }
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.util.ExceptionFormatter#format(Throwable)
+ */
+ public String format(Throwable t) throws Exception {
+ StringBuilder builder = new StringBuilder();
+ // DB2Sqlca sqlca = ((DB2Diagnosable) t).getSqlca();
+ Method getSqlca = t.getClass().getMethod(METHOD_GET_SQLCA,
+ (Class[]) null);
+ Object sqlca = getSqlca.invoke(t, (Object[]) null);
+
+ // String msg = sqlca.getMessage();
+ Method getMessage = sqlca.getClass().getMethod(METHOD_GET_MESSAGE,
+ (Class[]) null);
+ String msg = getMessage.invoke(sqlca, (Object[]) null).toString();
+
+ // int sqlCode = sqlca.getSqlCode();
+ Method getSqlCode = sqlca.getClass().getMethod(METHOD_GET_SQL_CODE,
+ (Class[]) null);
+ int sqlCode = (Integer) getSqlCode.invoke(sqlca, (Object[]) null);
+
+ // int sqlstate = sqlca.getSqlState();
+ Method getSqlState = sqlca.getClass().getMethod(
+ METHOD_GET_SQL_STATE, (Class[]) null);
+ String sqlState = getSqlState.invoke(sqlca, (Object[]) null)
+ .toString();
+
+ builder.append(msg).append(" SQL Code: ").append(sqlCode).append(
+ ", SQL State: ").append(sqlState);
+ return builder.toString();
+ }
+}
\ No newline at end of file
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2Plugin.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/DB2Plugin.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2Plugin.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/DB2Plugin.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,330 @@
+package net.sourceforge.squirrel_sql.plugins.db2;
+
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+import java.sql.SQLException;
+import java.sql.Types;
+
+import net.sourceforge.squirrel_sql.client.IApplication;
+import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
+import net.sourceforge.squirrel_sql.client.plugin.PluginException;
+import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
+import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallbackAdaptor;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableIndexExtractor;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.TableWithChildNodesExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.DatabaseObjectInfoTab;
+import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.CellComponentFactory;
+import net.sourceforge.squirrel_sql.fw.dialects.DialectFactory;
+import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+import net.sourceforge.squirrel_sql.plugins.db2.exp.DB2TableIndexExtractorImpl;
+import net.sourceforge.squirrel_sql.plugins.db2.exp.DB2TableTriggerExtractorImpl;
+import net.sourceforge.squirrel_sql.plugins.db2.exp.SchemaExpander;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.IndexDetailsTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.ProcedureSourceTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.SequenceDetailsTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.TableSourceTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.TriggerDetailsTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.TriggerSourceTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.UDFDetailsTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.UDFSourceTab;
+import net.sourceforge.squirrel_sql.plugins.db2.tab.ViewSourceTab;
+import net.sourceforge.squirrel_sql.plugins.db2.types.DB2XmlTypeDataTypeComponentFactory;
+
+/**
+ * The main controller class for the DB2 plugin.
+ *
+ * @author manningr
+ */
+public class DB2Plugin extends DefaultSessionPlugin
+{
+
+ private static final String JCC_DRIVER_NAME = "IBM DB2 JDBC Universal Driver Architecture";
+
+ /** The product name that indicates we need to use os/400 queries */
+ private static final String OS_400_PRODUCT_NAME = "DB2 UDB for AS/400";
+
+ private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(DB2Plugin.class);
+
+ /** Logger for this class. */
+ private final static ILogger s_log = LoggerController.createLogger(DB2Plugin.class);
+
+ /** API for the Object Tree. */
+ private IObjectTreeAPI _treeAPI;
+
+ static interface i18n
+ {
+ // i18n[DB2Plugin.showUdfSource=Show UDF source]
+ String SHOW_UDF_SOURCE = s_stringMgr.getString("DB2Plugin.showUdfSource");
+
+ // i18n[DB2Plugin.showViewSource=Show view source]
+ String SHOW_VIEW_SOURCE = s_stringMgr.getString("DB2Plugin.showViewSource");
+
+ // i18n[DB2Plugin.showProcedureSource=Show procedure source]
+ String SHOW_PROCEDURE_SOURCE = s_stringMgr.getString("DB2Plugin.showProcedureSource");
+
+ // i18n[DB2Plugin.showTriggerSource=Show trigger source]
+ String SHOW_TRIGGER_SOURCE = s_stringMgr.getString("DB2Plugin.showTriggerSource");
+
+ }
+
+ /**
+ * Return the internal name of this plugin.
+ *
+ * @return the internal name of this plugin.
+ */
+ public String getInternalName()
+ {
+ return "db2";
+ }
+
+ /**
+ * Return the descriptive name of this plugin.
+ *
+ * @return the descriptive name of this plugin.
+ */
+ public String getDescriptiveName()
+ {
+ return "DB2 Plugin";
+ }
+
+ /**
+ * Returns the current version of this plugin.
+ *
+ * @return the current version of this plugin.
+ */
+ public String getVersion()
+ {
+ return "0.04";
+ }
+
+ /**
+ * Returns the authors name.
+ *
+ * @return the authors name.
+ */
+ public String getAuthor()
+ {
+ return "Rob Manning";
+ }
+
+ /**
+ * Returns a comma separated list of other contributors.
+ *
+ * @return Contributors names.
+ */
+ public String getContributors()
+ {
+ return "Christoph Schmitz, Tilmann Brenk, Lars Heller";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getChangeLogFileName()
+ */
+ public String getChangeLogFileName()
+ {
+ return "changes.txt";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getHelpFileName()
+ */
+ public String getHelpFileName()
+ {
+ return "readme.html";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getLicenceFileName()
+ */
+ public String getLicenceFileName()
+ {
+ return "licence.txt";
+ }
+
+ /**
+ * Load this plugin.
+ *
+ * @param app
+ * Application API.
+ */
+ public synchronized void load(IApplication app) throws PluginException
+ {
+ super.load(app);
+ }
+
+ /**
+ * Initialize this plugin.
+ */
+ public synchronized void initialize() throws PluginException
+ {
+ super.initialize();
+
+ // register custom DataTypeComponent factory for DB2 XML
+ CellComponentFactory.registerDataTypeFactory(new DB2XmlTypeDataTypeComponentFactory(),
+ Types.OTHER,
+ "XML");
+ }
+
+ /**
+ * Application is shutting down so save preferences.
+ */
+ public void unload()
+ {
+ super.unload();
+ }
+
+ public boolean allowsSessionStartedInBackground()
+ {
+ return true;
+ }
+
+ /**
+ * Session has been started. Update the tree api in using the event thread
+ *
+ * @param session
+ * Session that has started.
+ * @return <TT>true</TT> if session is Oracle in which case this plugin is interested in it.
+ */
+ public PluginSessionCallback sessionStarted(final ISession session)
+ {
+
+ if (!isPluginSession(session))
+ {
+ return null;
+ }
+ GUIUtils.processOnSwingEventThread(new Runnable()
+ {
+ public void run()
+ {
+ updateTreeApi(session);
+ }
+ });
+
+ // Install DB2JCCExceptionFormatter iff we're using the JCC driver
+ try
+ {
+ if (JCC_DRIVER_NAME.equals(session.getMetaData().getJDBCMetaData().getDriverName()))
+ {
+ session.setExceptionFormatter(new DB2JCCExceptionFormatter());
+ }
+ } catch (SQLException e)
+ {
+ s_log.error("Problem installing exception formatter: " + e.getMessage());
+ }
+
+ return new PluginSessionCallbackAdaptor(this);
+ }
+
+ @Override
+ protected boolean isPluginSession(ISession session)
+ {
+ return DialectFactory.isDB2(session.getMetaData());
+ }
+
+ private void updateTreeApi(ISession session)
+ {
+ String stmtSep = session.getQueryTokenizer().getSQLStatementSeparator();
+ boolean isOS400 = isOS400(session);
+
+ _treeAPI = session.getSessionInternalFrame().getObjectTreeAPI();
+ _treeAPI.addDetailTab(DatabaseObjectType.PROCEDURE, new ProcedureSourceTab(i18n.SHOW_PROCEDURE_SOURCE,
+ isOS400,
+ stmtSep));
+ _treeAPI.addDetailTab(DatabaseObjectType.VIEW, new ViewSourceTab( i18n.SHOW_VIEW_SOURCE,
+ stmtSep,
+ isOS400));
+
+ _treeAPI.addDetailTab(DatabaseObjectType.INDEX, new DatabaseObjectInfoTab());
+ _treeAPI.addDetailTab(DatabaseObjectType.INDEX, new IndexDetailsTab(isOS400));
+
+ _treeAPI.addDetailTab(DatabaseObjectType.TRIGGER, new DatabaseObjectInfoTab());
+ _treeAPI.addDetailTab(DatabaseObjectType.TRIGGER_TYPE_DBO, new DatabaseObjectInfoTab());
+
+ _treeAPI.addDetailTab(DatabaseObjectType.SEQUENCE, new DatabaseObjectInfoTab());
+ _treeAPI.addDetailTab(DatabaseObjectType.SEQUENCE, new SequenceDetailsTab(isOS400));
+
+ _treeAPI.addDetailTab(DatabaseObjectType.UDF, new DatabaseObjectInfoTab());
+ _treeAPI.addDetailTab(DatabaseObjectType.UDF, new UDFSourceTab(i18n.SHOW_UDF_SOURCE, stmtSep, isOS400));
+ _treeAPI.addDetailTab(DatabaseObjectType.UDF, new UDFDetailsTab(isOS400));
+
+ _treeAPI.addDetailTab(DatabaseObjectType.TABLE, new TableSourceTab("Show MQT Source", stmtSep, isOS400));
+
+ // Expanders - trigger and index expanders are added inside the table
+ // expander
+ _treeAPI.addExpander(DatabaseObjectType.SCHEMA, new SchemaExpander(isOS400));
+
+ // Expanders - trigger and index expanders are added inside the table
+ // expander
+ TableWithChildNodesExpander tableExpander = new TableWithChildNodesExpander();
+
+ // tableExpander.setTableIndexExtractor(extractor);
+ ITableIndexExtractor indexExtractor = new DB2TableIndexExtractorImpl(isOS400);
+ tableExpander.setTableIndexExtractor(indexExtractor);
+
+ ITableTriggerExtractor triggerExtractor = new DB2TableTriggerExtractorImpl(isOS400);
+ tableExpander.setTableTriggerExtractor(triggerExtractor);
+
+ _treeAPI.addExpander(DatabaseObjectType.TABLE, tableExpander);
+
+ _treeAPI.addDetailTab(DatabaseObjectType.TRIGGER, new TriggerDetailsTab());
+ _treeAPI.addDetailTab(DatabaseObjectType.TRIGGER, new TriggerSourceTab( i18n.SHOW_TRIGGER_SOURCE,
+ isOS400,
+ stmtSep));
+
+ }
+
+ /**
+ * Determines whether or not we've connected to DB2 on OS/400.
+ *
+ * @param session
+ * @return
+ */
+ private boolean isOS400(ISession session)
+ {
+ boolean result = false;
+ try
+ {
+ String prodName = session.getMetaData().getDatabaseProductName();
+ if (prodName == null || prodName.equals(""))
+ {
+ s_log.info("isOS400: product name is null or empty. " + "Assuming not an OS/400 DB2 session.");
+ } else if (prodName.equals(OS_400_PRODUCT_NAME))
+ {
+ s_log.info("isOS400: session appears to be an OS/400 DB2");
+ result = true;
+ } else
+ {
+ s_log.info("isOS400: session doesn't appear to be an OS/400 DB2");
+ }
+ } catch (SQLException e)
+ {
+ s_log.error("isOS400: unable to determine the product name: " + e.getMessage(), e);
+ }
+ return result;
+ }
+}
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableIndexExtractorImpl.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableIndexExtractorImpl.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableIndexExtractorImpl.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableIndexExtractorImpl.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.plugins.db2.exp;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableIndexExtractor;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+
+/**
+ * Provides the query and parameter binding behavior for DB2's index catalog.
+ *
+ * @author manningr
+ */
+public class DB2TableIndexExtractorImpl implements ITableIndexExtractor {
+
+ /** Logger for this class */
+ private final static ILogger s_log =
+ LoggerController.createLogger(DB2TableIndexExtractorImpl.class);
+
+ /** The query that finds the indexes for a given table */
+ private static final String query =
+ "select INDNAME from SYSCAT.INDEXES " +
+ "where TABSCHEMA = ? " +
+ "and TABNAME = ? ";
+
+ /** The query that finds the indexes for a given table on OS/400 */
+ private static final String OS_400_SQL =
+ "select " +
+ "index_name " +
+ "from qsys2.sysindexes " +
+ "where table_schema = ? " +
+ "and table_name = ? ";
+
+ /** boolean to indicate whether or not this session is OS/400 */
+ private boolean isOS400 = false;
+
+ /**
+ * Ctor.
+ *
+ * @param isOS400 whether or not the session is OS/400
+ */
+ public DB2TableIndexExtractorImpl(boolean isOS400) {
+ this.isOS400 = isOS400;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableIndexExtractor#bindParamters(java.sql.PreparedStatement, net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo)
+ */
+ public void bindParamters(PreparedStatement pstmt, IDatabaseObjectInfo dbo)
+ throws SQLException
+ {
+ if (s_log.isDebugEnabled()) {
+ s_log.debug("Binding schema name "+dbo.getSchemaName()+
+ " as first bind value");
+ s_log.debug("Binding table name "+dbo.getSimpleName()+
+ " as second bind value");
+ }
+ pstmt.setString(1, dbo.getSchemaName());
+ pstmt.setString(2, dbo.getSimpleName());
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableIndexExtractor#getTableIndexQuery()
+ */
+ public String getTableIndexQuery() {
+ if (isOS400) {
+ return OS_400_SQL;
+ }
+ return query;
+ }
+
+}
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableTriggerExtractorImpl.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableTriggerExtractorImpl.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableTriggerExtractorImpl.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/DB2TableTriggerExtractorImpl.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.plugins.db2.exp;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+
+/**
+ * Provides the query and parameter binding behavior for DB2's trigger catalog.
+ *
+ * @author manningr
+ */
+public class DB2TableTriggerExtractorImpl implements ITableTriggerExtractor {
+
+ /** Logger for this class */
+ private final static ILogger s_log =
+ LoggerController.createLogger(DB2TableTriggerExtractorImpl.class);
+
+ /** The query that finds the triggers for a given table */
+ private final static String SQL =
+ "select TRIGNAME from SYSCAT.TRIGGERS " +
+ "where TABSCHEMA = ? " +
+ "and TABNAME = ? ";
+
+ /** The query that finds the triggers for a given table in DB2 on OS/400 */
+ private final static String OS400_SQL =
+ "select trigger_name " +
+ "from qsys2.systriggers " +
+ "where trigger_schema = ? " +
+ "and event_object_table = ? ";
+
+ /** boolean to indicate whether or not this session is OS/400 */
+ private boolean isOS400 = false;
+
+ /**
+ * Ctor.
+ *
+ * @param isOS400 whether or not the session is OS/400
+ */
+ public DB2TableTriggerExtractorImpl(boolean isOS400) {
+ this.isOS400 = isOS400;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor#bindParamters(java.sql.PreparedStatement, net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo)
+ */
+ public void bindParamters(PreparedStatement pstmt, IDatabaseObjectInfo dbo)
+ throws SQLException
+ {
+ if (s_log.isDebugEnabled()) {
+ s_log.debug("Binding schema name "+dbo.getSchemaName()+
+ " as first bind value");
+ s_log.debug("Binding table name "+dbo.getSimpleName()+
+ " as second bind value");
+ }
+ pstmt.setString(1, dbo.getSchemaName());
+ pstmt.setString(2, dbo.getSimpleName());
+
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.ITableTriggerExtractor#getTableTriggerQuery()
+ */
+ public String getTableTriggerQuery() {
+ String result = SQL;
+ if (isOS400) {
+ result = OS400_SQL;
+ }
+ return result;
+ }
+
+}
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SchemaExpander.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/exp/SchemaExpander.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SchemaExpander.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SchemaExpander.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,95 @@
+package net.sourceforge.squirrel_sql.plugins.db2.exp;
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData;
+
+/**
+ * This class is an expander for the schema nodes. It will add Sequence and UDF Object
+ * Type nodes to the schema node.
+ *
+ * @author manningr
+ */
+public class SchemaExpander implements INodeExpander
+{
+
+ /** whether or not we are connected to OS/400 */
+ private boolean isOS400 = false;
+
+ /**
+ * Ctor.
+ */
+ public SchemaExpander(boolean isOS400)
+ {
+ super();
+ this.isOS400 = isOS400;
+ }
+
+ /**
+ * Create the child nodes for the passed parent node and return them. Note
+ * that this method should <B>not</B> actually add the child nodes to the
+ * parent node as this is taken care of in the caller.
+ *
+ * @param session Current session.
+ * @param node Node to be expanded.
+ *
+ * @return A list of <TT>ObjectTreeNode</TT> objects representing the child
+ * nodes for the passed node.
+ */
+ public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)
+ {
+ final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
+ final IDatabaseObjectInfo parentDbinfo = parentNode.getDatabaseObjectInfo();
+ final SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();
+ final String catalogName = parentDbinfo.getCatalogName();
+ final String schemaName = parentDbinfo.getSimpleName();
+
+ IDatabaseObjectInfo seqInfo =
+ new DatabaseObjectInfo(catalogName,
+ schemaName,
+ "SEQUENCE",
+ DatabaseObjectType.SEQUENCE_TYPE_DBO,
+ md);
+ ObjectTreeNode node = new ObjectTreeNode(session, seqInfo);
+ node.addExpander(new SequenceParentExpander(isOS400));
+ childNodes.add(node);
+
+ IDatabaseObjectInfo udfInfo =
+ new DatabaseObjectInfo(catalogName,
+ schemaName,
+ "UDF",
+ DatabaseObjectType.UDF_TYPE_DBO,
+ md);
+ ObjectTreeNode udfnode = new ObjectTreeNode(session, udfInfo);
+ udfnode.addExpander(new UDFParentExpander(isOS400));
+ childNodes.add(udfnode);
+
+
+ return childNodes;
+ }
+
+}
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SequenceParentExpander.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/exp/SequenceParentExpander.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SequenceParentExpander.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/SequenceParentExpander.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,123 @@
+package net.sourceforge.squirrel_sql.plugins.db2.exp;
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.schemainfo.ObjFilterMatcher;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
+import net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData;
+import net.sourceforge.squirrel_sql.fw.sql.SQLUtilities;
+/**
+ * This class handles the expanding of the "Sequence Group"
+ * node. It will give a list of all the Sequences available in the schema.
+ *
+ * @author manningr
+ */
+public class SequenceParentExpander implements INodeExpander
+{
+ /** SQL used to load sequence names */
+ private static final String SQL =
+ "select SEQNAME " +
+ "from SYSCAT.SEQUENCES " +
+ "WHERE SEQSCHEMA = ? " +
+ "AND SEQNAME like ? ";
+
+ /** SQL used to load sequence names on OS/400 */
+ private static final String OS_400_SQL =
+ "select sequence_name " +
+ "from qsys2.syssequences " +
+ "where sequence_schema = ? " +
+ "and sequence_name like ? ";
+
+ /** whether or not we are connected to OS/400 */
+ private boolean isOS400 = false;
+
+ /**
+ * Default ctor.
+ */
+ public SequenceParentExpander(boolean isOS400)
+ {
+ super();
+ this.isOS400 = isOS400;
+ }
+
+ /**
+ * Create the child nodes for the passed parent node and return them. Note
+ * that this method should <B>not</B> actually add the child nodes to the
+ * parent node as this is taken care of in the caller.
+ *
+ * @param session Current session.
+ * @param node Node to be expanded.
+ *
+ * @return A list of <TT>ObjectTreeNode</TT> objects representing the child
+ * nodes for the passed node.
+ */
+ public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)
+ throws SQLException
+ {
+ final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
+ final IDatabaseObjectInfo parentDbinfo = parentNode.getDatabaseObjectInfo();
+ final ISQLConnection conn = session.getSQLConnection();
+ final SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();
+ final String catalogName = parentDbinfo.getCatalogName();
+ final String schemaName = parentDbinfo.getSchemaName();
+ final ObjFilterMatcher filterMatcher = new ObjFilterMatcher(session.getProperties());
+
+ String sql = SQL;
+ if (isOS400) {
+ sql = OS_400_SQL;
+ }
+
+ final PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = null;
+ try
+ {
+ pstmt.setString(1, schemaName);
+ pstmt.setString(2, filterMatcher.getSqlLikeMatchString());
+ rs = pstmt.executeQuery();
+ while (rs.next())
+ {
+ IDatabaseObjectInfo si = new DatabaseObjectInfo(catalogName,
+ schemaName, rs.getString(1),
+ DatabaseObjectType.SEQUENCE, md);
+
+ if(filterMatcher.matches(si.getSimpleName()))
+ {
+ childNodes.add(new ObjectTreeNode(session, si));
+ }
+ }
+ }
+ finally
+ {
+ SQLUtilities.closeResultSet(rs);
+ SQLUtilities.closeStatement(pstmt);
+ }
+ return childNodes;
+ }
+}
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/UDFParentExpander.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/exp/UDFParentExpander.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/UDFParentExpander.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/exp/UDFParentExpander.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,124 @@
+package net.sourceforge.squirrel_sql.plugins.db2.exp;
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.schemainfo.ObjFilterMatcher;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
+import net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData;
+import net.sourceforge.squirrel_sql.fw.sql.SQLUtilities;
+/**
+ * This class handles the expanding of the "UDF"
+ * node. It will give a list of all the User-Defined Functions in the schema that match the
+ * object tree filter criteria.
+ *
+ * @author manningr
+ */
+public class UDFParentExpander implements INodeExpander
+{
+ /** SQL used to load UDF names */
+ private static final String SQL =
+ "SELECT name " +
+ "FROM SYSIBM.SYSFUNCTIONS " +
+ "WHERE schema = ? " +
+ "AND name like ? " +
+ "AND implementation is null";
+
+ /** SQL used to load UDF names on OS/400 systems */
+ private static final String OS_400_SQL =
+ "select routine_name " +
+ "from QSYS2.SYSFUNCS " +
+ "where routine_schema = ? " +
+ "and routine_name like ? ";
+
+ /** whether or not we are connected to OS/400 */
+ private boolean isOS400 = false;
+
+ /**
+ * Default ctor.
+ */
+ public UDFParentExpander(boolean isOS400)
+ {
+ super();
+ this.isOS400 = isOS400;
+ }
+
+ /**
+ * Create the child nodes for the passed parent node and return them. Note
+ * that this method should <B>not</B> actually add the child nodes to the
+ * parent node as this is taken care of in the caller.
+ *
+ * @param session Current session.
+ * @param node Node to be expanded.
+ *
+ * @return A list of <TT>ObjectTreeNode</TT> objects representing the child
+ * nodes for the passed node.
+ */
+ public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)
+ throws SQLException
+ {
+ final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
+ final IDatabaseObjectInfo parentDbinfo = parentNode.getDatabaseObjectInfo();
+ final ISQLConnection conn = session.getSQLConnection();
+ final SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();
+ final String catalogName = parentDbinfo.getCatalogName();
+ final String schemaName = parentDbinfo.getSchemaName();
+ final ObjFilterMatcher filterMatcher = new ObjFilterMatcher(session.getProperties());
+
+
+ String sql = SQL;
+ if (isOS400) {
+ sql = OS_400_SQL;
+ }
+ final PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = null;
+ try
+ {
+ pstmt.setString(1, schemaName);
+ pstmt.setString(2, filterMatcher.getSqlLikeMatchString());
+ rs = pstmt.executeQuery();
+ while (rs.next())
+ {
+ IDatabaseObjectInfo si = new DatabaseObjectInfo(catalogName,
+ schemaName, rs.getString(1),
+ DatabaseObjectType.UDF, md);
+ if(filterMatcher.matches(si.getSimpleName()))
+ {
+ childNodes.add(new ObjectTreeNode(session, si));
+ }
+ }
+ }
+ finally
+ {
+ SQLUtilities.closeResultSet(rs);
+ SQLUtilities.closeStatement(pstmt);
+ }
+ return childNodes;
+ }
+}
Copied: trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/IndexDetailsTab.java (from rev 5805, trunk/sql12/plugins/db2/src/net/sourceforge/squirrel_sql/plugins/db2/tab/IndexDetailsTab.java)
===================================================================
--- trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/IndexDetailsTab.java (rev 0)
+++ trunk/sql12/plugins/db2/src/main/java/net/sourceforge/squirrel_sql/plugins/db2/tab/IndexDetailsTab.java 2010-08-21 17:37:29 UTC (rev 5810)
@@ -0,0 +1,160 @@
+package net.sourceforge.squirrel_sql.plugins.db2.tab;
+/*
+ * Copyright (C) 2007 Rob Manning
+ * man...@us...
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BasePreparedStatementTab;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+/**
+ * This class will display the details for an DB2 index.
+ *
+ */
+public class IndexDetailsTab extends BasePreparedStatementTab
+{
+ /** i18N strings for this class */
+ private static final StringManager s_stringMgr =
+ StringManagerFactory.getStringManager(IndexDetailsTab.class);
+
+ /** boolean to indicate whether or not this session is OS/400 */
+ private boolean isOS400 = false;
+
+ /**
+ * This interface defines locale specific strings. This should be
+ * replaced with a property file.
+ */
+ private interface i18n
+ {
+ // i18n[IndexDetailsTab.title=Details]
+ String TITLE = s_stringMgr.getString("IndexDetailsTab.title");
+ // i18n[IndexDetailsTab.hint=Display index details]
+ String HINT = s_stringMgr.getString("IndexDetailsTab.hint");
+ }
+
+ /** SQL that retrieves the data. */
+ private static final String SQL =
+ "SELECT T1.IID as index_identifier, " +
+ " T1.DEFINER AS index_owner, " +
+ " T1.INDNAME AS index_name, " +
+ " T2.DEFINER AS table_owner, " +
+ " T2.TABNAME AS table_name, " +
+ " T3.TBSPACE AS table_space, " +
+ " case T1.INDEXTYPE " +
+ " when 'BLOK' then 'Block Index' " +
+ " when 'CLUS' then 'Clustering Index' " +
+ " when 'DIM' then 'Dimension Block Index' " +
+ " when 'REG' then 'Regular Index' " +
+ " when 'XPTH' then 'XML Path Index' " +
+ " when 'XRGN' then 'XML Region Index' " +
+ " when 'XVIL' then 'Index over XML column (Logical)' " +
+ " when 'XVIP' then 'Index over XML column (Physical)' " +
+ " end AS index_type, " +
+ " case T1.UNIQUERULE " +
+ " when 'U' then 'UNIQUE' " +
+ " when 'D' then 'NON-UNIQUE' " +
+ " when 'I' then 'UNIQUE (Implements PK)' " +
+ " end AS uniqueness, " +
+ " T1.NLEAF AS number_of_leaf_pages, " +
+ " T1.NLEVELS AS number_of_levels, " +
+ " T1.CREATE_TIME, " +
+ " T1.STATS_TIME AS last_statistics_update, " +
+ " case T1.REVERSE_SCANS " +
+ " when 'Y' then 'Supported' " +
+ " when 'N' then 'Not Supported' " +
+ " end AS reverse_scans " +
+ "FROM SYSCAT.INDEXES AS T1, " +
+ " SYSCAT.TABLES AS T2, " +
+ " SYSCAT.TABLESPACES as T3 " +
+ "WHERE T3.TBSPACEID = T1.TBSPACEID " +
+ "and T2.TABNAME = T1.TABNAME " +
+ "and T2.TABSCHEMA = T1.TABSCHEMA " +
+ "AND T1.TABSCHEMA = ? " +
+ "AND T1.INDNAME = ? ";
+
+ /** SQL that retrieves the data on OS/400 */
+ private static String OS_400_SQL =
+ "select index_owner, " +
+ "index_name, " +
+ "index_schema, " +
+ "table_owner, " +
+ "table_name, " +
+ "table_schema, " +
+ "case is_unique " +
+ " when 'D' then 'No (duplicates are allowed)' " +
+ " when 'V' then 'Yes (duplicate NULL values are allowed)' " +
+ " when 'U' then 'Yes' " +
+ " when 'E' then 'Encoded vector index' " +
+ "end as uniqueness, " +
+ "column_count, " +
+ "system_index_name, " +
+ "system_index_schema, " +
+ "system_table_name, " +
+ "system_table_schema, " +
+ "long_comment, " +
+ "iasp_number, " +
+ "index_text, " +
+ "is_spanning_index " +
+ "from qsys2.sysindexes " +
+ "where table_schema = ? " +
+ "and index_name = ? ";
+
+ /** Logger for this class. */
+ private final static ILogger s_log =
+ LoggerController.createLogger(IndexDetailsTab.class);
+
+ /**
+ * Constructor
+ *
+ * @param isOS400 whether or not we are connected to an OS/400 system
+ */
+ public IndexDetailsTab(boolean isOS400)
+ {
+ super(i18n.TITLE, i18n.HINT, true);
+ this.isOS400 = isOS400;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BasePreparedStatementTab#createStatement()
+ */
+ @Override
+ protected PreparedStatement createStatement() throws SQLException
+ {
+ ISession session = getSession();
+ IDatabaseObjectInfo doi = getDatabaseObjectInfo();
+ String sql = SQL;
+ if (isOS400) {
+ sql = OS_400...
[truncated message content] |