turbo
turbo

Reputation: 589

Maintaing MySql database connections in web app

I have MySql server. I am making trivial CRUD calls to it from java servlets. I am establishing connection before each call and closing it at the end.

What should be ideal way to handle this scenario so the application could scale and handle user load decently.

Upvotes: 0

Views: 94

Answers (2)

MaVRoSCy
MaVRoSCy

Reputation: 17839

definately the way to go is using connection pools (Connection pooling is a technique used for sharing database connections among requesting clients). Connection pooling provide significant benefits in terms of application performance, concurrency and scalability and usually involves little or no code modification.

Its pretty forward to use connection pools using tomcat but usually they differ in implementation details from version to version.

Upvotes: 0

Keith Randall
Keith Randall

Reputation: 23265

You should maintain a connection pool which recycles recently used connections. That way, each request to the mysql server doesn't require connection setup.

Upvotes: 1

Related Questions