首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SchemaCrawler获取存储过程

使用SchemaCrawler获取存储过程
EN

Stack Overflow用户
提问于 2015-08-17 18:29:27
回答 1查看 723关注 0票数 0

当我试图使用Server从Server数据库检索存储过程时,会得到以下错误:

代码语言:javascript
复制
12:28:07.427 [main] INFO  schemacrawler.crawl.SchemaCrawler - Retrieving routines
12:28:07.767 [main] WARN  schemacrawler.crawl.RoutineRetriever - JDBC driver does not support retrieving functions
java.lang.AbstractMethodError: null
    at net.sourceforge.jtds.jdbc.JtdsDatabaseMetaData.getFunctions(JtdsDatabaseMetaData.java:3570) ~[jtds-1.3.1.jar:1.3.1]
    at schemacrawler.crawl.RoutineRetriever.retrieveFunctions(RoutineRetriever.java:175) ~[schemacrawler-14.02.02.jar:na]
    at schemacrawler.crawl.SchemaCrawler.crawlRoutines(SchemaCrawler.java:214) [schemacrawler-14.02.02.jar:na]
    at schemacrawler.crawl.SchemaCrawler.crawl(SchemaCrawler.java:564) [schemacrawler-14.02.02.jar:na]
    at schemacrawler.utility.SchemaCrawlerUtility.getCatalog(SchemaCrawlerUtility.java:49) [schemacrawler-14.02.02.jar:na]
    at schemacrawler.utility.SchemaCrawlerUtility.getCatalog(SchemaCrawlerUtility.java:57) [schemacrawler-14.02.02.jar:na]
    at com.expedia.cgs.db.ExportScripts.main(ExportScripts.java:41) [classes/:na]

jtds驱动程序支持DatabaseMetaData.getProcedures(),但不支持DatabaseMetaData.getFunctions()。有解决办法吗?

更新:这是我的代码:

代码语言:javascript
复制
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.slf4j.bridge.SLF4JBridgeHandler;
import schemacrawler.schema.Catalog;
import schemacrawler.schema.Column;
import schemacrawler.schema.Routine;
import schemacrawler.schema.Schema;
import schemacrawler.schema.Table;
import schemacrawler.schema.View;
import schemacrawler.schemacrawler.DatabaseConnectionOptions;
import schemacrawler.schemacrawler.RegularExpressionInclusionRule;
import schemacrawler.schemacrawler.SchemaCrawlerException;
import schemacrawler.schemacrawler.SchemaCrawlerOptions;
import schemacrawler.schemacrawler.SchemaInfoLevelBuilder;
import schemacrawler.utility.SchemaCrawlerUtility;

public class ExportScripts {

    public static void main(String[] args) throws SchemaCrawlerException, SQLException {
        SLF4JBridgeHandler.removeHandlersForRootLogger();
        SLF4JBridgeHandler.install();

        // Create a database connection
        final DataSource dataSource = new DatabaseConnectionOptions("jdbc:sqlserver://myDatabase;appName=SchemaCrawler;useCursors=true");
        final Connection connection = dataSource.getConnection("username", "password");

        // Create the options
        final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
        // Set what details are required in the schema - this affects the
        // time taken to crawl the schema
        options.setSchemaInfoLevel(SchemaInfoLevelBuilder.standard());
        options.setRoutineInclusionRule(new RegularExpressionInclusionRule("ContentGeneration\\.dbo.*"));
        options.setSchemaInclusionRule(new RegularExpressionInclusionRule("ContentGeneration\\.dbo.*"));

        // Get the schema definition
        final Catalog catalog = SchemaCrawlerUtility.getCatalog(connection,
                options);

        for (final Schema schema : catalog.getSchemas()) {
            System.out.println(schema);
            for (final Routine routine : catalog.getRoutines()) {
                System.out.println("r--> " + routine);
                System.out.println("definition: " + routine.getDefinition());
            }
            for (final Table table : catalog.getTables(schema)) {
                System.out.print("o--> " + table);
                if (table instanceof View) {
                    System.out.println(" (VIEW)");
                } else {
                    System.out.println();
                }

                for (final Column column : table.getColumns()) {
                    System.out.println("     o--> " + column + " ("
                            + column.getColumnDataType() + ")");
                }
            }
        }
    }
}
EN

回答 1

Stack Overflow用户

发布于 2015-08-18 00:37:41

下面是如何获得对Microsoft的完全SchemaCrawler支持。

  1. 在您的SchemaCrawler项目中包括具有Microsoft支持的Maven jar。

<dependency> <groupId>us.fatehi</groupId> <artifactId>schemacrawler-sqlserver</artifactId> <version>14.02.02</version> </dependency>

  1. 使用下面类似的代码。 final DatabaseSystemConnector dbSystemConnector = new dbSystemConnector 最终dbSystemConnector.getDatabaseSpecificOverrideOptionsBuilder().toOptions();DatabaseSpecificOverrideOptions databaseSpecificOverrideOptions = schemaCrawlerOptions.setSchemaInfoLevel(InfoLevel.maximum.buildSchemaInfoLevel());SchemaCrawlerOptions schemaCrawlerOptions =新的SchemaCrawlerOptions() 最后目录目录= SchemaCrawlerUtility.getCatalog(getConnection(),databaseSpecificOverrideOptions,schemaCrawlerOptions);
  2. 循环这些例程,并使用Routine.getDefinition()获得定义。

Sualeh Fatehi,SchemaCrawler

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32057277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档