I am using JDBC connection pool to make connection with mysql server.
Below is my code snippet
try {
InitialContext initialContext = new InitialContext();
Context context = (Context) initialContext.lookup("java:comp/env");
DataSource ds = (DataSource) context.lookup("connpool");
Connection conn = ds.getConnection();
//some query is executed
}
catch(SQLException ex)
{ }
finally { conn.close(); }
My Doubt:
My doubt here is even I am making connection close(conn.close()), in MySQL show processlist command it showing connection.
If I send more requests to servlet the connections count in show processlist is also increasing,
When this connection will be closed.
Why I am afraid means it it reached max connections count it will show error.
My Connection pool configuration is:
<Resource name="connpool" auth="Container"
type="javax.sql.DataSource"
maxActive="1" maxIdle="0"
maxWait="-1"
username="xxxxx"
password="xxxxx"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/govsocial"/>
conn.close
, but rather just free it up for use by anothergetConnection
. – GriffeyDog