Ok it turns out it was bound to an private ip address on ec2, thanks Dan!

On Tue, Nov 13, 2012 at 10:52 PM, S Ahmed <sahmed1...@gmail.com> wrote:

> ubuntu:~$ mysql -u root -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 58
> Server version: 5.1.63-0ubuntu0.11.04.1-log (Ubuntu)
>
> Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights
> reserved.
>
> Oracle is a registered trademark of Oracle Corporation and/or its
> affiliates. Other names may be trademarks of their respective
> owners.
>
> Type 'help;' or '\h' for help. Type '\c' to clear the current input
> statement.
>
> mysql> exit
> Bye
> ubuntu:~$ telnet localhost 3306
> Trying 127.0.0.1...
> telnet: Unable to connect to remote host: Connection refused
> ubuntu:~$ telnet 127.0.0.1 3306
> Trying 127.0.0.1...
> telnet: Unable to connect to remote host: Connection refused
> ubuntu:~$ cat /etc/hosts
> 127.0.0.1 localhost
>
> # The following lines are desirable for IPv6 capable hosts
> ::1 ip6-localhost ip6-loopback
> fe00::0 ip6-localnet
> ff00::0 ip6-mcastprefix
> ff02::1 ip6-allnodes
> ff02::2 ip6-allrouters
> ff02::3 ip6-allhosts
> ubuntu:~$
>
> ubuntu:~$ cat /etc/issue
> Ubuntu 11.04 \n \l
>
>
>
>
>
> On Tue, Nov 13, 2012 at 11:16 AM, S Ahmed <sahmed1...@gmail.com> wrote:
>
>> I'll report back tonight, thanks again!
>>
>>
>> On Tue, Nov 13, 2012 at 11:08 AM, Daniel Mikusa <dmik...@vmware.com>wrote:
>>
>>> On Nov 13, 2012, at 9:55 AM, S Ahmed wrote:
>>>
>>> > Dan,
>>> >
>>> > Thanks for your help.
>>> >
>>> > From the terminal I was very explicit, I did this:
>>> >
>>> >> mysql --host localhost --port 3306 --user myuser --password
>>> >> password: 123
>>> >
>>> > And it worked fine.  In my log4net, I believe I set jdbc logs to be
>>> ALL or
>>> > DEBUG (i'll check when I get home), but it didn't output the host and
>>> > password (just in case it is reading from the wrong file somehow??).
>>>
>>> It's not an issue of a wrong user / pass, the exception is saying that
>>> it literally cannot connect to the host that you've specified.
>>>
>>> >>> Caused by: java.net.ConnectException: Connection refused
>>>
>>> Can you include the output from the following commands?
>>>
>>> telnet localhost 3306
>>> telnet 127.0.0.1 3306
>>> cat /etc/hosts
>>>
>>> You might also want to enable wireshark and see what is happening when
>>> your application starts.
>>>
>>> Dan
>>>
>>>
>>>
>>> >
>>> >
>>> >
>>> > On Tue, Nov 13, 2012 at 8:18 AM, Daniel Mikusa <dmik...@vmware.com>
>>> wrote:
>>> >
>>> >> On Nov 12, 2012, at 10:55 PM, S Ahmed wrote:
>>> >>
>>> >>> I can't seem to connect to my mysql database from my java code, but
>>> I can
>>> >>> do it via terminal using the user and password that is in my spring
>>> >> context
>>> >>> file.
>>> >>>
>>> >>> I also tried modifying it to localhost:3306 but that didn't change
>>> >> anything
>>> >>> (it defaults to 3306).
>>> >>
>>> >> Have you tried using 127.0.0.1 or the IP address of the machine?
>>>  Perhaps
>>> >> something is not right in your /etc/hosts file and it is unable to
>>> lookup
>>> >> localhost.
>>> >>
>>> >>>
>>> >>> Both the application and mysql are on the same server (ec2).
>>> >>>
>>> >>> What can I do to figure out the issue?  I'm lost!
>>> >>>
>>> >>> my xml file has:
>>> >>>
>>> >>>   <bean id="dataSource"
>>> class="org.apache.tomcat.jdbc.pool.DataSource"
>>> >>> destroy-method="close">
>>> >>>       <property name="driverClassName"
>>> value="com.mysql.jdbc.Driver"/>
>>> >>>       <property name="url" value="jdbc:mysql://localhost/mydb"/>
>>> >>>       <property name="username" value="myuser"/>
>>> >>>       <property name="password" value="123"/>
>>> >>>
>>> >>>       <property name="maxActive" value="100"/>
>>> >>>       <property name="maxIdle" value="30"/>
>>> >>>       <property name="maxWait" value="1000"/>
>>> >>>       <property name="defaultAutoCommit" value="true"/>
>>> >>>       <property name="removeAbandoned" value="true"/>
>>> >>>       <property name="removeAbandonedTimeout" value="60"/>
>>> >>>
>>> >>>       <property name="testOnBorrow" value="true"/>
>>> >>>       <property name="validationQuery" value="SELECT 1"/>
>>> >>>
>>> >>>   </bean>
>>> >>>
>>> >>> This is the error I am getting:
>>> >>>
>>> >>> Exception in thread "main"
>>> >>> org.springframework.jdbc.CannotGetJdbcConnectionException: Could not
>>> get
>>> >>> JDBC Connection; nested exception is
>>> >>> com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
>>> Communications
>>> >>> link failure
>>> >>>
>>> >> <snip>
>>> >>>
>>> >>> Caused by: java.net.ConnectException: Connection refused
>>> >>> at java.net.PlainSocketImpl.socketConnect(Native Method)
>>> >>> at
>>> >>>
>>> >>
>>> java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
>>> >>> at
>>> >>>
>>> >>
>>> java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
>>> >>> at
>>> >>>
>>> >>
>>> java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
>>> >>> at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
>>> >>> at java.net.Socket.connect(Socket.java:546)
>>> >>> at java.net.Socket.connect(Socket.java:495)
>>> >>> at java.net.Socket.<init>(Socket.java:392)
>>> >>> at java.net.Socket.<init>(Socket.java:235)
>>> >>> at
>>> >>>
>>> >>
>>> com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
>>> >>> at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
>>> >>> ... 29 more
>>> >>
>>> >> Seems like the root cause is that a connection cannot be made to the
>>> >> server.  Double check your credentials.  Also, how are you testing
>>> from the
>>> >> terminal?  Can you run "telnet localhost 3306"?
>>> >>
>>> >> Dan
>>> >>
>>> >>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> >> For additional commands, e-mail: users-h...@tomcat.apache.org
>>> >>
>>> >>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>>
>>>
>>
>

Reply via email to