You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sneha Manohar <sn...@yahoo.co.in> on 2009/02/13 00:47:45 UTC

unable to connect to mysql on remote server

Hi ,
I am trying to connect to mysql on remote server using following code 
Class.forName("com.mysql.jdbc.Driver").newInstance();
        
 String connectionURL = "jdbc:mysql://remoteHostIp:3306/test"; 
       
        
 Connection connection = DriverManager.getConnection(connectionURL, "root", "");
 
I get following errorjavax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
	org.apache.jasper.runtime.PageContextImpl.access$1100(PageContextImpl.java:71)
	org.apache.jasper.runtime.PageContextImpl$12.run(PageContextImpl.java:768)
	java.security.AccessController.doPrivileged(Native Method)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:766)
	org.apache.jsp.test_jsp._jspService(test_jsp.java:75)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:616)
	org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
	java.security.AccessController.doPrivileged(Native Method)
	javax.security.auth.Subject.doAsPrivileged(Subject.java:537)
	org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
	org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)



--- On Fri, 13/2/09, Pid <p...@pidster.com> wrote:

From: Pid <p...@pidster.com>
Subject: Re: deploying web application on remote server
To: "Tomcat Users List" <us...@tomcat.apache.org>
Date: Friday, 13 February, 2009, 4:52 AM

Sneha Manohar wrote:
> Hi ,
> Thanks for your reply ,  remote server is on ubuntu Operating system . 
> Version of tomcat - 6
> Version of java - jdk1.6.
>  
> I  try to load driver ""com.mysql.jdbc.Driver" , I have put
"mysql-connector-java-5.1.5-bin" in WEB-INF /lib folder , I get class
not found exception error . 
>  
> I wish to know how tomcat locate libraries . Do I need to add anything in
the path .
> It works on local ,I use net beans , I add the libraries  by clicking
'Add library'-> Global library ->mysql driver. How do I achieve
this on remote server .

You're adding it to the Global libraries for what purpose?

If *Tomcat* needs DB access then the jars go in tomcat/lib.

If *your app* needs DB access then the jars go in WEB-INF/lib, (unless
there's already a copy in tomcat/lib).


p




> sneha
>  
>  
> 
> 
> --- On Thu, 12/2/09, Pid <p...@pidster.com> wrote:
> 
> From: Pid <p...@pidster.com>
> Subject: Re: deploying web application on remote server
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Date: Thursday, 12 February, 2009, 11:57 PM
> 
> Sneha Manohar wrote:
>> Hi ,
>>  
>> I have developed web application using netbeans , I wish to deploy on
> remote server .
>> I have placed files under / webapps  directory of remote server.
Tomcat is
> unable to locate libraries .  how do I make tomcat locate libraries which
are
> under WEB-INF/lib folder
>>  
>> sneha
>>
>>
>>       Connect with friends all over the world. Get Yahoo! India
Messenger
> at http://in.messenger.yahoo.com/?wm=n/
> 
> 
> to the tune of "Humpty Dumpty"
> 
> The Original Poster sent an email
> The Original Poster had a vague FAIL
> All the list members and all of the devs
> Couldn't put Tomcat together again.
> 
> 
> because you didn't tell us what operating system you're using,
what
> version of tomcat, java etc, or what your log error messages said.
> 
> ?
> 
> p
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
>       Unlimited freedom, unlimited storage. Get it now, on
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




      Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/

Re: unable to connect to mysql on remote server

Posted by Gregor Schneider <rc...@googlemail.com>.
Sorry,

should have been

mysql -h YOUR_HOST_HERE -u USER -p

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: unable to connect to mysql on remote server

Posted by Gregor Schneider <rc...@googlemail.com>.
By default, MySQL only listens on localhost.
If you have configured MySQL to listen for remote connections, happy
getting hacked...

However, to solve your issue:

- Make sure you can connect to the remote MySQL from the server where
you're running Tomcat:

mysql -h YOUR_HOST_HERE - u USER -p

If that works, come back here, if not:

Consult your MySQL manual or read it up right here:
http://dev.mysql.com/doc/ or ask your questions in your preferred
MySQL-mailinglist.

Rgds

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org