API OutputOptions

Anonymous
2012-02-23
2012-09-09

  • Anonymous
    2012-02-23

    Hi,

    I`m trying to use SchemaCrawler inside a servlet, and whant to get a database
    Schema in JSON format. but the only way I can find is to output to a file, any
    way I can output to any Stream ?

    I'm doing something like this:

                           dataSource = new DatabaseConnectionOptions(driverClassName, uri);
    
                final Connection connection = dataSource.getConnection(login, password);
    
                // Create the options
                final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
                // Set what details are required in the schema 
                options.setSchemaInfoLevel(SchemaInfoLevel.minimum() );
                // Sorting options
                options.setAlphabeticalSortForTableColumns(true); 
                final Database database = SchemaCrawlerUtility.getDatabase(connection,options);
    
                schemacrawler.tools.text.schema.SchemaTextExecutable  st = new schemacrawler.tools.text.schema.SchemaTextExecutable("dump");
    
                OutputOptions outputOptions = new OutputOptions();
                outputOptions.setOutputFileName(FILENAME);
                outputOptions.setOutputFormatValue("json");
                st.setOutputOptions(outputOptions);
    
                st.setSchemaCrawlerOptions(options);
    
                st.execute(connection);
    

    Any help will be appreciated.

     
  • Sualeh Fatehi
    Sualeh Fatehi
    2012-02-24

    Not right now, but I can quickly add that feature in for you.

     
  • Sualeh Fatehi
    Sualeh Fatehi
    2012-02-25

    I have released version 8.12, which contains a feature to allow you to stream
    output. You can do:

    outputOptions.setWriter(writer);