MongoDB Connection in Java / JSF app

27 views
Skip to first unread message

Robert James Liguori

unread,
Jan 10, 2017, 7:43:51 PM1/10/17
to mongodb-user
What is the best practice for connections in a JSF app?

(a) One connection per session?
(b) Connection pooling?
(c) opening and closing connections per database query?
(d) other

Thanks,
Robert

Kevin Adistambha

unread,
Jan 26, 2017, 11:03:19 PM1/26/17
to mongodb-user

Hi Robert

What is the best practice for connections in a JSF app?

For most purposes, the recommended method is to use connection pooling. This is to avoid expensive setup/teardown process of establishing a database connection, and to better regulate connections into the database (i.e. avoiding high connection churn, too many connections into the database, etc.)

The standard MongoClient() method in MongoDB Java driver connects using a connection pool by default. Please see the Connect to MongoDB page for more information. If you need more information regarding the Java driver in general, please see the Java MongoDB Driver page.

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages