Tomcat connecting to MySQL - Ubuntu 8.10 Server
Ambrose Krapacs
akrapacs at gmail.com
Mon Nov 17 00:39:53 UTC 2008
Perhaps you are on to something here. Below is the output from 3
attempts to telnet to localhost on port 3306. Something doens't seem
right..
ambrose at ubuntusrvr:~$ telnet localhost 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
=
5.0.67-0ubuntu6pOw,olQ3,FIyF1c!tIO2IConnection closed by foreign host.
ambrose at ubuntusrvr:~$ telnet 127.0.0.1 3306
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
=
5.0.67-0ubuntu6Ha2pbz^H,,BG|^AimiF_/Connection closed by foreign host.
ambrose at ubuntusrvr:~$ telnet 127.0.0.1 3306
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
=
5.0.67-0ubuntu6 /;{zsT(i,\o;vcjk\k'|\Connection closed by foreign host.
On Nov 16, 2008, at 19:21 , Chris Mohler wrote:
> On Mon, Nov 17, 2008 at 6:06 PM, Ambrose Krapacs
> <akrapacs at gmail.com> wrote:
>> 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.
>> 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.
>> Class.forName("com.mysql.jdbc.Driver");
>> Connection connection =
>> DriverManager.getConnection("jdbc:mysql://localhost/inventory?
>> user=invuser&password=pass");
>> I receive the following exception when the second line above is
>> executed.
>>
>> com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
>> Communications link
>> failure
>>
>> Last packet sent to the server was 0 ms ago.
>> web.db.DatabaseBean.createDatabase(DatabaseBean.java:115)
>> web.db.DatabaseBean.install(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)
>>
>> 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.
>> Details:
>> Tomcat 6
>> Mysql Server version: 5.0.67-0ubuntu6
>> MySQL J/Connector: mysql-connector-java-5.1.7-bin.jar
>
> A shot in the dark, but did you try "telnet localhost 3306" to make
> sure mysqld is accepting connections?
>
> Chris
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20081116/af179b0e/attachment.html>
More information about the ubuntu-users
mailing list