Hi all,
I have the same problem with DB connections. How I can solve it? Any idea? My pool connection don't work well.
I have Java Web application, that I invoke with Java Web Start. The application is configure with Spring+Hibernate+MySQL. I Have problem with DB connection. I have probed with dbcp, c3p0 and finally with bonetcp, but always it generate more conection than maxConnection configure.
My applicationContext.xml content is:
… .hbm.xml
-->
<!-- Transaction manager for a single JDBC DataSource -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!--
========================= DAO DEFINITIONS =========================
-->
<bean id="functionsDao" class="….model.dao.TSysFunctionsDao">
<property name="dataSource" ref="dataSource" />
</bean>
…
DAO class example:
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import javax.naming.InitialContext;
import javax.sql.DataSource;
public class TSysFuncionsDao {
private DataSource dataSource;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
public TDsDsourceDao() {
}
public Response getTSysFunctionssList(GridParams gridParams) throws DataAccessException {
Connection conn = null;
try {
conn = dataSource.getConnection();
…
return res;
}
catch (Exception ex) {
return new ErrorResponse(ex.getMessage());
}
finally {
try {
conn.close();
}
catch (Exception ex1) {
}
}
}
}
I think that the system not release the close data source connection. Any Idea? How I can solve it?
Thanks in advances.