<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I installed 8.10 server and installed the LAMP Server and the Tomcat Web Application Server. All necessary components seem to be installed and configured fine. I can log into mysql server via the terminal and I can run access the tomcat mangager web console as well as run servlets and JSPs. The only thing that I can not get to work is connecting to MySQL databases via Tomcat web applications.</div><div><br></div><div>I'm trying to open the database connection using the following code. I have tried using localhost, 127.0.0.1, localhost:3306, 127.0.0.1:3306 and the results are the same. I've also tried using the overloaded version of the getConnection method that takes the username and password as separate parameters and still the same results.</div><div><br></div><div>Class.forName("com.mysql.jdbc.Driver");</div><div>Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/inventory?user=invuser&password=pass");</div><div><br></div><div>I receive the following exception when the second line above is executed.</div><div><pre><font class="Apple-style-span" face="Helvetica">com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
<span class="Apple-tab-span" style="white-space:pre"> </span><a href="http://web.db.DatabaseBean.createDatabase">web.db.DatabaseBean.createDatabase</a>(DatabaseBean.java:115)
        <a href="http://web.db.DatabaseBean.install">web.db.DatabaseBean.install</a>(DatabaseBean.java:89)
        org.apache.jsp.install_jsp._jspService(install_jsp.java:89)
        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)</font></pre></div><div><br></div><div>I receive the exact same exception in OS X when I forget to start the MySQL Server (i have not configure it to start automatically). However, it doesn't seem like that's the problem on my Ubuntu server. I have checked the my.cnf and verified that "bind-address=127.0.0.1" and that the port it was running on was 3306. From what I can tell MySQL is up and running. </div><div><br></div><div>Details:</div><div>Tomcat 6</div><div>Mysql Server version: 5.0.67-0ubuntu6 </div><div>MySQL J/Connector: <span class="Apple-style-span" style="font-family: 'Lucida Grande'; ">mysql-connector-java-5.1.7-bin.jar</span></div></body></html>