I am unable to connect mysql db from below mentioned example.
class JDBCTest {
private static final String url = "jdbc:mysql://localhost"; private static final String user = "root"; private static final String password = "abc"; public static void main(String args[]) { try { Connection con = DriverManager.getConnection(url, user, password); System.out.println("Success"); } catch (Exception e) { e.printStackTrace(); } } }
The stacktrace is as follows
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; nested exception is
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
property file provide to spring contains: jdbcDriverClassName=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/mynumber jdbcUsername=root jdbcPassword=rock