Package sqlline

Class Application


  • public class Application
    extends java.lang.Object
    Defines the configuration of a SQLLine application.

    This class can be extended to allow customizations for: known drivers, output formats, commands, information message, session options, prompt handler.

    You can pass the name of the sub-class to SQLLine via the -ac command-line parameter or !appconfig command.

    Use !appconfig sqlline.Application to reset SQLLine application configuration to default at runtime.

    • Field Detail

      • DEFAULT_APP_INFO_MESSAGE

        public static final java.lang.String DEFAULT_APP_INFO_MESSAGE
        See Also:
        Constant Field Values
    • Constructor Detail

      • Application

        public Application()
        Creates an Application.
    • Method Detail

      • getInfoMessage

        public java.lang.String getInfoMessage()
        Returns the information message, by default "sqlline version x.x".

        Override this method to return a custom information message.

        Returns:
        custom information message
        See Also:
        DEFAULT_APP_INFO_MESSAGE
      • getVersion

        public java.lang.String getVersion()
      • initDrivers

        @Deprecated
        public java.util.Collection<java.lang.String> initDrivers()
        Deprecated.
        Deprecated, now that drivers are loaded using ServiceLoader and META-INF/services/java.sql.Driver; use allowedDrivers() instead.
        Returns:
        Collection of known drivers
      • allowedDrivers

        public java.util.List<java.lang.String> allowedDrivers()
        Returns the list of the class names of allowed JDBC drivers.

        The default implementation returns null, which means there are no restrictions, and SQLLine will use all drivers on the class path.

        Override this method to modify list of allowed drivers.

        Returns:
        List of allowed drivers, null if any is allowed
      • getOutputFormats

        public java.util.Map<java.lang.String,​OutputFormat> getOutputFormats​(SqlLine sqlLine)
        Override this method to modify known output formats implementations.

        If method is not overridden, current state of formats will be reset to default (super.getOutputFormats(sqlLine)).

        To update / leave current state, override this method and use sqlLine.getOutputFormats().

        When overriding output formats outputformat command should be re-initialized unless default commands handlers are used.

        Parameters:
        sqlLine - SQLLine instance
        Returns:
        Map of output formats by name
      • getConnectionUrlExamples

        public java.util.Collection<java.lang.String> getConnectionUrlExamples()
        Override this method to modify connection url examples.

        When overriding connection url examples, connect / open command should be re-initialized unless default commands handlers are used.

        Returns:
        Collection of connection url examples
      • getCommandHandlers

        public java.util.Collection<CommandHandler> getCommandHandlers​(SqlLine sqlLine)
        Override this method to modify supported commands.

        If method is not overridden, current state of commands will be reset to default (super.getCommandHandlers(sqlLine)).

        To update / leave current state, override this method and use sqlLine.getCommandHandlers().

        Parameters:
        sqlLine - SQLLine instance
        Returns:
        Collection of command handlers
      • getOpts

        public SqlLineOpts getOpts​(SqlLine sqlLine)
        Override this method to modify session options.

        If method is not overridden, current state of options will be reset to default (super.getOpts(sqlLine)).

        To update / leave current state, override this method and use sqlLine.getOpts().

        Parameters:
        sqlLine - SQLLine instance
        Returns:
        SQLLine session options
      • getName2HighlightStyle

        public java.util.Map<java.lang.String,​HighlightStyle> getName2HighlightStyle()
      • getConnectInteractiveModes

        public java.util.Collection<java.lang.String> getConnectInteractiveModes()
      • getDefaultInteractiveMode

        public java.lang.String getDefaultInteractiveMode()