Note that there are some explanatory texts on larger screens.

plurals
  1. POtomcat connection pooling
    text
    copied!<p>I have a simple servlet running in Tomcat. Because the servlet connects to a database, I need to use connection pooling. However, all the examples on the internet assume that (the developer) will never change which database the servlet is connecting to.</p> <p>For example, here is a sample context.xml file.</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Context antiJARLocking="true" path="/feeds"&gt; &lt;Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" username="username" password="password" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://example.com:1234/myDB" maxWait="1000" removeAbandoned="true" maxActive="30" maxIdle="10" removeAbandonedTimeout="60" logAbandoned="true"/&gt; &lt;/Context&gt; </code></pre> <p>In my case, I have a test server (postgresql) and a production server (ms sql), so all the tutorials assuming that I can just hardcode settings in the context.xml won't work. </p> <p>I have 2 different properties file's for the database url's, authentication etc., which I use, one for test server, one for production server, and that works great, but now if I want to use connection pooling, how would I integrate this into my servlet?</p> <p>I want to be able to hit "build" in Netbeans 6.5, take the war in the dist directory, and drop it in the tomcat application dir of either server, without having to go around changing xml files after the new war has been deployed. The servlet knows where to get the properties file on each system, so if I can integrate the properties file with the connection pooling properties, I'd be all set.</p> <p>Any ideas... ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload