You forgot to close the connection
Use a finally statement to close a pooled connection. The following finally block would appear after the try/catch block that applies to the code in which the pooled connection was used:
try {
Connection con =
ds.getConnection(username, password);
// ... code to use the pooled
// connection con
} catch (Exception ex {
// ... code to handle exceptions
} finally {
if (con != null) con.close();
}
Your datasource reached the maximum connection defined.