Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralized configuration for JDBC driver #1290

Merged
merged 3 commits into from
Mar 18, 2023
Merged

Conversation

zhicwu
Copy link
Contributor

@zhicwu zhicwu commented Mar 18, 2023

Summary

Centralized configuration for JDBC driver, which might be of use when you want to maintain consistent configuration for a group of users using JDBC driver v0.4.2+. Please pay attention that it's built for ease of use not security control.

Usage

  • add custom server setting
    <!-- config.xml -->
    <custom_settings_prefixes>custom_</custom_settings_prefixes>
    
    <!-- users.xml -->
    <profiles>
        ...
        <managed>
            <!-- use '*' to discard all options specified in JDBC client -->
            <custom_jdbc_config><![CDATA['*&custom_settings=max_result_rows%3D1&compress_algorithm=gzip&!transactionSupport']]></custom_jdbc_config>
        </managed>
    </profiles>
    <users>
        ...
        <user1>
            <profile>managed</profile>
            <networks>
                <ip>::/0</ip>
            </networks>
            <password>123</password>
            <quota>default</quota>
        </user1>
    </users>
  • connect to the server using JDBC driver as usual
    Properties props = new Properties();
    props.setProperty("user", "user1");
    props.setProperty("password", "123");
    try (Connection conn = DriverManager.getConnection("jdbc:ch:http://server1?transactionSupport&max_execution_time=3600")) {
        // same as connecting to below URL
        // jdbc:ch:http://server1?custom_settings=max_result_rows%3D1&compress_algorithm=gzip&!transactionSupport
    }

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@zhicwu zhicwu merged commit c079c99 into ClickHouse:main Mar 18, 2023
@zhicwu zhicwu linked an issue Mar 18, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code: 452. Setting max_execution_time should not be changed
1 participant