Support Questions
Find answers, ask questions, and share your expertise

HBase, Phoneix, Spring boot, JDBCTemplate, The connection failed when sending a large array


Hi All,

I have a spring boot application and connect to Phoneix HBase.

i have a post function like:

@RequestMapping(method = RequestMethod.POST, value = "data/batchinsert/")
	public ResponseEntity<?> batchInsertHaEnvrironmentData(@RequestBody List<HaEnvrironmentData> tts) {
		int i = heds.batchInsert(tts);
		if (i <= 0)
			new ResponseEntity<String>("failed", HttpStatus.NO_CONTENT);
		return new ResponseEntity<String>("Successed", HttpStatus.OK);


public int batchInsert(List<HaEnvrironmentData> eds){
		String sql=EvotionSqlUtils.getUpsertSql("HA_ENVRIRONMENT_DATA", true, HaEnvrironmentEnum.class, null);
		BatchPreparedStatementSetter bpss = new BatchPreparedStatementSetter() {
			public void setValues(PreparedStatement ps, int i) throws SQLException {
				HaEnvrironmentData ed=eds.get(i);
				Connection conn= getConnection();
				ps.setString(1,  ed.getId());
				ps.setTimestamp(2,  ed.getRecord_date());
				ps.setString(3,  ed.getAid_id());
				ps.setShort(4, ed.getEnvironment_classification_unit());
		    public int getBatchSize() {
		        return eds.size();
		  int[] counts=jdbcTemplate.batchUpdate(sql, bpss);
		  return counts.length;

The data list




This works fine with two or three data in the list. However, it failed when I am trying with 100 data blocks on the list.

And shows the error below:

org.apache.tomcat.jdbc.pool.PoolExhaustedException: [http-nio-8080-exec-2] Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none available[size:100; busy:100; idle:0; lastwait:30000].
	at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(
	at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(
	at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(
	at org.evotion.datarepository.dao.BaseDaoImpl.getConnection(
	at org.evotion.datarepository.dao.HaEnvrironmentDataDaoImpl.insert(
	at org.evotion.datarepository.dao.HaEnvrironmentDataDaoImpl.batchInsert(
	at org.evotion.datarepository.dao.HaEnvrironmentDataDaoImpl$$FastClassBySpringCGLIB$$618b5314.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(

By the way, the JDBCTemplate will release the connection automatically. but why every time, when I execute the post function above, the connection pool gets exhausted.

Please help me!

Many thanks in advance.


Super Collaborator

I would suggest disabling connection pooling first. FAQ


How to disable the connection pool?

; ;