🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## ClickHouse的JDBC连接 1)加入clickhouse-jdbc驱动依赖 ~~~ <dependency> <groupId>ru.yandex.clickhouse<//groupId> <artifactId>clickhouse-jdbc</artifactId> <version>0.1.54</version> </dependency> ~~~ 2)连接操作 ~~~JAVA import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; public class ClickhouseUtils { private static Connection connection = null; static { try { Class.forName("ru.yandex.clickhouse.ClickHouseDriver");// 驱动包 String url = "jdbc:clickhouse://192.168.89.230:8123/default";// url路径 String user = "default";// 账号 String password = "root";// 密码 connection = DriverManager.getConnection(url, user, password); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws SQLException { Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("select * from system.functions"); ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); while (resultSet.next()) { for (int i = 1; i <= columnCount; i++) { System.out.println(metaData.getColumnName(i) + ":" + resultSet.getString(i)); } } } } ~~~