tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quest Software" <supp...@quest.com>
Subject Auto-Confirmation
Date Fri, 22 Aug 2003 16:09:39 GMT
Thank you for submitting your request to Quest Software Technical Support.  We are unable to
process your request because our records indicate that you are not registered for Technical
Support.

To register, logon to our Supportlink web site http://www.quest.com/support , and  self-register
from the web.  Or, you can phone Quest at one of the numbers below to register.

Once you have registered, you can submit your request within Supportlink, by email at support@quest.com,
by phone at one of the numbers below.

Please do not reply to this email.

If this is an URGENT matter please contact Quest Technical Support via telephone at one of
the numbers listed below.

Thank you,

Quest Software Technical Support
www.quest.com/support

Quest Software Technical Support - Canada               902.442.5700
Quest Software Technical Support - United Kingdom  44.1628.601007
Quest Software Technical Support - United States      949.754.8000
>  --------------------Original Message--------------------
>  From: "Robert S. Jones" [mailto:rjones@salientsystems.com]
>  Sent: 22 Aug 2003 10:31:48 -0400
>  To: Tomcat Users List [tomcat-user@jakarta.apache.org]
>  Subject: RE: Problem connecting to mysql database with Tomcat and JNDI
>  
>  Well Folks, the law of, "the longer a problem takes to resolve, the
>  dumber the mistake" has held true once again.  It turns out that I had
>  my <Context> definition in the wrong place in the server.xml file.  I'm
>  aggravated, but glad to have the problem solved.
>  
>  Thanks Scott for your suggestions.  I should have posted the whole
>  server.xml file.  That probably would have made the problem obvious to
>  folks more experienced than me.
>  
>  Rob
>  
>  On Fri, 2003-08-22 at 09:00, Robert S. Jones wrote:
>  > Ok, I tried that.  Same results.  Here is my new <Context> definition.
>  > 
>  > <Context path="/db-test" docBase="db-test" debug="0" reloadable="true">
>  >   <Resource name="jdbc/address" auth="Container"
>  > type="javax.sql.DataSource"/>
>  >   <ResourceParams name="jdbc/address">
>  >     <parameter>
>  >       <name>username</name>
>  >       <value>username</value>
>  >     </parameter>
>  >     <parameter>
>  >       <name>password</name>
>  >       <value>password</value>
>  >     </parameter>
>  >     <parameter>
>  >       <name>url</name>
>  >       <value>jdbc:mysql://localhost:3306/ADDRESS</value>
>  >     </parameter>
>  >     <parameter>
>  >       <name>driverClassName</name>
>  >       <value>com.mysql.jdbc.Driver</value>
>  >     </parameter>
>  >   </ResourceParams>
>  > </Context>
>  > 
>  > Thanks,
>  > Rob
>  > 
>  > 
>  > On Fri, 2003-08-22 at 07:09, Scott Stewart wrote:
>  > > Well, looking at your <Context> definition, I'm not seeing the following
>  > > required element:
>  > > 
>  > >     <Resource name="jdbc/address" 
>  > >               auth="Container" 
>  > >               type="javax.sql.DataSource" />
>  > > 
>  > > Thanks,
>  > > 
>  > > Scott Stewart
>  > > [Manager, Software Development]
>  > > SStewart@csky.com
>  > > 
>  > > ClearSky Mobile Media, Inc.
>  > > 56 E. Pine Street  Suite 200
>  > > Orlando, FL  32801
>  > > USA
>  > > 
>  > > 
>  > > 
>  > > 
>  > > 
>  > > -----Original Message-----
>  > > From: Robert S. Jones [mailto:rjones@salientsystems.com]
>  > > Sent: Thursday, August 21, 2003 5:35 PM
>  > > To: tomcat-user@jakarta.apache.org
>  > > Subject: Problem connecting to mysql database with Tomcat and JNDI
>  > > 
>  > > 
>  > > Folks, 
>  > > 
>  > > I'm having trouble connecting to a mysql database through Tomcat.  I'm
>  > > using Tomcat 5.0.9a with mysql 4.0.14.  I have the mysql 3.0.8 JDBC
>  > > driver in ${TOMCAT_HOME}/common/lib.  I'm running RedHat 8.0 with a
>  > > stock kernel. 
>  > > 
>  > > I've been able to connect to the database without JNDI services.  I
>  > > believe I have the database user set up correctly.  I have been all over
>  > > the web trying to figure out what the problem is.  It seems like
>  > > everyone is having this problem, but no two solutions are the same.
>  > > 
>  > > FWIW I've tried a lot of this on Tomcat 4 and have had the same results.
>  > > 
>  > > I've traced the problem to the following code from the JSP file below:
>  > > 
>  > > conn = ds.getConnection();
>  > > 
>  > > Any thoughts/ideas would be greatly appreciated.  I'm at the end of my
>  > > rope on this.
>  > > 
>  > > Here is the error message I'm getting. 
>  > > 
>  > > java.lang.NullPointerException 
>  > > org.apache.jsp.usingDataSource_jsp._jspService(usingDataSource_jsp.java:74)

>  > > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136) 
>  > > javax.servlet.http.HttpServlet.service(HttpServlet.java:856) 
>  > > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
>  > > 20) 
>  > > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
>  > > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240) 
>  > > javax.servlet.http.HttpServlet.service(HttpServlet.java:856) 
>  > > 
>  > > Here is the JSP page I'm using: 
>  > > 
>  > > <%@page import="java.sql.*, javax.sql.*, javax.naming.*"%>
>  > > <html>
>  > > <head>
>  > > <title>Using a DataSource</title>
>  > > </head>
>  > > <body>
>  > > <h1>Using a DataSource</h1>
>  > > <%
>  > > DataSource ds = null;
>  > > Connection conn = null;
>  > > ResultSet result = null;
>  > > Statement stmt = null;
>  > > ResultSetMetaData rsmd = null;
>  > > 
>  > > try {
>  > >     Context context = new InitialContext();
>  > >     Context envCtx = (Context) context.lookup("java:comp/env");
>  > >     ds = (DataSource)envCtx.lookup("jdbc/address");
>  > >     if (ds != null) {
>  > >         conn = ds.getConnection();
>  > >         stmt = conn.createStatement();
>  > >         result = stmt.executeQuery("SELECT * FROM AddressList");
>  > >     }
>  > > }
>  > > catch (SQLException e) {
>  > >     System.out.println("Error occurred " + e);
>  > > }
>  > > int columns = 0;
>  > > try {
>  > >     rsmd = result.getMetaData(); // bad line
>  > >     columns = rsmd.getColumnCount();
>  > > }
>  > > catch (SQLException e) {
>  > >     System.out.println("Error occurred " + e);
>  > > }
>  > > %>
>  > > <table width="90%" border="1">
>  > > <tr>
>  > > <% // write out the header cells containing the column labels
>  > >     try {
>  > >         for (int i = 1; i <= columns; i++) {
>  > >             out.write("<th>" + rsmd.getColumnLabel(i) + "</th>");
>  > >         }
>  > > %>
>  > > </tr>
>  > > <% // now write out one row for each entry in the database table
>  > >         while (result.next()) {
>  > >             out.write("<tr>");
>  > >             for (int i = 1; i <= columns; i++) {
>  > >                 out.write("<td>" + result.getString(i) + "</td>");
>  > >             }
>  > >             out.write("</tr>");
>  > >         }
>  > > 
>  > >         // close the connection, resultset, and the statement
>  > >         result.close();
>  > >         stmt.close();
>  > >         conn.close();
>  > >     } // end of the try block
>  > > catch (SQLException e) {
>  > >     System.out.println("Error " + e);
>  > > }
>  > > // ensure everything is closed
>  > > finally {
>  > >     try {
>  > >         if (stmt != null) {
>  > >             stmt.close();
>  > >         }
>  > >     } catch (SQLException e) {}
>  > >     try {
>  > >         if (conn != null) {
>  > >             conn.close();
>  > >         }
>  > >     } catch (SQLException e ) {}
>  > > }
>  > > %>
>  > > 
>  > > </table>
>  > > </body>
>  > > </html>
>  > > 
>  > > 
>  > > Here are the changes I made to my server.xml file.  Of course, I've
>  > > changed the username/password entries here. 
>  > > 
>  > > <Context path="/db-test" docBase="db-test" debug="0" reloadable="true">

>  > >   <ResourceParams name="jdbc/address"> 
>  > >     <parameter> 
>  > >       <name>username</name> 
>  > >       <value>username</value> 
>  > >     </parameter> 
>  > >     <parameter> 
>  > >       <name>password</name> 
>  > >       <value>password</value> 
>  > >     </parameter> 
>  > >     <parameter> 
>  > >       <name>url</name> 
>  > >       <value>jdbc:mysql://localhost:3306/ADDRESS</value> 
>  > >     </parameter> 
>  > >     <parameter> 
>  > >       <name>driverClassName</name> 
>  > >       <value>com.mysql.jdbc.Driver</value> 
>  > >     </parameter> 
>  > >   </ResourceParams> 
>  > > </Context> 
>  > > 
>  > > Here is the web.xml file I am using in my WEB-INF directory. 
>  > > 
>  > > <?xml version="1.0" encoding="ISO-8859-1"?> 
>  > >     <!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> 
>  > >   <resource-ref> 
>  > >       <res-ref-name>jdbc/address</res-ref-name> 
>  > >       <res-type>javax.sql.DataSource</res-type> 
>  > >       <res-auth>Container</res-auth> 
>  > >   </resource-ref> 
>  > > </web-app> 
>  > > 
>  > > Rob
>  > > 
>  > > 
>  > > 
>  > > 
>  > > 
>  > > ---------------------------------------------------------------------
>  > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>  > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  > > 
>  > > ---------------------------------------------------------------------
>  > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>  > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  > > 
>  > > 
>  > 
>  > 
>  > 
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  > 
>  > 
>  
>  
>  
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  
Mime
View raw message