赞
踩
HikariConfig中各属性设置 { "allowPoolSuspension": false, "autoCommit": true, "connectionTimeout": 10000, "driverClassName": "org.apache.hive.jdbc.HiveDriver", "idleTimeout": 30000, "initializationFailTimeout": 30000, "jdbcUrl": "jdbc:hive2://IP:port,IP:port,IP:port/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2", "leakDetectionThreshold": 0, "maxLifetime": 1800000, "maximumPoolSize": 15, "minimumIdle": 5, "password": "XXXXXX", "username": "XXXXX", "validationTimeout": 30000 } 获取连接 Connection=new HikariDataSource(hikariConfig).getConnection(); 所需依赖(注意各依赖之间版本) <!-- hive begin --> <dependency> <groupId>org.apache.hive</groupId> <artifactId>hive-jdbc</artifactId> <version>2.0.0</version> <exclusions> <exclusion> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> </exclusion> <exclusion> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> </exclusion> <exclusion> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-apache-client4</artifactId> </exclusion> <exclusion> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-all</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jdbc</artifactId> </dependency> <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.11</version> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-framework</artifactId> <version>4.0.1</version> <exclusions> <exclusion> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-recipes</artifactId> <version>4.0.1</version> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-client</artifactId> <version>4.0.1</version> </dependency> <!-- hive end --> <!-- springboot 版本 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.9</version> </parent>
2,连接postgresql
HikariConfig中各属性设置 { "connectionTimeout": 10000, "driverClassName": "org.postgresql.Driver", "idleTimeout": 30000, "initializationFailTimeout": 30000, "isolateInternalQueries": false, "jdbcUrl": "jdbc:postgresql://192.168.112.50:5433/dh", "leakDetectionThreshold": 0, "maxLifetime": 1800000, "maximumPoolSize": 15, "minimumIdle": 5, "password": "XXXXX", "poolName": "jdbc-hikari", "username": "XXXX", "validationTimeout": 30000 } 获取连接 Connection=new HikariDataSource(hikariConfig).getConnection(); 所需依赖 <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.1.1</version> </dependency> <!-- springboot 版本 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.9</version> </parent>
3,连接presto
HikariConfig中各属性设置 { "driverClassName": "io.prestosql.jdbc.PrestoDriver", "idleTimeout": 30000, "initializationFailTimeout": 30000, "jdbcUrl": "jdbc:presto://IP:port?SSL=true&SSLKeyStorePath=F:/key/presto.keystore&SSLKeyStorePassword=XXX", "leakDetectionThreshold": 0, "maxLifetime": 1800000, "maximumPoolSize": 15, "minimumIdle": 5, "password": "YYYYY", "readOnly": false, "registerMbeans": false, "username": "XXXX", "validationTimeout": 30000 } 获取连接 Connection=new HikariDataSource(hikariConfig).getConnection(); 所需依赖 <dependency> <groupId>io.prestosql</groupId> <artifactId>presto-jdbc</artifactId> <version>338</version> </dependency> <!-- springboot 版本 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.9</version> </parent>
4,连接MySQL
HikariConfig中各属性设置 { "connectionTimeout": 10000, "driverClassName": "com.mysql.cj.jdbc.Driver", "idleTimeout": 30000, "initializationFailTimeout": 30000, "isolateInternalQueries": false, "jdbcUrl": "jdbc:mysql://192.168.112.50:3306/dhtest?useSSL=false", "leakDetectionThreshold": 0, "maxLifetime": 1800000, "maximumPoolSize": 15, "minimumIdle": 5, "password": "XXXXXX", "username": "XXXXX", "validationTimeout": 30000 } 获取连接 Connection=new HikariDataSource(hikariConfig).getConnection(); 所需依赖 <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- springboot 版本 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.9</version> </parent>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。