-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created shaded all packages and updated examples. (#2001)
- Loading branch information
Showing
10 changed files
with
181 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,6 @@ | |
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<id>zhicwu</id> | ||
<name>Zhichun Wu</name> | ||
<email>[email protected]</email> | ||
<timezone>+8</timezone> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<url>https://github.com/ClickHouse/clickhouse-java</url> | ||
<connection>scm:[email protected]:ClickHouse/clickhouse-java.git</connection> | ||
|
@@ -73,56 +64,29 @@ | |
<compiler-plugin.version>3.8.1</compiler-plugin.version> | ||
|
||
<minJdk>1.8</minJdk> | ||
<clickhouse-packages.classifier>all</clickhouse-packages.classifier> | ||
</properties> | ||
|
||
<profiles> | ||
<profile> | ||
<id>http</id> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.clickhouse</groupId> | ||
<artifactId>clickhouse-jdbc</artifactId> | ||
<version>${clickhouse-java.version}</version> | ||
<classifier>http</classifier> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>shaded</id> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.clickhouse</groupId> | ||
<artifactId>clickhouse-jdbc</artifactId> | ||
<version>${clickhouse-java.version}</version> | ||
<classifier>shaded</classifier> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
<profile> | ||
<id>fatjar</id> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.clickhouse</groupId> | ||
<artifactId>clickhouse-jdbc</artifactId> | ||
<version>${clickhouse-java.version}</version> | ||
<classifier>all</classifier> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
|
||
</profiles> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.zaxxer</groupId> | ||
<artifactId>HikariCP</artifactId> | ||
<version>${hikaricp.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.clickhouse</groupId> | ||
<artifactId>clickhouse-jdbc</artifactId> | ||
<version>${clickhouse-java.version}</version> | ||
<classifier>${clickhouse-packages.classifier}</classifier> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<version>2.0.13</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,23 +82,6 @@ static String exteralTables(String url) throws SQLException { | |
} | ||
} | ||
|
||
static String manualTransaction(String url) throws SQLException { | ||
Properties props = new Properties(); | ||
// props.setProperty(JdbcConfig.PROP_AUTO_COMMIT, "false"); | ||
props.setProperty("autoCommit", "false"); | ||
// props.setProperty(JdbcConfig.PROP_TX_SUPPORT, "true"); | ||
props.setProperty("transactionSupport", "true"); | ||
try (Connection conn = getConnection(url, props)) { | ||
if (!((ClickHouseConnection) conn).isTransactionSupported()) { | ||
System.out.println("Re-establishing connection until transaction is supported..."); | ||
return manualTransaction(url); | ||
} | ||
|
||
conn.commit(); | ||
return "Transaction committed!"; | ||
} | ||
} | ||
|
||
static String namedParameter(String url) throws SQLException { | ||
Properties props = new Properties(); | ||
// props.setProperty(JdbcConfig.PROP_NAMED_PARAM, "true"); | ||
|
@@ -172,19 +155,14 @@ static String unwrapToUseClientApi(String url) throws SQLException { | |
public static void main(String[] args) { | ||
// randomly pick one of the two endpoints to connect to, | ||
// fail over to the other when there's connection issue | ||
String url = System.getProperty("chUrl", | ||
"jdbc:ch://(https://[email protected]:443)," | ||
+ "(https://demo:[email protected])" | ||
+ "/default?failover=1&load_balancing_policy=random"); | ||
String url = System.getProperty("chUrl", "jdbc:ch://localhost"); | ||
|
||
try { | ||
System.out.println(exteralTables(url)); | ||
System.out.println(namedParameter(url)); | ||
System.out.println(renameResponseColumn(url)); | ||
System.out.println(unwrapToUseClientApi(url)); | ||
|
||
// requires ClickHouse 22.6+ with transaction enabled | ||
System.out.println(manualTransaction(url)); | ||
} catch (SQLException e) { | ||
e.printStackTrace(); | ||
} | ||
|
Oops, something went wrong.