You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "lauradiara@libero.it" <la...@libero.it> on 2002/10/03 09:47:28 UTC

Please help me!!

Hi all,

I can't find an answer to this question. Plese help me.

I have an apache-tomcat(4.0.3) system installed. I use a connection 
DataSource with a Oracle database (I have a resource in server.xml with 
type="javax.sql.DataSource"). ---> Instruction in the JNDI Resources 
HOW-TO section of Tomcat 4.0.x.

My question is this. If Oracle DB crashes and it has to been restarted, 
does my web application,that uses DataSource, have to be restarted? 

I have a class with this static block:

static {
    try  {
        Context initCtx = new InitialContext();
        Context envCtx = (Context) initCtx.lookup("java:comp/env");
        DataSource ds = (DataSource) envCtx.lookup(dbName);
        con =  ds.getConnection();
        if (con == null)
          System.out.println("[ERROR] Connection null");
      } catch (Exception ex) {
        System.out.println("[ERROR] Errore = "  + ex.toString() + " \n" 
+ ex.getMessage());
        con = null;
      }
  }
 
and I have a method:


protected synchronized Connection getConnection() {
         while (conFree == false) {
            try {
               wait();
            } catch (InterruptedException e) {
              System.out.println("[ERROR] Exception getConnection() = " 
+ e.toString());
            }
         }
         conFree = false;
         notify();
         return con;
    }

In the servlets of my web application I call getConnection() to take 
the connection: if db is restarted what happen?

Thanks for your help

Laura



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Please help me!!

Posted by Nikola Milutinovic <Ni...@ev.co.yu>.
Miguel Angel Mulero Martinez wrote:

> This depends on how you use the connection. If you use a db pool, then the
> pool must reconnect. There're pools that do that and other that don't do.


Does DBCP that comes with Tomcat 4.0.4 and later reconnect?

Nix.




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Please help me!!

Posted by Miguel Angel Mulero Martinez <mi...@mad.tecsidel.es>.
This depends on how you use the connection. If you use a db pool, then the
pool must reconnect. There're pools that do that and other that don't do.

Regards.

-----Mensaje original-----
De: lauradiara@libero.it [mailto:lauradiara@libero.it]
Enviado el: jueves, 03 de octubre de 2002 9:47
Para: tomcat-user
Asunto: Please help me!!

Hi all,

I can't find an answer to this question. Plese help me.

I have an apache-tomcat(4.0.3) system installed. I use a connection
DataSource with a Oracle database (I have a resource in server.xml with
type="javax.sql.DataSource"). ---> Instruction in the JNDI Resources
HOW-TO section of Tomcat 4.0.x.

My question is this. If Oracle DB crashes and it has to been restarted,
does my web application,that uses DataSource, have to be restarted?

I have a class with this static block:

static {
    try  {
        Context initCtx = new InitialContext();
        Context envCtx = (Context) initCtx.lookup("java:comp/env");
        DataSource ds = (DataSource) envCtx.lookup(dbName);
        con =  ds.getConnection();
        if (con == null)
          System.out.println("[ERROR] Connection null");
      } catch (Exception ex) {
        System.out.println("[ERROR] Errore = "  + ex.toString() + " \n"
+ ex.getMessage());
        con = null;
      }
  }

and I have a method:


protected synchronized Connection getConnection() {
         while (conFree == false) {
            try {
               wait();
            } catch (InterruptedException e) {
              System.out.println("[ERROR] Exception getConnection() = "
+ e.toString());
            }
         }
         conFree = false;
         notify();
         return con;
    }

In the servlets of my web application I call getConnection() to take
the connection: if db is restarted what happen?

Thanks for your help

Laura



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>