Home > Back-end >  [for] a JDBC connection Hive3.1.2 error, connection 1.1.0 version is no problem, what reason be?
[for] a JDBC connection Hive3.1.2 error, connection 1.1.0 version is no problem, what reason be?

Time:09-22

Project is used in the hive - hive JDBC to remote database connection, the previous version of the hive is 1.1.0, hive - JDBC version is 1.1.0. Connect with alibaba druid connection pool, no problem. Can execute the query.
Replaced by a new hive database, the hive version changed 3.1.2, hadoop is also the latest 3.3.0, the same configuration, modify the hive - a JDBC driver version, modify the connection url, connection error. Don't know what the reason, the error message is as follows:


I loaded configuration class is as follows:
 @ Data 
@ Configuration
@ ConfigurationProperties (prefix="spring. The datasource. Hive. The druid")
@ Log4j2
Public class HiveDataBaseConfigBACKUP {

@ Value (" ${spring. The datasource. Hive. Druid. Filters} ")
Private String filters.
@ Value (" ${spring. The datasource. Hive. Druid. DriverClassName} ")
Private String driverClassName;
@ Value (" ${spring. The datasource. Hive. Druid. Url} ")
private String url;
@ Value (" ${spring. The datasource. Hive. Druid. Username} ")
private String username;
@ Value (" ${spring. The datasource. Hive. Druid. "} ")
private String password;
@ Value (" ${spring. The datasource. Hive. Druid. InitialSize} ")
Private int initialSize;
@ Value (" ${spring. The datasource. Hive. Druid. MinIdle} ")
Private int minIdle;
@ Value (" ${spring. The datasource. Hive. Druid. MaxActive} ")
Private int maxActive;
@ Value (" ${spring. The datasource. Hive. Druid. MaxWait} ")
Private long maxWait;
@ Value (" ${spring. The datasource. Hive. Druid. TimeBetweenEvictionRunsMillis} ")
Private long timeBetweenEvictionRunsMillis;
@ Value (" ${spring. The datasource. Hive. Druid. MinEvictableIdleTimeMillis} ")
Private long minEvictableIdleTimeMillis;
@ Value (" ${spring. The datasource. Hive. Druid. ValidationQuery} ")
Private String validationQuery;
@ Value (" ${spring. The datasource. Hive. Druid. TestWhileIdle} ")
Private Boolean testWhileIdle;
@ Value (" ${spring. The datasource. Hive. Druid. TestOnBorrow} ")
Private Boolean testOnBorrow;
@ Value (" ${spring. The datasource. Hive. Druid. TestOnReturn} ")
Private Boolean testOnReturn;
@ Value (" ${spring. The datasource. Hive. Druid. PoolPreparedStatements} ")
Private Boolean poolPreparedStatements;
@ Value (" ${spring. The datasource. Hive. Druid. MaxPoolPreparedStatementPerConnectionSize} ")
Private int maxPoolPreparedStatementPerConnectionSize;


@ Bean (name="hiveDruidDataSource")
@ the Qualifier (" hiveDruidDataSource ")
Public DataSource hiveDataSource () throws SQLException {
DruidDataSource druid=new DruidDataSource ();
//monitoring statistics of intercepting filters
Druid. SetFilters (filters);

//configure basic attribute
Druid. SetDriverClassName (driverClassName);
Druid. SetUsername (username);
Druid. SetPassword (password);
Druid. SetUrl (url);

//initialize the establishment of physical connection number
Druid. SetInitialSize (initialSize);
//maximum number of connection pool
Druid. SetMaxActive (maxActive);
//minimum number of connection pool
Druid. SetMinIdle (minIdle);
//get connection maximum wait time, unit of milliseconds,
Druid. SetMaxWait (maxWait);
//how long is the interval for a test, the test need to shut down the free connection
Druid. SetTimeBetweenEvictionRunsMillis (timeBetweenEvictionRunsMillis);
//a connection in the pool minimum survival time
Druid. SetMinEvictableIdleTimeMillis (minEvictableIdleTimeMillis);
//used to test for a valid SQL connection
Druid. SetValidationQuery (validationQuery);
//advice configuration is true, do not affect performance, and guarantee the security,
Druid. SetTestWhileIdle (testWhileIdle);
//when applying for connection of performing validationQuery test connection is valid
Druid. SetTestOnBorrow (testOnBorrow);
Druid. SetTestOnReturn (testOnReturn);
//whether the cache preparedStatement, namely PSCache, oracle is set to true, mysql is set to false, depots table is more recommended set to false
Druid. SetPoolPreparedStatements (poolPreparedStatements);
//open PSCache, specifies the size of each connection PSCache
Druid. SetMaxPoolPreparedStatementPerConnectionSize (maxPoolPreparedStatementPerConnectionSize);

The info (" Hive data source configuration success ");
Return druid.
}

@ Bean (name="hiveJdbcTemplate")
Public JdbcTemplate hiveJdbcTemplate (@ the Qualifier (" hiveDruidDataSource ") the DataSource DataSource) {
The info (" obtain Hive connection ");
Return new JdbcTemplate (dataSource);
}

}

Hive configuration is as follows:
 
Spring:
Datasource:
Hive:
Druid:
# monitoring statistics of intercepting filters
Filters: stat
DriverClassName: org. Apache. Hive. JDBC. HiveDriver
# configuration basic attribute
Url: JDBC: hive2://xx. Xx. Xx. Xx: 10000/default; Auth=noSasl
Username: app
Password:
# configuration initialization size/min/Max
InitialSize: 2
MinIdle: 3
MaxActive: 20
# get connection wait timeout
MaxWait: 60000
# how long is the interval for a test, the test need to shut down the free connection
TimeBetweenEvictionRunsMillis: 60000
# a connection in the pool minimum survival time
MinEvictableIdleTimeMillis: 300000
ValidationQuery: SELECT 1
TestWhileIdle: true
TestOnBorrow: false
TestOnReturn: false
Open PSCache # and specify the size of each connection PSCache, oracle is set to true, mysql is set to false, depots table is more recommended set to false
PoolPreparedStatements: false
MaxPoolPreparedStatementPerConnectionSize: 20

Add the hive dependence is as follows:
 

Org. Apache. Hive
Hive - jdbc
  • Related