username/password  --> are right, I checked with MySQL-Front :-)
driver --> is right and in the directory (mm.mysql-2.0.14-bin.jar)
drivername -->
<parameter><name>driverClassName</name><value>org.gjt.mm.mysql.Driver</value
></parameter>



-----Original Message-----
From: Short, Dave [mailto:dave.short@;pfizer.com]
Sent: Freitag, 25. Oktober 2002 18:07
To: 'Tomcat Users List'
Subject: RE: JNDI Datasource is null, again


In the past, I've found that I received this type of exception when any of
my connection parameters were wrong (username/password, driver name , etc.).
I'd suggest you review connection parameters carefully to make sure that
isn't the problem.

You do have your JDBC diver class jar file loaded in your tomcat\common\lib
directory, correct?

-----Original Message-----
From: "Steltner, Jörn HTC/DE/ESS" [mailto:Joern.Steltner@;hochtief.de]
Sent: October 25, 2002 9:00 AM
To: 'Tomcat Users List'
Subject: RE: JNDI Datasource is null, again


sorry, doesn't work!

-----Original Message-----
From: Short, Dave [mailto:dave.short@;pfizer.com]
Sent: Freitag, 25. Oktober 2002 17:56
To: 'Tomcat Users List'
Subject: RE: JNDI Datasource is null, again


I noticed you have the following code in your server.xml file within your
w2k context:

<Resource name="jdbc/w2k" auth="Container" type="javax.sql.DataSource"/>

I don't have this in mine.  Not sure if it's needed.  I can connect just
fine without it.  Take it out and see if it works.

-----Original Message-----
From: "Steltner, Jörn HTC/DE/ESS" [mailto:Joern.Steltner@;hochtief.de]
Sent: October 25, 2002 8:38 AM
To: '[EMAIL PROTECTED]'
Subject: JNDI Datasource is null, again


Hallo,

I read that the problem was described many times here, but I cecked all
solutions and got the error again. Please may someone give me a hint.
Attached my config and the exception print. I don't know where I should look
...

I use Tomcat 4.1.12 and J2SDK 1.4.1_01.


my code:

/*
 * dbGetInvoices.java
 *
 * Created on 12. August 2002, 15:14
 */
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.text.*;
/**
 *
 * @author  steltner
 * @version
 */


public class dbGetInvoices extends HttpServlet {

    public void init(ServletConfig config) throws ServletException 
    {
        super.init(config);
    }
    
    /** Destroys the servlet.
     */
    public void destroy() {
    }
    
    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "dbGetInvoices";
    }

    /** Processes requests for both HTTP <code>GET</code> and
<code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     */
    protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, java.io.IOException {
        response.setContentType("text/html");
        java.io.PrintWriter out = response.getWriter();
        out.close();
    }
    
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse
response)
    throws ServletException, java.io.IOException 
    {
       PrintWriter out     = response.getWriter();
       HttpSession session = request.getSession(true);
       
       String  no_user = (String)session.getAttribute("logon.isUserNo");
       String  no_role = (String)session.getAttribute("logon.isRole");
      
       if ((null == no_user) || (null == no_role))
       {
          out.println("<p><strong>Sie sind zur Zeit nicht angemeldet!");
       }
       else
       {
           // wenn Projektteam Mitglied
           if ( 0 == no_role.compareTo("3"))
               GetInvoices( out, no_user );
       }
       out.println("</body></html>");
    }
    
    protected void doPost(HttpServletRequest request, HttpServletResponse
response)
    throws ServletException, java.io.IOException {
        processRequest(request, response);
    }

    protected void GetInvoices( PrintWriter out, String no_user )
    {
       ....................
       GetInvoiceContents(out,no_user);
       ......................
    }
    
    protected void GetInvoiceContents( PrintWriter out, String no_user )
    {
       try
       {
          Context initCtx = new InitialContext();
          DataSource ds =
(DataSource)initCtx.lookup("java:comp/env/jdbc/w2k");


          // at this point ds is equal null :-(( 

          if (null != ds) 
          {
             Connection conn = ds.getConnection();
              
             if (null != conn)  
             {
                 Statement st = conn.createStatement();
                 ResultSet rs = st.executeQuery("select description from
price_comparison where no_price_comparison=1");
       
                 String    s  = "<tr bgcolor=#f0f0f0>";
                 int       i  = 0;
                 double    d  = 0.0;

                 // number formating
                 Locale       myLocale    = new Locale("de", "Germany");
                 NumberFormat myFormatter =
NumberFormat.getNumberInstance(myLocale);
                 myFormatter.setGroupingUsed( true );
                 myFormatter.setMinimumFractionDigits(2);
                 myFormatter.setMaximumFractionDigits(2);

                 while (rs.next())
                 {
                     // do something
                 } 
                     
                 st.close();                  
                 conn.close();
             }
          }
          
       }
       catch(Exception e) {
            e.printStackTrace();
       }
       
    }
          
}
    


my server.xml

        <!-- Tomcat w2k Context -->
        <Context path="" docBase="w2k" debug="9" reloadable="true"
crossContext="true">
          <Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_w2k_log." suffix=".txt" timestamp="true"/>
          <Resource name="jdbc/w2k" auth="Container"
type="javax.sql.DataSource"/>

          <ResourceParams name="jdbc/w2k">
           <parameter>
             <name>factory</name>
             <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
           </parameter>

           <!-- Maximum number of dB connections in pool. Make sure you
                configure your mysqld max_connections large enough to handle
                all of your db connections. Set to 0 for no limit.
           -->
           <parameter>
             <name>maxActive</name>
             <value>100</value>
           </parameter>

           <!-- Maximum number of idle dB connections to retain in pool.
                Set to 0 for no limit.
           -->
           <parameter>
             <name>maxIdle</name>
             <value>30</value>
           </parameter>

           <!-- Maximum time to wait for a dB connection to become available
                in ms, in this example 10 seconds. An Exception is thrown if
                this timeout is exceeded.  Set to -1 to wait indefinitely.
           -->
           <parameter>
             <name>maxWait</name>
             <value>10000</value>
           </parameter>

           <!-- MySQL dB username and password for dB connections  -->
           <parameter>
             <name>username</name>
             <value>web</value>
           </parameter>
           <parameter>
             <name>password</name>
             <value>access</value>
           </parameter>

           <!-- Class name for mm.mysql JDBC driver -->
           <parameter>
             <name>driverClassName</name>
             <value>org.gjt.mm.mysql.Driver</value>
           </parameter>

           <!-- The JDBC connection url for connecting to your MySQL dB.
                The autoReconnect=true argument to the url makes sure that
the
                mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
                connection.  mysqld by default closes idle connections after
8 hours.
           -->
           <parameter>
             <name>url</name>
 
<value>jdbc:mysql://localhost:3306/w2k?autoReconnect=true</value>
           </parameter>
    
           <parameter>
             <name>removeAbandoned</name>
             <value>true</value>
           </parameter>

           <parameter>
             <name>removeAbandonedTimeout</name>
             <value>60</value>
           </parameter>

           <parameter>
             <name>logAbandoned</name>
             <value>true</value>
           </parameter>
          </ResourceParams>
        </Context>



my web.xml

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app>
  <display-name>w2k-Projektdokumentation</display-name>
  <description>w2k-Projektdokumentation</description>
  <context-param>
    <param-name>J. Steltner</param-name>
    <param-value>[EMAIL PROTECTED]</param-value>
    <description>
      Please send a mail.
    </description>
  </context-param>


  <servlet>
    <servlet-name>dbGetInvoices</servlet-name>
    <description>Print table with all invoices.</description>
    <servlet-class>dbGetInvoices</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>dbGetInvoices</servlet-name>
    <url-pattern>/dbGetInvoices</url-pattern>
  </servlet-mapping>

  <session-config>
     <session-timeout>30</session-timeout>
  </session-config>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
  
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/w2k</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>

</web-app>


my catalina.out:

java.sql.SQLException: Cannot load JDBC driver class 'null'
        at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav
a:529)
        at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:3
12)
        at dbGetInvoices.GetInvoiceContents(dbGetInvoices.java:149)
        at dbGetInvoices.GetInvoices(dbGetInvoices.java:127)
        at dbGetInvoices.doGet(dbGetInvoices.java:71)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:260)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:170)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:380)
        at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:533)
        at java.lang.Thread.run(Thread.java:536)



Regards Joern




--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>

Reply via email to