Package org.firebirdsql.gds.impl

## Class GDSFactory

- java.lang.Object
- - org.firebirdsql.gds.impl.GDSFactory

-     public final class GDSFactory
      extends java.lang.Object

  The class `GDSFactory` exists to provide a way to obtain objects implementing GDS and Clumplet.
  Author:
    David Jencks, Mark Rotteveel

- - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static java.lang.Class<?>` | `getConnectionClass​(GDSType gdsType)` | Get class extending the `FBConnection` that will be instantiated when new connection is created.
    `static FbDatabaseFactory` | `getDatabaseFactoryForType​(GDSType gdsType)` |
    `static java.lang.String` | `getDatabasePath​(GDSType gdsType, java.lang.String jdbcUrl)` | Get path to the database from the specified JDBC URL.
    `static java.lang.String` | `getDatabasePath​(GDSType gdsType, java.lang.String server, java.lang.Integer port, java.lang.String path)` | Get connection string for the specified server name, port and database name/path.
    `static GDSType` | `getDefaultGDSType()` | Get default GDS type.
    `static java.lang.String` | `getJdbcUrl​(GDSType gdsType, java.lang.String databasePath)` | Deprecated. Use `getJdbcUrl(GDSType, DatabaseConnectionProperties)`; will be removed in Jaybird 6
    `static java.lang.String` | `getJdbcUrl​(GDSType gdsType, DatabaseConnectionProperties dbConnectionProperties)` | Create JDBC URL for the specified GDS type and database connection properties.
    `static GDSFactoryPlugin` | `getPlugin​(GDSType gdsType)` | Get plugin for the specified GDS type.
    `static java.util.Set<java.lang.String>` | `getSupportedProtocols()` | Get collection of the supported JDBC protocols.
    `static GDSType` | `getTypeForProtocol​(java.lang.String jdbcUrl)` | Get GDS type for the specified JDBC URL.
    `static void` | `registerPlugin​(GDSFactoryPlugin plugin)` | Register plugin for this factory.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### registerPlugin

          public static void registerPlugin​(GDSFactoryPlugin plugin)

      Register plugin for this factory. Usually there is no need to register plugins, since this happens automatically during initialization of this class. However, there might be a situation when automatic plugin registration does not work.
      Parameters:
        `plugin` - instance of `GDSFactoryPlugin` to register.

    - #### getDefaultGDSType

          public static GDSType getDefaultGDSType()

      Get default GDS type.
      Returns:
        instance of `GDSType`.

    - #### getDatabaseFactoryForType

          public static FbDatabaseFactory getDatabaseFactoryForType​(GDSType gdsType)

    - #### getDatabasePath

          public static java.lang.String getDatabasePath​(GDSType gdsType,
                                                         java.lang.String server,
                                                         java.lang.Integer port,
                                                         java.lang.String path)
                                                  throws GDSException

      Get connection string for the specified server name, port and database name/path. This method delegates call to the factory plugin corresponding to the specified type.
      Parameters:
        `gdsType` - instance of `GDSType` for which connection string should be returned.
        `server` - name or IP address of the database server, applies only to IPC and TCP connection modes, in other cases should be `null`.
        `port` - port on which database server opened listening socket, applies to TCP connection mode only, may be `null`.
        `path` - database name or path to the database
      Returns:
        full connection string
      Throws:
        `GDSException` - if connection string cannot be obtained.

    - #### getDatabasePath

          public static java.lang.String getDatabasePath​(GDSType gdsType,
                                                         java.lang.String jdbcUrl)
                                                  throws GDSException

      Get path to the database from the specified JDBC URL. This method finds the appropriate plugin and delegates the call to it. Plugin is responsible for the call execution.
      Parameters:
        `gdsType` - type of the plugin, to which operation will be delegated to.
        `jdbcUrl` - JDBC url from which the database path must be extracted.
      Returns:
        path to the database specified in the JDBC URL.
      Throws:
        `GDSException` - error when database path cannot be extracted.

    - #### getSupportedProtocols

          public static java.util.Set<java.lang.String> getSupportedProtocols()

      Get collection of the supported JDBC protocols.
      Returns:
        set of the supported protocols.

    - #### getJdbcUrl

          @Deprecated
          public static java.lang.String getJdbcUrl​(GDSType gdsType,
                                                    java.lang.String databasePath)

      Deprecated.
      Use `getJdbcUrl(GDSType, DatabaseConnectionProperties)`; will be removed in Jaybird 6
      Create JDBC URL for the specified GDS type and database path.
      Parameters:
        `gdsType` - type of the plugin, to which operation will be delegated to.
        `databasePath` - path to the database.
      Returns:
        newly created JDBC URL.

    - #### getJdbcUrl

          public static java.lang.String getJdbcUrl​(GDSType gdsType,
                                                    DatabaseConnectionProperties dbConnectionProperties)
                                             throws java.sql.SQLException

      Create JDBC URL for the specified GDS type and database connection properties.
      Parameters:
        `gdsType` - type of the plugin, to which operation will be delegated to.
        `dbConnectionProperties` - Database connection properties
      Returns:
        newly created JDBC URL
      Throws:
        `java.sql.SQLException` - When required information is missing to build the URL

    - #### getTypeForProtocol

          public static GDSType getTypeForProtocol​(java.lang.String jdbcUrl)

      Get GDS type for the specified JDBC URL. This method finds the plugin corresponding to the specified type and delegates the call to it.
      Parameters:
        `jdbcUrl` - JDBC URL for which GDS type should be obtained.
      Returns:
        instance of `GDSType`.

    - #### getConnectionClass

          public static java.lang.Class<?> getConnectionClass​(GDSType gdsType)

      Get class extending the `FBConnection` that will be instantiated when new connection is created. This method finds the plugin for the specified type and delegates the call to it.
      Parameters:
        `gdsType` - instance of `GDSType`
      Returns:
        class to instantiate for the database connection.

    - #### getPlugin

          @InternalApi
          public static GDSFactoryPlugin getPlugin​(GDSType gdsType)

      Get plugin for the specified GDS type.
      Parameters:
        `gdsType` - GDS type.
      Returns:
        instance of `GDSFactoryPlugin`
      Throws:
        `java.lang.IllegalArgumentException` - if specified type is not known.