after some reading of servlet architecture, tomcat mechanisms and DB pooling I wonder if I really should open a connection in the init of my servlet (and close in destroy)? My target is to archieve high performance, so I guess I should use a connection pool. For the beginning I use tomcat's built-in DB pooling mechanism.
context.xml
<Context>
<Resource name="jdbc/mytest" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="userxy" password="xy" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mytest"/>
</Context>
web xml:
<resource-ref>
<description>MyTest</description>
<res-ref-name>jdbc/mytest</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I am quite sure I can replace it easilly by s.th. else if neccessary. So my question is: Should I use instead of the serlet's init()/destroy() the per-request called doGet() and trust in the pooling mechanism? What, if I use both?