Class JdbcIO.DataSourceConfiguration

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    JdbcIO

    public abstract static class JdbcIO.DataSourceConfiguration
    extends java.lang.Object
    implements java.io.Serializable
    A POJO describing a DataSource, either providing directly a DataSource or all properties allowing to create a DataSource.
    See Also:
    Serialized Form
    • Constructor Detail

      • DataSourceConfiguration

        public DataSourceConfiguration()
    • Method Detail

      • create

        public static JdbcIO.DataSourceConfiguration create​(org.apache.beam.sdk.options.ValueProvider<@Nullable java.lang.String> driverClassName,
                                                            org.apache.beam.sdk.options.ValueProvider<@Nullable java.lang.String> url)
      • withUsername

        public JdbcIO.DataSourceConfiguration withUsername​(org.apache.beam.sdk.options.ValueProvider<@Nullable java.lang.String> username)
      • withPassword

        public JdbcIO.DataSourceConfiguration withPassword​(org.apache.beam.sdk.options.ValueProvider<@Nullable java.lang.String> password)
      • withConnectionProperties

        public JdbcIO.DataSourceConfiguration withConnectionProperties​(java.lang.String connectionProperties)
        Sets the connection properties passed to driver.connect(...). Format of the string must be [propertyName=property;]*

        NOTE - The "user" and "password" properties can be add via withUsername(String), withPassword(String), so they do not need to be included here.

      • withConnectionInitSqls

        public JdbcIO.DataSourceConfiguration withConnectionInitSqls​(java.util.Collection<@Nullable java.lang.String> connectionInitSqls)
        Sets the connection init sql statements to driver.connect(...).

        NOTE - This property is not applicable across databases. Only MySQL and MariaDB support this. A Sql exception is thrown if your database does not support it.

      • withMaxConnections

        public JdbcIO.DataSourceConfiguration withMaxConnections​(java.lang.Integer maxConnections)
        Sets the maximum total number of connections. Use a negative value for no limit.
      • withDriverClassLoader

        public JdbcIO.DataSourceConfiguration withDriverClassLoader​(java.lang.ClassLoader driverClassLoader)
        Sets the class loader instance to be used to load the JDBC driver. If not specified, the default class loader is used.
      • withDriverJars

        public JdbcIO.DataSourceConfiguration withDriverJars​(java.lang.String driverJars)
        Comma separated paths for JDBC drivers. This method is filesystem agnostic and can be used for all FileSystems supported by Beam If not specified, the default classloader is used to load the jars.

        For example, gs://your-bucket/driver_jar1.jar,gs://your-bucket/driver_jar2.jar.

      • buildDatasource

        public javax.sql.DataSource buildDatasource()