简体   繁体   中英

MySql not working on Amazon EC2

I have a java spring application deployed on tomcat7 on Amazon EC2 Linux AMI. Mysql is running on the same instance. I can connect to the mysql server remotely using SSH connection. But not able to access mysql server from spring application. Tomcat's context.xml looks like :

    <Resource name="jdbc/db"   
       auth="Container"   
       type="javax.sql.DataSource"   
       uniqueResourceName="jdbc/db"   
       username="root"   
       password="pass"   
       driverClassName="com.mysql.jdbc.Driver"  
       url="jdbc:mysql://localhost:3306/db"  
       maxActive="15"  
       maxIdle="7"  
       validationQuery="Select 1" />  

This doesn't work, actually I'm not able to figure out whether db is connected or no as it throws no error. But when I replace localhost with server running on some other instance it works as expected. Would be helpful if someone point out where I am wrong.

Is port 3306 open? The EC2 default security group controls which ports can be accessed by new instances, and is pretty restrictive by default. Log in to the AWS Console and check that you don't have restrictive rules under EC2 > Network & Security > Security Groups.

try read tomcat error - nano usr/share/tomcat8/logs/catalina.out

in my connection.property file i have writed code like this

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/?user=root&password=pass

the app which runs under tomcat8 connects to local mysql and everything ok. Simple read error context may be some thing does not exist or becaouse of case sensitivenes mysql throws error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM