I am currently doing testing with Google Search Appliance (GSA) for crawling database and built a connector for handling database query and stuff.
The GSA have a crawl interval, which mean it will repeatedly crawl the database for update. So my question is:
Should I create a connection and close it for everytime GSA crawl the database ? (The crawl rate is very high, which mean connection will be repeatedly created and close alot).
Or should I just create a connection and let it stay to query the database for every crawl? The problem is that I do not have anyway to close the connection when the system terminated.
Or another better option ?
Use connection pooling as Vikdor said, but I would suggest you use BoneCP as it is better performance wise. Set a number of connections in the pool and then you would not have to worry about opening and closing or keeping the connection alive.