Java Code Examples for io.debezium.jdbc.JdbcConfiguration

Following code examples demonstrate how to use io.debezium.jdbc.JdbcConfigurationfrom debezium. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use io.debezium.jdbc.JdbcConfigurationand various code implementation of this class.

    public static JdbcConfiguration defaultJdbcConfig() {
        return JdbcConfiguration.copy(Configuration.fromSystemProperties("database."))
                                .withDefault(JdbcConfiguration.DATABASE, TEST_DATABASE)
                                .withDefault(JdbcConfiguration.HOSTNAME, "localhost")
                                .withDefault(JdbcConfiguration.PORT, 1433)
                                .withDefault(JdbcConfiguration.USER, "sa")
                                .withDefault(JdbcConfiguration.PASSWORD, "Password!")
                                .build();
    } 


    public static Configuration.Builder defaultConfig() {
        JdbcConfiguration jdbcConfiguration = defaultJdbcConfig();
        Configuration.Builder builder = Configuration.create();

        jdbcConfiguration.forEach(
                (field, value) -> builder.with(SqlServerConnectorConfig.DATABASE_CONFIG_PREFIX + field, value)
        );

        return builder.with(SqlServerConnectorConfig.LOGICAL_NAME, "server1")
                .with(SqlServerConnectorConfig.DATABASE_HISTORY, FileDatabaseHistory.class)
                .with(FileDatabaseHistory.FILE_PATH, DB_HISTORY_PATH);
    } 

    public static JdbcConfiguration adminJdbcConfig() {
        return JdbcConfiguration.copy(Configuration.fromSystemProperties("database."))
                                .withDefault(JdbcConfiguration.DATABASE, "master")
                                .withDefault(JdbcConfiguration.HOSTNAME, "localhost")
                                .withDefault(JdbcConfiguration.PORT, 1433)
                                .withDefault(JdbcConfiguration.USER, "sa")
                                .withDefault(JdbcConfiguration.PASSWORD, "Password!")
                                .build();
    } 

    public Connection connect(JdbcConfiguration config) throws SQLException {
        String hostName = config.getHostname();
        int port = config.getPort();
        String database = config.getDatabase();
        String user = config.getUser();
        String password = config.getPassword();

        return DriverManager.getConnection(
              "jdbc:oracle:oci:@" + hostName + ":" + port + "/" + database, user, password
        );
    } 

Advertisement
Javadoc
A specialized configuration for the Debezium driver. This defines several known io.debezium.config.F

ield fields that are common to all JDBC configurations. @author Randall Hauch

Read More
Advertisement