Release a borrowed Connection back to ConnectionPool

35 views
Skip to first unread message

y2k-shubham

unread,
Apr 27, 2018, 3:08:14 AM4/27/18
to ScalikeJDBC Users Group
ScalikeJDBC's ConnectionPool docs page says:
----------------------------------------------------------------

Borrowing Connections


Simply just call #borrow method.

import scalikejdbc._
// default
val conn: java.sql.Connection = ConnectionPool.borrow()
// named
val conn: java.sql.Connection = ConnectionPool('named).borrow()

Be careful. The connection object should be released by yourself.

----------------------------------------------------------------

However there's no mention of how to do it.
I can always do Connection.close() but by 'releasing' Connection,
I understand that I'm supposed to return the Connection back to the ConnectionPool
and not close it (otherwise the purpose of having a ConnectionPool would be defied).

My doubts are:
1. What does 'releasing' a Connection (that has been borrowed from ConnectionPool) mean?
2. How do I 'release' a Connection borrowed from ConnectionPool?
Reply all
Reply to author
Forward
0 new messages