Tim Lucia wrote:
-----Original Message----- From: Natasha N Wright [mailto:[EMAIL PROTECTED] Sent: Friday, March 16, 2007 6:08 AM To: Tomcat Users List Subject: Servlet Caching Hi, I have a servlet which connects to a database; once the connection is made I pass a connection object into another class which uses this object to execute queries on the database. When i run the servlet my queries are executed fine, when i try to run the application for a second time my class executing the queries doesn't work - it appears that it doesnt recieve the connection object properly it bombs out at the stage stmt = conn.createStatement();What exception are you getting? Connection closed? Odds are very good you closed the connection somewhere. Per the servlet spec, init() is called once when the servlet is initialized. It is generally a bad idea to use a single connection in a servlet as all threads running in that instance will be forced to use that connection, which leads to synchronization issues. It is far better to have a connection per request, allocated from a connection pool.
...which is dead easy to configure via JNDI http://tomcat.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.htmlI think we'd all recommend pretty strongly that you upgrade your version of Tomcat to something newer if you can. If you're stuck with Java 1.4, then go for 5.0.latest (4.0 is oooolllldddd, 4.1.n is better).
If you can install Java 1.5+ and go for 5.5 or 6.0 then all the better. The J1.5+ TC5.5+ combo is faster, better...
TimI am creating a connention within the inint() method of my servlet. When i re-start tomcat everything works fine again - this leads me to believe hat i have connection caching issuse. I have set the context param in server.xml to reloadable = true (not sure if this makes any difference) I am also not using a connection pool to connect to my database. I am using tomcat v.4.0 with Java 1.4 Any advice is appreciated Cheers Natasha This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]--------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME Cryptographic Signature