-
Notifications
You must be signed in to change notification settings - Fork 607
Closed
Labels
Milestone
Description
Passing of custom properties is broken when using JDBC Driver's DataSource#getConnection(username,password)
method (it works when using DataSource#getConnection()
).
Verified with test suite pasted below, second test fails - I get ClickHouse Java Client
instead of Agent #1
. Verified on:
- 0.3.2-patch10 - test fails
- 0.3.2-patch9 - test fails
- 0.3.2-patch5 - test fails
- 0.3.2 - test fails
package pl.coretech.cdn;
import com.clickhouse.jdbc.ClickHouseConnection;
import com.clickhouse.jdbc.ClickHouseDataSource;
import com.clickhouse.jdbc.ClickHouseDriver;
import org.junit.jupiter.api.Test;
import java.sql.SQLException;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ConnectionTests {
private final static String URL = "jdbc:clickhouse://localhost:18123/";
private final static String USERNAME = "default";
private final static String PASSWORD = "";
private final static String CLIENT_NAME = "Agent #1";
static {
System.out.println(ClickHouseDriver.class.getPackage().getImplementationVersion());
}
@Test
void testDriver1() throws SQLException {
var properties = new Properties();
properties.setProperty("user", USERNAME);
properties.setProperty("password", PASSWORD);
properties.setProperty("client_name", CLIENT_NAME);
var dataSource = new ClickHouseDataSource(URL, properties);
try (var conn = dataSource.getConnection()) {
assertEquals(CLIENT_NAME, conn.getClientInfo(ClickHouseConnection.PROP_APPLICATION_NAME));
}
}
@Test
void testDriver2() throws SQLException {
var properties = new Properties();
properties.setProperty("client_name", CLIENT_NAME);
var dataSource = new ClickHouseDataSource(URL, properties);
try (var conn = dataSource.getConnection(USERNAME, PASSWORD)) {
assertEquals(CLIENT_NAME, conn.getClientInfo(ClickHouseConnection.PROP_APPLICATION_NAME));
}
}
}