Skip to content

Commit

Permalink
fixes #5 by closing connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Nov 1, 2013
1 parent 7868e87 commit 030ca5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/com/jcabi/jdbc/JdbcSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ private <T> T run(final JdbcSession.Handler<T> handler,
}
throw new SQLException(ex);
} finally {
if (this.auto) {
this.disconnect();
}
this.args.clear();
}
return result;
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/jcabi/jdbc/JdbcSessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public String handle(final ResultSet rset)
* @since 0.10.2
*/
@Test
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void releasesConnectionsFromThePool() throws Exception {
final DataSource src = JdbcSessionTest.source();
new JdbcSession(src)
Expand Down Expand Up @@ -162,7 +163,7 @@ public void executesSqlInParallelThreads() throws Exception {
*/
@Parallel(threads = Tv.FIFTY)
private void insert(final DataSource src, final String table)
throws Exception{
throws Exception {
new JdbcSession(src)
.sql(String.format("INSERT INTO %s VALUES ('hey')", table))
.execute();
Expand Down

0 comments on commit 030ca5e

Please sign in to comment.