Problem connecting to database

I am currently testing the Google Search Appliance (GSA) to crawl a database and have built a connector to handle database queries, etc.

The GSA has a crawl interval, which means that it will rescan the database for updates. So my question is:

  • Should I create a connection and close it every time the GSA scans the database? (The crawl rate is very high, which means that the connection will be created and closed many times).

  • Or should I just create a connection and let it stay in the database for every scan? The problem is that I still don't close the connection when the system shuts down.

Or another better option?

+4
source share
2 answers

Use pooling as Vikdor said, but I would suggest you use BoneCP , as better performance . Define multiple connections in the pool, and you don’t have to worry about opening and closing or keeping the connection.

+1
source

You should use a simple pooling library such as C3P0 and configure the number of connections according to your requirement. Connection lifecycle management will be handled by the library, and you will be freed from establishing a connection, drop them in inactive periods, restore if necessary, etc.,

0
source

All Articles