Commit abffde53 by 陶光胜

取数平台权限

parent 1b03e693
......@@ -24,10 +24,13 @@ public class HiveHelper implements ApplicationContextAware {
/** 内置数据源 */
private static DataSource source = null;
private static DataSource downloadSource = null;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
log.debug("setApplicationContext", "准备初始化 Hive 连接池");
source = (DataSource)applicationContext.getBean("hiveSource");
downloadSource = (DataSource)applicationContext.getBean("downloadHiveSource");
}
/** 获取 Hive 数据源
......@@ -62,5 +65,26 @@ public class HiveHelper implements ApplicationContextAware {
} // TRY CATCH OVER
}
public static Connection getDownloadHiveConnection() {
Connection conn = null;
try {
// String url = "jdbc:hive2://115.159.205.44:10015/data_test";
// //String url = "jdbc:hive2://10.0.0.3:10015/data_test";
// Class.forName("org.apache.hive.jdbc.HiveDriver");
// conn = DriverManager.getConnection(url, "hadoop", "");
conn = downloadSource.getConnection();
return conn;
} catch (Exception ex) {
ex.printStackTrace();
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return null;
} // TRY CATCH OVER
}
}
......@@ -503,7 +503,7 @@ public class FlatQueryResultServiceImpl implements IFlatQueryResultService {
0,
condition.getAuthStoreIdList());
Connection conn = HiveHelper.getHiveConnection();
Connection conn = HiveHelper.getDownloadHiveConnection();
if (conn != null) {
try {
Statement stat = conn.createStatement();
......
......@@ -35,4 +35,27 @@
</property>
</bean>
<bean class="org.apache.commons.dbcp.BasicDataSource" id="downloadHiveSource" destroy-method="close">
<property name="driverClassName" value="org.apache.hive.jdbc.HiveDriver" />
<!--<property name="url" value="jdbc:hive2://115.159.205.44:10015/data_test" />-->
<property name="url" value="${hive.download.url}" />
<property name="username" value="${hive.username}" />
<property name="password" value="" />
<property name="maxActive">
<value>20</value>
</property>
<property name="maxIdle">
<value>5</value>
</property>
<property name="minIdle">
<value>1</value>
</property>
<property name="testWhileIdle">
<value>true</value>
</property>
<property name="maxWait">
<value>120000</value>
</property>
</bean>
</beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment