Revision: 6389
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6389&view=rev
Author: manningr
Date: 2011-09-04 21:21:25 +0000 (Sun, 04 Sep 2011)
Log Message:
-----------
New external tests for various dialects.
Modified Paths:
--------------
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DbCopyCliExternalIntegrationTest.java
Added Paths:
-----------
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/NonClosingConnection.java
trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionConnectionProvider.java
Modified: trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DbCopyCliExternalIntegrationTest.java
===================================================================
--- trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DbCopyCliExternalIntegrationTest.java 2011-09-04 10:08:26 UTC (rev 6388)
+++ trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/DbCopyCliExternalIntegrationTest.java 2011-09-04 21:21:25 UTC (rev 6389)
@@ -1,214 +1,592 @@
+/*
+ * Copyright (C) 2011 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.dbcopy.cli;
-import org.junit.After;
-import org.junit.Before;
+import java.io.File;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Properties;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.AliasNames;
+import net.sourceforge.squirrel_sql.fw.dialects.DialectFactory;
+import net.sourceforge.squirrel_sql.fw.sql.IQueryTokenizer;
+import net.sourceforge.squirrel_sql.fw.sql.SQLUtilities;
+import net.sourceforge.squirrel_sql.fw.util.IOUtilities;
+import net.sourceforge.squirrel_sql.fw.util.IOUtilitiesImpl;
+import net.sourceforge.squirrel_sql.plugins.db2.DB2JCCExceptionFormatter;
+
import org.junit.Test;
+import pl.kernelpanic.dbmonster.DBMonster;
+import pl.kernelpanic.dbmonster.ProgressMonitorAdapter;
+import pl.kernelpanic.dbmonster.schema.Schema;
+import pl.kernelpanic.dbmonster.schema.SchemaUtil;
+
/**
- * Tests copying tables from one type of database to another. The ALIAS_NAME constants below must be defined
+ * Tests copying tables from one type of database to another. The ALIAS_NAME constants below must be defined
* in ~/.squirrel-sql/SQLAliases23.xml for this test to work properly.
*/
public class DbCopyCliExternalIntegrationTest
{
- private static String DB2_DEST_ALIAS_NAME = "DB2 (DBCPDST)";
+
+ private static String TABLE_LIST_UPPER =
+ "BIGINT_TYPE_TABLE,BINARY_TYPE_TABLE,BIT_TYPE_TABLE,BLOB_TYPE_TABLE,BOOLEAN_TYPE_TABLE,"
+ + "CHAR_TYPE_TABLE,CLOB_TYPE_TABLE,DATE_TYPE_TABLE,DECIMAL_TYPE_TABLE,DOUBLE_TYPE_TABLE,"
+ + "FLOAT_TYPE_TABLE,INTEGER_TYPE_TABLE,LONGVARBINARY_TYPE_TABLE,LONGVARCHAR_TYPE_TABLE,"
+ + "NUMERIC_TYPE_TABLE,REAL_TYPE_TABLE,SMALLINT_TYPE_TABLE,TIME_TYPE_TABLE,TIMESTAMP_TYPE_TABLE,"
+ + "TINYINT_TYPE_TABLE,VARBINARY_TYPE_TABLE,VARCHAR_TYPE_TABLE";
+
+ private static String TABLE_LIST_LOWER = TABLE_LIST_UPPER.toLowerCase();
+
+ private SessionUtil sessionUtil = new SessionUtil();
+
+ private DBCopyRunner runner = new DBCopyRunner();
- private static String DB2_SOURCE_ALIAS_NAME = "DB2 (DBCPSRC)";
+ private IOUtilities ioutils = new IOUtilitiesImpl();
+
+ @Test
+ public void testDerbyToDb2() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DB2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "DBCPDST", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testDerbyToDerby() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "APP", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testDerbyToFirebird() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FIREBIRD_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "APP", TABLE_LIST_UPPER);
+ }
- private static String DERBY_DEST_ALIAS_NAME = "Derby (dbcopydest)";
+ @Test
+ public void testDerbyToFrontbase() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FRONTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "DBCOPY", TABLE_LIST_UPPER);
+ }
- private static String DERBY_SOURCE_ALIAS_NAME = "Derby (dbcopysrc)";
+ @Test
+ public void testDerbyToH2() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.H2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "PUBLIC", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testDerbyToInformix() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.INFORMIX_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, "ansidb", "informix", TABLE_LIST_UPPER);
+ }
- private static String FIREBIRD_DEST_ALIAS_NAME = "Firebird (dbcopydest)";
+ @Test
+ public void testDerbyToMysql4() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.MYSQL4_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "dbcopydest", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testDerbyToMysql5() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.MYSQL5_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "dbcopydest", TABLE_LIST_UPPER);
+ }
- private static String FRONTBASE_DEST_ALIAS_NAME = "Frontbase (dbcopydest)";
+ @Test
+ public void testDerbyToOracle() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "DBCOPYDEST", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testDerbyToPointbase() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "DBCOPY", TABLE_LIST_UPPER);
+ }
- private static String H2_SOURCE_ALIAS_NAME = "H2 (dbcopysrc)";
+ @Test
+ public void testDerbyToPostgreSQL() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POSTGRES_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, null, destSession, null, "public", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testMysql4ToDb2() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.MYSQL4_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DB2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, "dbcopysrc", null, destSession, null, "DBCPDST", TABLE_LIST_LOWER);
+ }
+
- private static String H2_DEST_ALIAS_NAME = "H2 (dbcopydest)";
+ // This test is currently broken because DB2 doesn't allow null clob column values for
+ // table with just one column.
+ @Test
+ public void testHsqldbToDb2() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.HSQLDB_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DB2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, "PUBLIC", "PUBLIC", destSession, null, "DBCPDST", TABLE_LIST_UPPER);
+ }
- private static String INFORMIX_DEST_ALIAS_NAME = "Informix (demo_on)";
- private static String HSQLDB_DEST_ALIAS_NAME = "HSQLDB (dbcopydest)";
-
- private static String MYSQL4_DEST_ALIAS_NAME = "MySQL 4 (dbcopydest)";
-
- private static String MYSQL4_SOURCE_ALIAS_NAME = "MySQL 4 (dbcopysrc)";
-
- private static String MYSQL5_DEST_ALIAS_NAME = "MySQL 5 (dbcopydest)";
-
- private static String MYSQL5_SOURCE_ALIAS_NAME = "MySQL 5 (dbcopysrc)";
-
- private static String ORACLE_SOURCE_ALIAS_NAME = "Oracle (dbcopysrc)";
-
- private static String ORACLE_DEST_ALIAS_NAME = "Oracle (dbcopydest)";
+ @Test
+ public void testH2ToDb2() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DB2_DEST_ALIAS_NAME);
- private static String POSTGRES_DEST_ALIAS_NAME = "PostgreSQL";
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "DBCPDST", TABLE_LIST_UPPER);
+ }
- private static String TABLE_LIST_UPPER =
- "BIGINT_TYPE_TABLE,BINARY_TYPE_TABLE,BIT_TYPE_TABLE,BLOB_TYPE_TABLE,BOOLEAN_TYPE_TABLE,"+
- "CHAR_TYPE_TABLE,CLOB_TYPE_TABLE,DATE_TYPE_TABLE,DECIMAL_TYPE_TABLE,DOUBLE_TYPE_TABLE," +
- "FLOAT_TYPE_TABLE,INTEGER_TYPE_TABLE,LONGVARBINARY_TYPE_TABLE,LONGVARCHAR_TYPE_TABLE," +
- "NUMERIC_TYPE_TABLE,REAL_TYPE_TABLE,SMALLINT_TYPE_TABLE,TIME_TYPE_TABLE,TIMESTAMP_TYPE_TABLE," +
- "TINYINT_TYPE_TABLE,VARBINARY_TYPE_TABLE,VARCHAR_TYPE_TABLE";
+ @Test
+ public void testH2ToDerby() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "APP", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testH2ToFirebird() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FIREBIRD_DEST_ALIAS_NAME);
- private static String TABLE_LIST_LOWER = TABLE_LIST_UPPER.toLowerCase();
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "", TABLE_LIST_UPPER);
+ }
+ @Test
+ public void testH2ToFrontbase() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FRONTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "DBCOPY", TABLE_LIST_UPPER);
+ }
@Test
- public void testH2ToDb2() throws Exception
+ public void testH2ToH2() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", H2_SOURCE_ALIAS_NAME,
- "--dest-alias", DB2_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "DBCPDST",
- "--source-schema", "PUBLIC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.H2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "PUBLIC", TABLE_LIST_UPPER);
}
+
+ @Test
+ public void testH2ToInformix() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.INFORMIX_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, "ansidb", "informix", TABLE_LIST_UPPER);
+ }
@Test
+ public void testH2ToMysql4() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.MYSQL4_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "dbcopydest", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testH2ToMysql5() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.MYSQL5_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "dbcopydest", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testH2ToOracle() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "DBCOPYDEST", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testH2ToPointbase() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "DBCOPY", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testH2ToPostgreSQL() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.H2_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POSTGRES_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "PUBLIC", destSession, null, "public", TABLE_LIST_UPPER);
+ }
+
+ @Test
public void testOracleToDb2() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", DB2_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "DBCPDST",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DB2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "DBCPDST", TABLE_LIST_UPPER);
}
@Test
public void testOracleToDerby() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", DERBY_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "APP",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "APP", TABLE_LIST_UPPER);
}
@Test
public void testOracleToFirebird() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", FIREBIRD_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FIREBIRD_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "", TABLE_LIST_UPPER);
}
-
+
@Test
public void testOracleToFrontbase() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", FRONTBASE_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "DBCOPY",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FRONTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "DBCOPY", TABLE_LIST_UPPER);
}
@Test
public void testOracleToH2() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", H2_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "PUBLIC",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.H2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "PUBLIC", TABLE_LIST_UPPER);
}
@Test
public void testOracleToHSQLDB() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", HSQLDB_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "PUBLIC",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.HSQLDB_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "PUBLIC", TABLE_LIST_UPPER);
}
@Test
public void testOracleToInformix() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", INFORMIX_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "informix",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.INFORMIX_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "informix", TABLE_LIST_UPPER);
}
-
+
@Test
public void testOracleToMySQL4() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", MYSQL4_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-catalog", "dbcopydest",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.INFORMIX_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, "dbcopydest", null, TABLE_LIST_UPPER);
}
@Test
public void testOracleToMySQL5() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", MYSQL5_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-catalog", "dbcopydest",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.MYSQL5_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, "dbcopydest", null, TABLE_LIST_UPPER);
}
-
+
@Test
public void testOracleToOracle() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", ORACLE_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "DBCOPYDEST",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
- }
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "DBCOPYDEST", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testOracleToPointbase() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "DBCOPY", TABLE_LIST_UPPER);
+ }
@Test
public void testOracleToPostgreSQL() throws Exception
{
- String[] args =
- new String[] {
- "--source-alias", ORACLE_SOURCE_ALIAS_NAME,
- "--dest-alias", POSTGRES_DEST_ALIAS_NAME,
- "--table-list", TABLE_LIST_UPPER,
- "--dest-schema", "public",
- "--source-schema", "DBCOPYSRC" };
- DBCopyCLI.main(args);
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POSTGRES_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPYSRC", destSession, null, "public", TABLE_LIST_UPPER);
}
+ @Test
+ public void testPointbaseToDerby() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_DEST_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DERBY_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "APP", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToDB2() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_DEST_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.DB2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "DBCPDST", TABLE_LIST_UPPER);
+ }
+ @Test
+ public void testPointbaseToFirebird() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FIREBIRD_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToFrontbase() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.FRONTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "DBCOPY", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToH2() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.H2_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "PUBLIC", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToHSQLDB() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.HSQLDB_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "PUBLIC", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToInformix() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.INFORMIX_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "informix", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToMySQL4() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.INFORMIX_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, "dbcopydest", null, TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToMySQL5() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.MYSQL5_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, "dbcopydest", null, TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToOracle() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.ORACLE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "DBCOPYDEST", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToPointbase() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "DBCOPY", TABLE_LIST_UPPER);
+ }
+
+ @Test
+ public void testPointbaseToPostgreSQL() throws Exception
+ {
+ ISession sourceSession = sessionUtil.getSessionForAlias(AliasNames.POINTBASE_SOURCE_ALIAS_NAME);
+ ISession destSession = sessionUtil.getSessionForAlias(AliasNames.POSTGRES_DEST_ALIAS_NAME);
+
+ testCopy(sourceSession, null, "DBCOPY", destSession, null, "public", TABLE_LIST_UPPER);
+ }
+
+
+
+ private String concat(List<String> lines) {
+ StringBuilder result = new StringBuilder();
+ for (String line : lines) {
+ result.append(line);
+ result.append("\n");
+ }
+ return result.toString();
+ }
+
+ private void executeScript(ISession session, String scriptFilename) throws Exception {
+ IQueryTokenizer tokenizer = session.getQueryTokenizer();
+ List<String> lines = ioutils.getLinesFromFile(scriptFilename, null);
+ tokenizer.setScriptToTokenize(concat(lines));
+ while (tokenizer.hasQuery()) {
+ String sql = tokenizer.nextQuery();
+ System.out.println("Running SQL ("+scriptFilename+"): "+sql);
+
+ Statement stmt = null;
+ try {
+ stmt = session.getSQLConnection().createStatement();
+ stmt.execute(sql);
+ } catch (SQLException e) {
+ System.err.println("Exception: "+e.getMessage());
+ } finally {
+ SQLUtilities.closeStatement(stmt);
+ }
+ }
+
+ }
+
+ private void runDBMonsterOnSourceSession(ISession sourceSession, String dbschema, String schemaXmlFile) throws Exception {
+ SessionConnectionProvider connProvider = new SessionConnectionProvider(sourceSession);
+ DBMonster dbm = new DBMonster();
+ Properties props = new Properties();
+ if (dbschema != null) {
+ props.setProperty("dbmonster.jdbc.schema", dbschema);
+ }
+ dbm.setProperties(props);
+ dbm.setProgressMonitor(new ProgressMonitorAdapter());
+ dbm.setConnectionProvider(connProvider);
+ Schema schema = SchemaUtil.loadSchema(schemaXmlFile, dbm.getLogger());
+ dbm.addSchema(schema);
+ System.out.println("Running DBMonster on source session using schema file: "+schemaXmlFile);
+ dbm.doTheJob();
+ }
+
+ private void testCopy(ISession sourceSession, String sourceCatalog, String sourceSchema, ISession destSession, String destCatalog, String destSchema, String tableListStr) throws Exception {
+ String sourceTestDataFolder =
+ DialectFactory.getDialect(sourceSession.getMetaData()).getDisplayName().toLowerCase();
+ String destTestDataFolder =
+ DialectFactory.getDialect(destSession.getMetaData()).getDisplayName().toLowerCase();
+
+
+ // run drop script on both the source and destination databases. If the testDataFolder associated with
+ // the session has a drop.sql script, use that one instead of the generic one.
+ if ((new File("src/test/resources/sql/"+sourceTestDataFolder+"/drop.sql")).exists()) {
+ executeScript(sourceSession, "src/test/resources/sql/"+sourceTestDataFolder+"/drop.sql");
+ } else {
+ executeScript(sourceSession, "src/test/resources/sql/generic/drop.sql");
+ }
+
+ if ((new File("src/test/resources/sql/"+destTestDataFolder+"/drop.sql")).exists()) {
+ executeScript(destSession, "src/test/resources/sql/"+destTestDataFolder+"/drop.sql");
+ } else {
+ executeScript(destSession, "src/test/resources/sql/generic/drop.sql");
+ }
+
+ // run the all types sql script on sourceSession
+ executeScript(sourceSession, "src/test/resources/sql/"+sourceTestDataFolder+"/all_types.sql");
+
+ // run dbmonster using oracle session as a ConnectionProvider.
+ runDBMonsterOnSourceSession(sourceSession, sourceSchema, "src/test/resources/sql/"+sourceTestDataFolder+"/test.xml");
+
+ runner.setSourceSession(sourceSession);
+ runner.setSourceCatalogName(sourceCatalog);
+ runner.setSourceSchemaName(sourceSchema);
+ runner.setDestCatalogName(destCatalog);
+ runner.setDestSession(destSession);
+ runner.setDestSchemaName(destSchema);
+ runner.setTableList(tableListStr);
+ try {
+ runner.run();
+ } catch (Exception e) {
+ System.err.println((new DB2JCCExceptionFormatter()).format(e));
+ throw e;
+ }
+ }
+
}
Added: trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/NonClosingConnection.java
===================================================================
--- trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/NonClosingConnection.java (rev 0)
+++ trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/NonClosingConnection.java 2011-09-04 21:21:25 UTC (rev 6389)
@@ -0,0 +1,400 @@
+/*
+ * Copyright (C) 2011 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.dbcopy.cli;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * A simple delegator to a wrapped Connection that omits any call to close. This is
+ * necessary as we want to re-use the Connection in a Session for DBMonster, yet DBMonster
+ * wants to close the Connection when it is finished with it.
+ */
+public class NonClosingConnection implements Connection
+{
+ private Connection con = null;
+
+ public NonClosingConnection(Connection con) {
+ this.con = con;
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException
+ {
+ con.clearWarnings();
+
+ }
+
+ @Override
+ public void close() throws SQLException
+ {
+// Thread.dumpStack();
+ }
+
+ @Override
+ public void commit() throws SQLException
+ {
+ con.commit();
+
+ }
+
+ @Override
+ public Array createArrayOf(String typeName, Object[] elements) throws SQLException
+ {
+
+ return con.createArrayOf(typeName, elements);
+ }
+
+ @Override
+ public Blob createBlob() throws SQLException
+ {
+
+ return con.createBlob();
+ }
+
+ @Override
+ public Clob createClob() throws SQLException
+ {
+
+ return con.createClob();
+ }
+
+ @Override
+ public NClob createNClob() throws SQLException
+ {
+
+ return con.createNClob();
+ }
+
+ @Override
+ public SQLXML createSQLXML() throws SQLException
+ {
+
+ return con.createSQLXML();
+ }
+
+ @Override
+ public Statement createStatement() throws SQLException
+ {
+
+ return con.createStatement();
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
+ {
+
+ return con.createStatement(resultSetType, resultSetConcurrency);
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException
+ {
+
+ return con.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+
+ @Override
+ public Struct createStruct(String typeName, Object[] attributes) throws SQLException
+ {
+
+ return con.createStruct(typeName, attributes);
+ }
+
+ @Override
+ public boolean getAutoCommit() throws SQLException
+ {
+
+ return con.getAutoCommit();
+ }
+
+ @Override
+ public String getCatalog() throws SQLException
+ {
+
+ return con.getCatalog();
+ }
+
+ @Override
+ public Properties getClientInfo() throws SQLException
+ {
+
+ return con.getClientInfo();
+ }
+
+ @Override
+ public String getClientInfo(String name) throws SQLException
+ {
+
+ return con.getClientInfo(name);
+ }
+
+ @Override
+ public int getHoldability() throws SQLException
+ {
+
+ return con.getHoldability();
+ }
+
+ @Override
+ public DatabaseMetaData getMetaData() throws SQLException
+ {
+
+ return con.getMetaData();
+ }
+
+ @Override
+ public int getTransactionIsolation() throws SQLException
+ {
+
+ return con.getTransactionIsolation();
+ }
+
+ @Override
+ public Map<String, Class<?>> getTypeMap() throws SQLException
+ {
+
+ return con.getTypeMap();
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException
+ {
+
+ return con.getWarnings();
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException
+ {
+
+ return con.isClosed();
+ }
+
+ @Override
+ public boolean isReadOnly() throws SQLException
+ {
+
+ return con.isReadOnly();
+ }
+
+ @Override
+ public boolean isValid(int timeout) throws SQLException
+ {
+
+ return con.isValid(timeout);
+ }
+
+ @Override
+ public String nativeSQL(String sql) throws SQLException
+ {
+
+ return con.nativeSQL(sql);
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql) throws SQLException
+ {
+
+ return con.prepareCall(sql);
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+
+ return con.prepareCall(sql, resultSetType, resultSetConcurrency);
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+
+ return con.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql) throws SQLException
+ {
+
+ return con.prepareStatement(sql);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
+ {
+
+ return con.prepareStatement(sql, autoGeneratedKeys);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
+ {
+
+ return con.prepareStatement(sql, columnIndexes);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
+ {
+
+ return con.prepareStatement(sql, columnNames);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+
+ return con.prepareStatement(sql, resultSetType, resultSetConcurrency);
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+
+ return con.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+
+ @Override
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException
+ {
+ con.releaseSavepoint(savepoint);
+
+ }
+
+ @Override
+ public void rollback() throws SQLException
+ {
+ con.rollback();
+
+ }
+
+ @Override
+ public void rollback(Savepoint savepoint) throws SQLException
+ {
+ con.rollback(savepoint);
+
+ }
+
+ @Override
+ public void setAutoCommit(boolean autoCommit) throws SQLException
+ {
+ con.setAutoCommit(autoCommit);
+
+ }
+
+ @Override
+ public void setCatalog(String catalog) throws SQLException
+ {
+ con.setCatalog(catalog);
+
+ }
+
+ @Override
+ public void setClientInfo(Properties properties) throws SQLClientInfoException
+ {
+
+ con.setClientInfo(properties);
+ }
+
+ @Override
+ public void setClientInfo(String name, String value) throws SQLClientInfoException
+ {
+ con.setClientInfo(name, value);
+
+ }
+
+ @Override
+ public void setHoldability(int holdability) throws SQLException
+ {
+ con.setHoldability(holdability);
+
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) throws SQLException
+ {
+ con.setReadOnly(readOnly);
+
+ }
+
+ @Override
+ public Savepoint setSavepoint() throws SQLException
+ {
+
+ return con.setSavepoint();
+ }
+
+ @Override
+ public Savepoint setSavepoint(String name) throws SQLException
+ {
+ return con.setSavepoint(name);
+
+ }
+
+ @Override
+ public void setTransactionIsolation(int level) throws SQLException
+ {
+ con.setTransactionIsolation(level);
+
+ }
+
+ @Override
+ public void setTypeMap(Map<String, Class<?>> map) throws SQLException
+ {
+ con.setTypeMap(map);
+
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException
+ {
+
+ return con.isWrapperFor(iface);
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException
+ {
+
+ return con.unwrap(iface);
+ }
+
+}
Added: trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionConnectionProvider.java
===================================================================
--- trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionConnectionProvider.java (rev 0)
+++ trunk/sql12/squirrelsql-integration-environment/src/test/java/net/sourceforge/squirrel_sql/plugins/dbcopy/cli/SessionConnectionProvider.java 2011-09-04 21:21:25 UTC (rev 6389)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 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.dbcopy.cli;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+
+import pl.kernelpanic.dbmonster.connection.ConnectionProvider;
+
+public class SessionConnectionProvider implements ConnectionProvider
+{
+
+ private ISession session = null;
+
+ public SessionConnectionProvider(ISession session) {
+ this.session = session;
+ }
+
+ @Override
+ public Connection getConnection() throws SQLException
+ {
+ return new NonClosingConnection(session.getSQLConnection().getConnection());
+ }
+
+ @Override
+ public void shutdown()
+ {
+ // No - dbmonster doesn't get this privilege during a test.
+ }
+
+ @Override
+ public void testConnection() throws SQLException
+ {
+ // Assume the connection is fine.
+ }
+
+ @Override
+ public void setAutoCommit(boolean autoCommit)
+ {
+ // Don't mess with auto commit
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|