You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rasoul Hajikhani <ra...@rhythm.com> on 2001/10/12 00:02:06 UTC

JDBC Problem

Folks,
I am using Velocity and Tomcat to generate dynamic content. I have
posted this question on Servlets and Velocity user lists and all say the
same thing: move the informix driver to :
/tomcathome/lib/informixdriver.jar . The problem is that the driver is
"there" but I still get this error:
Error Connecting: java.sql.SQLException: No suitable driver
I have declared the path to the driver within the "CLASSPATH" and as I
stop/start tomcat I can see that it is reading from the updated class
path. I am not sure what the problem might be since I am a novice
Servlets/Velocity/Tomcat user. Any help would be greatly appreciated.
Thanks in advance
-r

Re: REPOST: java.util.ConcurrentModificationException

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 12 Oct 2001, Kar YEOW wrote:

> Date: Fri, 12 Oct 2001 09:45:03 +1000
> From: Kar YEOW <ka...@apir.com.au>
> Reply-To: tomcat-user@jakarta.apache.org, Kar YEOW <ka...@apir.com.au>
> To: tomcat-user@jakarta.apache.org
> Subject: REPOST: java.util.ConcurrentModificationException
>
> I have a util that clear the session data at the beginning of loading a
> page.  I got a ConcurrentModificationException.  These JSPs works fine on
> 3.2.3, is there any changes or dos and don'ts in relation to 'HttpSession'
> in tomcat 4.0 I should pay attention to?  Any help is appreciated.
> Kar
>
>     public static void clearParameters(HttpSession session) {
>         Enumeration e = session.getAttributeNames();
>         while (e.hasMoreElements()) {
>             String attributeName = (String)e.nextElement();
>             session.removeAttribute(attributeName);
>         }
>     }
>

There are *no* guarantees that you can delete items out of the collection
you are enumerating over.  The fact that it worked under 3.2.3 was
happenstance.

The portable way to do this:

    public static void clearParameters(HttpSession session) {
        ArrayList list = new ArrayList();
        Enumeration e = session.getAttributeNames();
        while (e.hasMoreElements())
            list.add(e.nextElement());
        Iterator i = list.iterator();
        while (i.hasNext())
            session.removeAttribute((String) i.next());
    }

Of course, one wonders why you need to do this anyway ... the container
will clear all the session attributes when the session expires.

Craig


REPOST: java.util.ConcurrentModificationException

Posted by Kar YEOW <ka...@apir.com.au>.
I have a util that clear the session data at the beginning of loading a
page.  I got a ConcurrentModificationException.  These JSPs works fine on
3.2.3, is there any changes or dos and don'ts in relation to 'HttpSession'
in tomcat 4.0 I should pay attention to?  Any help is appreciated.
Kar

    public static void clearParameters(HttpSession session) {
        Enumeration e = session.getAttributeNames();
        while (e.hasMoreElements()) {
            String attributeName = (String)e.nextElement();
            session.removeAttribute(attributeName);
        }
    }


java.util.ConcurrentModificationException
 at java.util.HashMap$HashIterator.next(HashMap.java:736)
 at org.apache.catalina.util.Enumerator.nextElement(Unknown Source)
 at au.com.apir.web.FormUtil.clearParameters(FormUtil.java:20)
 at org.apache.jsp.main$jsp._jspService(main$jsp.java:479)
 at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Unknown
Source)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(Unknown Source)
 at org.apache.jasper.servlet.JspServlet.service(Unknown Source)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
Source)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown Source)
 at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
 at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
 at org.apache.catalina.core.StandardContextValve.invoke(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Unknown
Source)
 at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
 at org.apache.catalina.valves.CertificatesValve.invoke(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
 at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
 at org.apache.catalina.core.StandardContext.invoke(Unknown Source)
 at org.apache.catalina.core.StandardHostValve.invoke(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
 at org.apache.catalina.valves.AccessLogValve.invoke(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
 at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
 at org.apache.catalina.core.StandardEngineValve.invoke(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invokeNext(Unknown Source)
 at org.apache.catalina.core.StandardPipeline.invoke(Unknown Source)
 at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
 at org.apache.catalina.connector.http.HttpProcessor.process(Unknown Source)
 at org.apache.catalina.connector.http.HttpProcessor.run(Unknown Source)
 at java.lang.Thread.run(Thread.java:484)


Re: JDBC Problem

Posted by Rasoul Hajikhani <ra...@rhythm.com>.
"Craig R. McClanahan" wrote:
> 
> On Thu, 11 Oct 2001, Rasoul Hajikhani wrote:
> 
> > Date: Thu, 11 Oct 2001 15:02:06 -0700
> > From: Rasoul Hajikhani <ra...@rhythm.com>
> > Reply-To: tomcat-user@jakarta.apache.org
> > To: "tomcat-user@jakarta.apache.org" <to...@jakarta.apache.org>
> > Subject: JDBC Problem
> >
> > Folks,
> > I am using Velocity and Tomcat to generate dynamic content. I have
> > posted this question on Servlets and Velocity user lists and all say the
> > same thing: move the informix driver to :
> > /tomcathome/lib/informixdriver.jar . The problem is that the driver is
> > "there" but I still get this error:
> > Error Connecting: java.sql.SQLException: No suitable driver
> > I have declared the path to the driver within the "CLASSPATH" and as I
> > stop/start tomcat I can see that it is reading from the updated class
> > path. I am not sure what the problem might be since I am a novice
> > Servlets/Velocity/Tomcat user. Any help would be greatly appreciated.
> > Thanks in advance
> > -r
> >
> 
> The details depend on the JDBC driver you are using, but you generally
> need to do something more than just put the JAR file in the right place.
> You might also have to register the driver with DriverManager.  For
> example, to register the Postgres SQL driver, you would say this if the
> driver knows how to regiister itself:
> 
>   Class.forName("org.postgresql.Driver");
> 
> or this if the driver does *not* know how to register itself:
> 
>   DriverManager.registerDriver(new org.postgresql.Driver());
> 
> You should really be looking at the Informix documentation on how to use
> your driver, to know what is actually needed.
> 
> Craig

Thanks Craig,
I figured what the problem was: Class.forName(driver); was missing from
myy code 8( But thanks for your help any ways...
-r

Re: JDBC Problem

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 11 Oct 2001, Rasoul Hajikhani wrote:

> Date: Thu, 11 Oct 2001 15:02:06 -0700
> From: Rasoul Hajikhani <ra...@rhythm.com>
> Reply-To: tomcat-user@jakarta.apache.org
> To: "tomcat-user@jakarta.apache.org" <to...@jakarta.apache.org>
> Subject: JDBC Problem
>
> Folks,
> I am using Velocity and Tomcat to generate dynamic content. I have
> posted this question on Servlets and Velocity user lists and all say the
> same thing: move the informix driver to :
> /tomcathome/lib/informixdriver.jar . The problem is that the driver is
> "there" but I still get this error:
> Error Connecting: java.sql.SQLException: No suitable driver
> I have declared the path to the driver within the "CLASSPATH" and as I
> stop/start tomcat I can see that it is reading from the updated class
> path. I am not sure what the problem might be since I am a novice
> Servlets/Velocity/Tomcat user. Any help would be greatly appreciated.
> Thanks in advance
> -r
>

The details depend on the JDBC driver you are using, but you generally
need to do something more than just put the JAR file in the right place.
You might also have to register the driver with DriverManager.  For
example, to register the Postgres SQL driver, you would say this if the
driver knows how to regiister itself:

  Class.forName("org.postgresql.Driver");

or this if the driver does *not* know how to register itself:

  DriverManager.registerDriver(new org.postgresql.Driver());

You should really be looking at the Informix documentation on how to use
your driver, to know what is actually needed.

Craig