Hi ranchers! I have made a class that implements the ServletContextListener. In this servlet I make a Connection that I can use in my application. ( I put it in the Context.setAttribute() ). My problem is that when I use this the Connection will be opened the whole time the application is alive. I want to make a Connection pool soo that I can close the connections after I have used them. I'm not sure if I have to close them or what's the best approch when coding this. It is just that I've heard of Connection pooling but I don't know how to do it , why it is soo good etc. I think by using it the way I have coded now that the Connection must finish before it can run a query again. If I have 500 users that want's to connect to the database then I have a big problem. My question is. * How do I code a Connection Pool ? * What is a Connection Pool. ? I've read that you should use JNDI instead of DriverManager. Is this correct and why? // Mathias
Most all servlet container/App Servers offer Connection Pooling through jndi. The web site for your app server should have the documentation available. For example, if you are using Tomcat, you can find information here. Once you have that setup you should be good to go. If you have more problems, let us know and we can help.
Thanks! The problem now is that I use jdk1.3 and the javax.sql isn't included. I have installed jdk1.4 , changed my JAVA_HOME but it is still not available. I'm using Tomcat4. I keep getting error on javax.sql import // Mathias
Could you display your code AND the error message you are recieving when you compile/run it. Also, if doing this from the command line, include the commands you type to compile/run the program. Thanks.