DB connection pool reaching max limit.

I am trying out the scheduler and per documentation have the server side connector initialized. However the pool is getting exhausted. Something wrong I am doing?
Should the connected backed be initialised only once? Should it be per user (Assuming, each online user has its own scheduler view)?

I need help here as I am not clear on how often the Scheduler need to be initialised? The initialization code needs JDBC connection. I plan to use it on a website with 1000+ users and each user can have its own scheduler view. What about transactions? Meaning it would be a disaster to use single connection across all online users (1000), this would not work. If there is a way to return back the connection to the pool, it would make sense…

My code is (DHTMLX scheduler + Spring MVC + Atomikos MySQL connection pool). The connection object is obtained from the pool using Spring JDBC template.

E.g. JdbcTemplate template = (JdbcTemplate) applicationContext
.getBean(“jdbcTemplate”);
conn = template.getDataSource().getConnection();

// Initialize connector. This should be only once per user or application?
SchedulerConnector schedulerConnector = new SchedulerConnector(conn,
DBType.MySQL);
schedulerConnector.servlet(request, response);
schedulerConnector.render_table(“events”, “event_id”,
“start_date, end_date, text”);

Please guide…

The code of connector will use a single connection object that you must provide, this connection will be released after data operation end ( data loading end or data saving end )

Connector itself doesn’t provide any pulling it can be configured on JDBC level.

I have the DB connection pool configured in Tomcat server. I retrieve one connection and give it to scheduler. Noticed that each time I refresh a page, the code retrieves the connection from the pool, gives it to Scheduler (init, operation) takes place. If the connection is destroyed then the connection pool should not run out of connection. There must be some way to release connection back to the pool after the operation is complete. You say the connection is destroyed after the operation? But creating a connection itself is very expensive.

Usually in J2EE/spring applications the The connection is returned back to the pool after the transaction completes.

Also are you suggesting that I create a connection using standard JDBC style? (E.g class.forname().newInstance()?. This is fine, but in-efficient hence JDBC introduced the concept of connection pool, where 100+ connections are maintained and used and returned on demand. There is a huge cost in creating DB connection.

If DHTMLx scheduler wants me to do the old style, fine…please let me know. But this piece need to be improved. Especially for high trafffic, multidevice website.

Added the code to explicitly close the connection. Now the pool is back to normal.

@Override
protected void configure(HttpServletRequest request,
HttpServletResponse response) {

	System.out.println("Reached...");

	// obtain DB connection

	Connection conn = null;
	try {
		WebApplicationContext applicationContext = WebApplicationContextUtils
				.getWebApplicationContext(request.getSession()
						.getServletContext());
		JdbcTemplate template = (JdbcTemplate) applicationContext
				.getBean("jdbcTemplate");
		conn = template.getDataSource().getConnection();
		System.out.println("DB connection - " + conn);
	} catch (Throwable e) {
		System.out.println("No connection");
		e.printStackTrace();
	}

	// Initialize connector. This should be only once per user or
	// application?
	SchedulerConnector schedulerConnector = new SchedulerConnector(conn,
			DBType.MySQL);
	schedulerConnector.servlet(request, response);
	schedulerConnector.render_table("events", "event_id",
			"start_date, end_date, text");

	[b]try {
		conn.close();
		System.out.println("closing DB connection!");
	} catch (SQLException e) {
		e.printStackTrace();
	}[/b]
}