海我是hadoop和hive的新手。我的应用程序现在无法处理多个连接。当连接数增加(超过 4 个)时,它会变慢。任何人都可以弄清楚。代码如下。
public static void setupDriver(String connectURI) throws Exception {
ObjectPool connectionPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
connectURI, username, password);
@SuppressWarnings("unused")
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
connectionFactory, connectionPool, null, null, false, true);
Class.forName(poolingDriver);
PoolingDriver driver = (PoolingDriver) DriverManager.getDriver(poolConnection);
driver.registerPool(poolName, connectionPool);
}
stmt = connection.createStatement();
String queryString = "select feed_date,count(feed_date) from twitter_stats where tweet like '%" + searchRequest.getWord() + "%' ";
if (null != searchRequest.getFromDate()) {
queryString += "and feed_date >= '" + searchRequest.getFromDate() + "' ";
}