On Aug 27, 2009, at 12:37 AM, ngocdaothanh wrote:

As I understand clojure.contrib.sql's with-connection opens DB
connection at the beginning and closes it at the end of each call.

That's correct.

How do I create a connection pool so that with-connection can reuse
connections?

clojure.contrib.sql is a thin layer over Java's JDBC.

A Google search for:

        best jdbc connection pooling

gives a lot of good links.

In particular, this one looks useful:

http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html

In addition to supporting connections via a DriverManager, clojure.contrib.sql can also use a DataSource or JNDI name to connect. I see that some methods of pooling use those.

Other links:

http://www.source-code.biz/snippets/java/8.htm
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html
http://java.sun.com/j2ee/1.4/docs/devguide/dgjdbc.html
http://javahowto.blogspot.com/2008/12/how-to-create-jdbc-connection-pool-and.html

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to