Link to home
Start Free TrialLog in
Avatar of aimueller
aimueller

asked on

displayed session number in tomcat web application manager..question

Hi,

If I start my servlet  I see a new session in  the tomcat web application manager. But After logging out and calling session.invalidate() the number of created session is still the same???

please ..help!!!
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

the session still will exist...  it will just be empty, and will be destroyed when it times out (or tomcat decides it is dead)
Avatar of aimueller
aimueller

ASKER

actually I have a problem with db connection pool: My servlet lost the db connection after 1 or 2 minutes, the configuration file is:
         <Resource name="jdbc/test" scope="Shareable" type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/test">
            <parameter>
              <name>driverClassName</name>
              <value>oracle.jdbc.driver.OracleDriver</value>
            </parameter>
            <parameter>
              <name>url</name>
              <value>jdbc:oracle:thin:@1.1.1.0:1521:test</value>
            </parameter>
            <parameter>
              <name>username</name>
              <value>test</value>
            </parameter>
            <parameter>
              <name>password</name>
              <value>test</value>
            </parameter>
            <parameter>
              <name>maxActive</name>
              <value>4</value>
            </parameter>
            <parameter>
              <name>maxWait</name>
              <value>10000</value>
            </parameter>
            <parameter>
              <name>maxIdle</name>
              <value>40</value>
            </parameter>
          </ResourceParams>

what is wrong in the config file..please!!

>  My servlet lost the db connection after 1 or 2 minutes,

You keep the connection open all that time?

You should open it when you need it, then close it again to return it to the pool
in my code:
- the main servlet resolves the datasource in the init()
- the main servlet opens - every access - the db connection in the doPost()  and gives it to the beans
- finally the main servlet do close the db connection

the beans do some calculations that takes max. 1 min.

May be the config file that I post it is not trivial??
Remember that connections are not managed by the run-time as your objects (garbage-collection). An open connection should be closed :-)

>> finally the main servlet do close the db connection

What if there are exceptions in between? Is the connection closed in a try block or a finally block (it should be in the finally block).
yeh.. the main servlet do close the connection in the finally block.
since every bean need a db connection, the db connection should be open in the main servlet :-(

ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial