0
我无法连接下面提到的示例中的mysql db。Ubuntu上的MySQL异常:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败
类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(); } } }
堆栈跟踪如下:
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
堆栈跟踪将包含原因。你能提供吗? – samlewis
即时获取下面的错误:( )引起:org.springframework.jdbc.CannotGetJdbcConnectionException:无法获取JDBC连接;嵌套异常是com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 属性文件提供到弹簧包含: jdbcDriverClassName = com.mysql.jdbc.Driver JDBCURL = JDBC:MySQL的://本地主机:3306/mynumber的 jdbcUsername =根 jdbcPassword =岩石 –
@just_java考虑添加,作为一个编辑的问题 – SubSevn