You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Swart, James (Jim) ** CTR **" <sw...@agere.com> on 2001/10/31 19:19:33 UTC

RE: *** HELP *** mySQL connectivity problems

Does any one know of a good book, tutorial or URL for Java and mySQL
connectivity?  I run Tomcat & mySQL on a RedHat 7.1 server and have used
mySQL to setup a database with a table and a few values so I can have a real
sample to toy with. I put the servlet names in the web.xml file in my
webapp, but I don't know HOW to code the JAVA to talk to it.  

I know this is not 100% tomcat and I apologize for that, is there another
group I can ask if this one is inappropriate?

-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Monday, July 30, 2001 11:39 AM
To: 'tomcat-user@jakarta.apache.org'
Subject: Re: *** HELP *** mySQL connectivity problems


On Mon, 30 Jul 2001, SIMONIN Alexandre wrote:

> Hi,
> 
> I'm running mySQL 2.0.4 and Tomcat 4.0 on Cobalt/Linux. 
> 

Are you running Tomcat 4 with a security manager (i.e.
"$CATALINA_HOME/bin/catalina.sh start -security")?  That seems likely,
given the fact that you're gatting a security manager exception.

If so, you need to grant your JDBC driver permission to create a network
connection to port 3306 on your database host.  This is done in the
"conf/catalina.policy" file.  There are some notes near the bottom of that
file documenting the way that you add this permission.

Craig McClanahan


> When trying to get a connection to the database, I got the following error
> (the code is provided below - exact id and password replaced for
> confidentiality).
> 
> Step 1 : Class.forName("org.gjt.mm.mysql.Driver"); OK
> Step 2 :
>
getConnection("jdbc:mysql://sherweb7.sherweb.com:3306/myDatabase?user=myID&p
> assword=myPwd"); *** FAILURE ***
>      SQLException: Cannot connect to MySQL server on
> sherweb7.sherweb.com:3306. Is there a MySQL server running on the
> machine/port you are
>      trying to connect to? (java.security.AccessControlException)
>      SQLState: 08S01
>      VendorError: 0
> 
> Few comments:
> 1/ the mySQL server's site address is OK (not the localhost)
> 2/ the mySQL server's port is OK
> 3/ the table name is OK
> 4/ the userID is OK
> 5/ the password is OK
> 6/ the connection looks fine through phpMyAdmin
> 7/ I get the same java.security.AccessControlException when doing the same
> request without the userID and password
> 6/ I got a java.net.ConnectException (which seems normal to me) when
trying
> to call the server as if it was local to my machine, i.e.:
> jdbc:mysql:///myDatabase?user=myID&password=myPwd
> 
> Any suggestion?
> 
> The code:
> 
>     try {
>       Class.forName("org.gjt.mm.mysql.Driver");   // this or <the
> same>.newInstance() does the same
>       System.out.println("Step1:
Class.forName(\"org.gjt.mm.mysql.Driver\"):
> OK");
>     }
>     catch (Exception e) {
>       System.out.println("Class.forName(\"org.gjt.mm.mysql.Driver\"): ***
> FAILURE ***");
>     }
> 
>     Connection myConn = null;
> 
>     try {
>       myConn =
>
DriverManager.getConnection("jdbc:mysql://sherweb7.sherweb.com:3306/myDataba
> se?user=myID&password=myPwd");
>       System.out.println("Step 2:
>
getConnection(\"jdbc:mysql://sherweb7.sherweb.com:3306/myDatabase?user=myID&
> password=myPwd\"): OK");
>     }
>     catch (SQLException e) {
>       System.out.println("Step 2:
>
getConnection(\"jdbc:mysql://sherweb7.sherweb.com:3306/myDatabase?user=myID&
> password=myPwd\"): *** FAILURE ***");
>      System.out.println(" SQLException: "+e.getMessage());
>      System.out.println(" SQLState: "+e.getSQLState());
>      System.out.println(" VendorError: "+e.getErrorCode());
>     }
> 
> 
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: *** HELP *** mySQL connectivity problems

Posted by Timothy Fisher <tr...@yahoo.com>.
You might consider the book titled:
"JSP, Servlets, and MySQL" by David Harms.

It seems like a pretty descent book.

Tim

--- "Swart, James (Jim) ** CTR **" <sw...@agere.com>
wrote:
> Does any one know of a good book, tutorial or URL
> for Java and mySQL
> connectivity?  I run Tomcat & mySQL on a RedHat 7.1
> server and have used
> mySQL to setup a database with a table and a few
> values so I can have a real
> sample to toy with. I put the servlet names in the
> web.xml file in my
> webapp, but I don't know HOW to code the JAVA to
> talk to it.  
> 
> I know this is not 100% tomcat and I apologize for
> that, is there another
> group I can ask if this one is inappropriate?
> 
> -----Original Message-----
> From: Craig R. McClanahan
> [mailto:craigmcc@apache.org]
> Sent: Monday, July 30, 2001 11:39 AM
> To: 'tomcat-user@jakarta.apache.org'
> Subject: Re: *** HELP *** mySQL connectivity
> problems
> 
> 
> On Mon, 30 Jul 2001, SIMONIN Alexandre wrote:
> 
> > Hi,
> > 
> > I'm running mySQL 2.0.4 and Tomcat 4.0 on
> Cobalt/Linux. 
> > 
> 
> Are you running Tomcat 4 with a security manager
> (i.e.
> "$CATALINA_HOME/bin/catalina.sh start -security")? 
> That seems likely,
> given the fact that you're gatting a security
> manager exception.
> 
> If so, you need to grant your JDBC driver permission
> to create a network
> connection to port 3306 on your database host.  This
> is done in the
> "conf/catalina.policy" file.  There are some notes
> near the bottom of that
> file documenting the way that you add this
> permission.
> 
> Craig McClanahan
> 
> 
> > When trying to get a connection to the database, I
> got the following error
> > (the code is provided below - exact id and
> password replaced for
> > confidentiality).
> > 
> > Step 1 : Class.forName("org.gjt.mm.mysql.Driver");
> OK
> > Step 2 :
> >
>
getConnection("jdbc:mysql://sherweb7.sherweb.com:3306/myDatabase?user=myID&p
> > assword=myPwd"); *** FAILURE ***
> >      SQLException: Cannot connect to MySQL server
> on
> > sherweb7.sherweb.com:3306. Is there a MySQL server
> running on the
> > machine/port you are
> >      trying to connect to?
> (java.security.AccessControlException)
> >      SQLState: 08S01
> >      VendorError: 0
> > 
> > Few comments:
> > 1/ the mySQL server's site address is OK (not the
> localhost)
> > 2/ the mySQL server's port is OK
> > 3/ the table name is OK
> > 4/ the userID is OK
> > 5/ the password is OK
> > 6/ the connection looks fine through phpMyAdmin
> > 7/ I get the same
> java.security.AccessControlException when doing the
> same
> > request without the userID and password
> > 6/ I got a java.net.ConnectException (which seems
> normal to me) when
> trying
> > to call the server as if it was local to my
> machine, i.e.:
> > jdbc:mysql:///myDatabase?user=myID&password=myPwd
> > 
> > Any suggestion?
> > 
> > The code:
> > 
> >     try {
> >       Class.forName("org.gjt.mm.mysql.Driver");  
> // this or <the
> > same>.newInstance() does the same
> >       System.out.println("Step1:
> Class.forName(\"org.gjt.mm.mysql.Driver\"):
> > OK");
> >     }
> >     catch (Exception e) {
> >      
>
System.out.println("Class.forName(\"org.gjt.mm.mysql.Driver\"):
> ***
> > FAILURE ***");
> >     }
> > 
> >     Connection myConn = null;
> > 
> >     try {
> >       myConn =
> >
>
DriverManager.getConnection("jdbc:mysql://sherweb7.sherweb.com:3306/myDataba
> > se?user=myID&password=myPwd");
> >       System.out.println("Step 2:
> >
>
getConnection(\"jdbc:mysql://sherweb7.sherweb.com:3306/myDatabase?user=myID&
> > password=myPwd\"): OK");
> >     }
> >     catch (SQLException e) {
> >       System.out.println("Step 2:
> >
>
getConnection(\"jdbc:mysql://sherweb7.sherweb.com:3306/myDatabase?user=myID&
> > password=myPwd\"): *** FAILURE ***");
> >      System.out.println(" SQLException:
> "+e.getMessage());
> >      System.out.println(" SQLState:
> "+e.getSQLState());
> >      System.out.println(" VendorError:
> "+e.getErrorCode());
> >     }
> > 
> > 
> > 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>