I'm using Linux, not OSX, so there will likely be differences, but shouldn't
be too much as OSX is Mach/BSD based.

I'm using connection pooling, so I've got commons-collections.jar,
commons-dbcp.jar, commons-pool.jar as well as mm.mysql-2.0.14-bin.jar
in $CATALINA_HOME/common/lib.

I connect to a datasource with the following code ...

   public Connection getConn (String appl)
      throws SQLException {
      DataSource datasource = null;
      try {
         Context initialcontext = new InitialContext();
         datasource =
(DataSource)initialcontext.lookup("java:comp/env/jdbc/" + appl);
      }
      catch (NamingException e) {
        throw new SQLException(e.getMessage());

      }
      try {
         conn = datasource.getConnection();
      }
      catch (SQLException e) {
         throw new SQLException(newMsg, e.getSQLState(), e.getErrorCode());
      }
      return (conn);
   }

My context for my app is ...


<Context path="/site" docBase="site" debug="0" reloadable="true">

      <Logger className="org.apache.catalina.logger.FileLogger"
              prefix="site." suffix=".log"
              timestamp="true"/>

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

      <ResourceParams name="jdbc/thought">
         <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
         <parameter>
            <name>username</name>
            <value>root</value>
         </parameter>
         <parameter>
            <name>password</name>
            <value>admin</value>
         </parameter>
         <parameter>

<name>driverClassName</name><value>org.gjt.mm.mysql.Driver</value>
         </parameter>
         <parameter>

<name>url</name><value>jdbc:mysql://10.0.0.4:3306/thought</value>
         </parameter>
      </ResourceParams>
</Context>

My database name is "thought", my username is "root" and my password is
"admin".
Substitute your own as required.

The appropriate section of my web.xml file is ...

  <resource-ref>
    <res-ref-name>jdbc/thought</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

I'm not a MySQL expert.  Your grant statement looks funny to me because
I'm not used to seeing the /* syntax.  Not saying it's wrong.  For all
of my MySQL questions I go to the New Riders book, MySQL, by Paul Dubois.

That's about all I can tell you other than my app's been running under
both Weblogic and HPAS for the last 9 months.  I finally got it going
under Tomcat this weekend using the info above.  Now if I can just figure
out how to front end Tomcat with Apache I'll be done with it.

Good luck
Steve


-----Original Message-----
From: Jack Park [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 07, 2002 8:09 PM
To: Tomcat Users List
Subject: RE: Mac OS X, Tomcat 4.0.4, MySql "configuration denies access"


Thank you!

I just upgraded to 2.0.14 with no change in behavior.

I suppose I am a bit confused, and perhaps a bit of detail on what I have
done might help.

I open mysql with
DriverManager.getConnection("jdbc:mysql:///mydatabase","nexw","")
where nexw is the username and there is no password.

I have already used two different grants:
         grant all privileges on mydatabase/* to nexw@localhost;         <a
guess because the next try didn't work
         grant all privileges on mydatabase/* to
[EMAIL PROTECTED]  <which works on wintel and linux

server.xml has this context for the program:
         <Context
                 path="/wiki"
                 docBase="wiki"
                 reloadable="true"
                 debug="0"
                 trusted="false" >
         </Context>
I am not aware of anything else I need to tell tomcat, particularly since
that context statement works on both WinME and Linux, and this is OS X.

Among the things I have tried is to create a Mac User called "nexw", with
no password and no root privileges.  Perhaps OS X requires that, which
means this my problem is less a tomcat problem and more a Darwin-user
(ignorance) problem.

Looking at mysql:user and mysql:db, nexw is clearly a registered (with
mysql) user with granted privileges, for both localhost and for
localhost.localdomain.

That summarizes the problem, thus far. Maybe that will animate more ideas.

Thanks again.
Jack

At 05:46 PM 7/7/2002 -0600, you wrote:
>2.0.8 is a very old driver.  The current version is 2.0.14
>
>I don't know how you granted permissions, but do something like ...
>
>(assuming root for username and admin for password) ...
>
>start mysql, then
>grant all on *.* to [EMAIL PROTECTED] identified by "admin";
>
>Then "use mysql" and select * on user, make sure your grant took
>effect.
>
>If everything looks cool and it still doesn't work, check that your
>server.xml is configured correctly for your context and datasource.


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





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

Reply via email to