コード例 #1
0
  public static void fillCatalogAndSchemas(
      IMetadataConnection iMetadataConnection, DatabaseConnection temConnection)
      throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
    java.sql.Connection sqlConn = null;
    try {
      MetadataFillFactory dbInstance = MetadataFillFactory.getDBInstance(iMetadataConnection);
      temConnection =
          (DatabaseConnection) dbInstance.fillUIConnParams(iMetadataConnection, temConnection);
      sqlConn = MetadataConnectionUtils.createConnection(iMetadataConnection).getObject();
      // because there is no any structure after import into 423 from 402,just sychronized the two
      // connection's
      // UISchema for fill catalogs and scheams
      if (((DatabaseConnection) iMetadataConnection.getCurrentConnection()).getUiSchema() != null) {
        temConnection.setUiSchema(
            ((DatabaseConnection) iMetadataConnection.getCurrentConnection()).getUiSchema());
      }

      if (((DatabaseConnection) iMetadataConnection.getCurrentConnection()).getSID() != null) {
        temConnection.setSID(
            ((DatabaseConnection) iMetadataConnection.getCurrentConnection()).getSID());
      }

      String dbType = iMetadataConnection.getDbType();
      if (sqlConn != null) {
        DatabaseMetaData dbMetaData = null;
        // Added by Marvin Wang on Mar. 13, 2013 for loading hive jars dynamically, refer to
        // TDI-25072.
        if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
          dbMetaData =
              HiveConnectionManager.getInstance().extractDatabaseMetaData(iMetadataConnection);
        } else {
          dbMetaData =
              ExtractMetaDataUtils.getInstance()
                  .getDatabaseMetaData(sqlConn, dbType, false, iMetadataConnection.getDatabase());
        }
        dbInstance.fillCatalogs(
            temConnection,
            dbMetaData,
            iMetadataConnection,
            MetadataConnectionUtils.getPackageFilter(temConnection, dbMetaData, true));

        dbInstance.fillSchemas(
            temConnection,
            dbMetaData,
            iMetadataConnection,
            MetadataConnectionUtils.getPackageFilter(temConnection, dbMetaData, false));
      }
    } catch (SQLException e) {
      throw e;
    } finally {
      if (sqlConn != null) {
        ConnectionUtils.closeConnection(sqlConn);
      }
      MetadataConnectionUtils.closeDerbyDriver();
    }
  }
コード例 #2
0
 private boolean setJDBCMysqlConnection(DatabaseConnection dbProvider) {
   // General JDBC case
   dbProvider.setComment(""); // $NON-NLS-1$
   dbProvider.setSID(""); // $NON-NLS-1$
   dbProvider.setDatasourceName(""); // $NON-NLS-1$
   dbProvider.setDatabaseType("General JDBC"); // $NON-NLS-1$
   dbProvider.setDriverJarPath(
       "E:\\tools\\jdbc\\mysql-connector-java-5.1.12-bin.jar"); //$NON-NLS-1$
   dbProvider.setDbVersionString(""); // $NON-NLS-1$
   dbProvider.setDriverClass("org.gjt.mm.mysql.Driver"); // $NON-NLS-1$
   dbProvider.setFileFieldName(""); // $NON-NLS-1$
   dbProvider.setId("_9bw28cccEeGQNaw_qcyMFw"); // $NON-NLS-1$
   dbProvider.setLabel("jdbcmysql1"); // $NON-NLS-1$
   dbProvider.setNullChar(""); // $NON-NLS-1$
   dbProvider.setRawPassword("shenze"); // $NON-NLS-1$
   dbProvider.setPort("3306"); // $NON-NLS-1$
   dbProvider.setServerName(""); // $NON-NLS-1$
   dbProvider.setSqlSynthax("SQL Syntax"); // $NON-NLS-1$
   dbProvider.setUiSchema(""); // $NON-NLS-1$
   dbProvider.setStringQuote(""); // $NON-NLS-1$
   dbProvider.setURL("jdbc:mysql://192.168.30.151:3306/?noDatetimeStringSync=true"); // $NON-NLS-1$
   dbProvider.setAdditionalParams(""); // $NON-NLS-1$
   dbProvider.setUsername("shenze"); // $NON-NLS-1$
   dbProvider.setDbmsId("mysql_id"); // $NON-NLS-1$
   dbProvider.setProductId("JDBC"); // $NON-NLS-1$
   dbProvider.setDBRootPath(""); // $NON-NLS-1$
   dbProvider.setSQLMode(false);
   dbProvider.setContextMode(false);
   dbProvider.setContextId(""); // $NON-NLS-1$
   dbProvider.setContextName(""); // $NON-NLS-1$
   ConnectionHelper.setPurpose("my test purpose", dbProvider); // $NON-NLS-1$
   ConnectionHelper.setDescription("my test description", dbProvider); // $NON-NLS-1$
   ConnectionHelper.setAuthor("*****@*****.**", dbProvider); // $NON-NLS-1$
   ConnectionHelper.setDevStatus("DEV", dbProvider); // $NON-NLS-1$
   ConnectionHelper.setVersion("1.1", dbProvider); // $NON-NLS-1$
   ConnectionHelper.setUniverse("", dbProvider); // $NON-NLS-1$
   return true;
 }