Keg,

Don't see anything at this point.

Post the context section for this app.

Doug
----- Original Message ----- 
From: "Keg" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Saturday, May 08, 2004 9:47 PM
Subject: Re: Help with Simple JDBC Connection (sry, kinda long)


> Parsons Technical Services wrote:
> > Keg,
> >
> > Link entry in the context for the app.
> >
> > If not then post it and the code snip that you are using in the jsp.
> >
> > Doug
> > www.parsonstechnical.com
> > ----- Original Message ----- 
> > From: "Keg" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, May 08, 2004 6:22 PM
> > Subject: Help with Simple JDBC Connection (sry, kinda long)
> >
> >
> >
> >>I am trying to connect to a local mysql database from a jsp page. I can
> >>see the datasource defined in the Admin app, however, when I drill down
> >>into the datasources under my webapp, I get this error:
> >>
> >>javax.servlet.ServletException: Exception retrieving attribute
> >>
> >
> >
'driverClassName'org.apache.jasper.runtime.PageContextImpl.doHandlePageExcep
> > tion(PageContextImpl.java:867)
> >
> >
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
> > l.java:800)
> >
> >
admin.resources.listDataSources_jsp._jspService(listDataSources_jsp.java:431
> > )
> >
> >><SNIP>
> >>
> >>I have the following server.xml file:
> >><?xml version='1.0' encoding='utf-8'?>
> >><Server>
> >>   <Listener
> >>className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
> >>   <Listener
>
>>className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
> >>   <GlobalNamingResources>
> >>     <Environment name="simpleValue" type="java.lang.Integer"
value="30"/>
> >>     <Resource auth="Container" description="User database that can be
> >>updated and saved" name="UserDatabase"
> >>type="org.apache.catalina.UserDatabase"/>
> >>     <Resource name="mysql-dev1" type="javax.sql.DataSource"/>
> >>     <ResourceParams name="UserDatabase">
> >>       <parameter>
> >>         <name>factory</name>
> >>
> > <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
> >
> >>       </parameter>
> >>       <parameter>
> >>         <name>pathname</name>
> >>         <value>conf/.__users.xml</value>
> >>       </parameter>
> >>     </ResourceParams>
> >>     <ResourceParams name="mysql-dev1">
> >>       <parameter>
> >>         <name>factory</name>
> >>         <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>maxActive</name>
> >>         <value>100</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>maxIdle</name>
> >>         <value>10</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>maxWait</name>
> >>         <value>10000</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>username</name>
> >>         <value>tomcat5</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>password</name>
> >>         <value>!tomcat5!</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>driverClassName</name>
> >>         <value>org.gjt.mm.mysql.Driver</value>
> >>       </parameter>
> >>       <parameter>
> >>         <name>url</name>
> >>
> >><value>jdbc:mysql://localhost:3306/tomcat5?autoReconnect=true</value>
> >>       </parameter>
> >>     </ResourceParams>
> >>   </GlobalNamingResources>
> >>   <Service name="Catalina">
> >>     <Connector acceptCount="100" connectionTimeout="20000"
> >>disableUploadTimeout="true" port="8080" redirectPort="8443">
> >>     </Connector>
> >>     <Connector port="8009" protocol="AJP/1.3"
> >>protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
> >>redirectPort="8443">
> >>     </Connector>
> >>     <Engine defaultHost="localhost" name="Catalina">
> >>       <Host appBase="webapps" name="localhost">
> >>         <Logger className="org.apache.catalina.logger.FileLogger"
> >>prefix="localhost_" timestamp="true"/>
> >>         <Valve className="org.apache.catalina.valves.AccessLogValve"
> >>fileDateFormat="yyyy-MM-dd" prefix="localhost_access_" suffix=".log"/>
> >>       </Host>
> >>       <Logger className="org.apache.catalina.logger.FileLogger"
> >>prefix="catalina_" timestamp="true"/>
> >>       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
> >>     </Engine>
> >>   </Service>
> >></Server>
> >>
> >>
> >
****************************************************************************
> >
> >>Here is the webapps/dev1/WEB-INF/web.xml file:
> >>
> >><?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>
> >>   <display-name>Dev1 - Test App</display-name>
> >>   <description>
> >>      Development application: DEV1
> >>   </description>
> >>
> >>   <resource-ref>
> >>       <description>mysql-dev1 JDBC Connection</description>
> >>       <res-ref-name>mysql-dev1</res-ref-name>
> >>       <res-type>javax.sql.DataSource</res-type>
> >>       <res-auth>Container</res-auth>
> >>   </resource-ref>
> >>
> >></web-app>
> >>
> >
****************************************************************************
> > *
> >
> >>I'm sure it's something stupid I missed.
> >>
> >>Thx for any help,
> >>keg
> >>
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> Here is the webapps/dev1/index.jsp file"
>
> <html>
>    <[EMAIL PROTECTED]  import="dev1.*" %>
>    <head>
>      <title>DB Test</title>
>    </head>
>    <body>
>
>    <%
>      dev1.DBTest tst = new dev1.DBTest();
>      tst.init();
>    %>
>
>    <h2>Results</h2>
>      Foo <%= tst.getFoo() %><br/>
>      Bar <%= tst.getBar() %>
>
>    </body>
> </html>
>
> Here is the class file webapps/dev1/WEB-INF/classes/dev1/DBTest.class
>
> package dev1;
>
> import javax.naming.*;
> import javax.sql.*;
> import java.sql.*;
>
> public class DBTest {
>
>    String foo = "Not Connected";
>    int bar = -1;
>
>    public void init() {
>      try{
>        Context ctx = new InitialContext();
>        if(ctx == null )
>            throw new Exception("Boom - No Context");
>
>        DataSource ds = (DataSource)ctx.lookup("java:comp/env/mysql-dev1");
>
>        if (ds == null) {
> System.err.println("ERROR: datasource lookup failed.");
>        }
>        if (ds != null) {
>          Connection conn = ds.getConnection();
>
>          if(conn != null)  {
>              foo = "Got Connection "+conn.toString();
>              Statement stmt = conn.createStatement();
>              ResultSet rst =
>                  stmt.executeQuery(
>                    "select test_id, test_name, test_age from test1");
>              if(rst.next()) {
>                 foo=rst.getString(2);
>                 bar=rst.getInt(3);
>              }
>              conn.close();
>          }
>        }
>      }catch(Exception e) {
>        e.printStackTrace();
>      }
>   }
>
>   public String getFoo() { return foo; }
>   public int getBar() { return bar;}
> }
>
> These are the examples from the tomcat docs, I am merely just trying to
> get familiar with the server layout and stuff....
>
>
> -keg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to