私はApacheとMySQLサーバをインストールしたローカルサーバを持っています。両方とも非常にうまく動作します。私はブラウザの細かいところにapacheのデフォルトページを表示することができます。そして私はターミナル経由でmysqlデータベースを管理することができます。今のところオッケー。しかし、私は私のDBを使用するコードを記述しようとする場合。それは私に通信リンクエラーを与える。ここで他のPCからローカルのMysqlサーバに接続
は、単純なJavaコードです:
public static void main(String[] args) {
String url = "jdbc:mysql://192.168.1.49:3306/test";
String username = "root";
String password = "1234";
System.out.println("Connecting database...");
Connection connection = null;
try {
connection = DriverManager.getConnection(url, username, password);
System.out.println("Database connected!");
} catch (SQLException e) {
throw new IllegalStateException("Cannot connect the database!", e);
}
}
、ここではエラーになります。データベースの接続
...
Exception in thread "main" java.lang.IllegalStateException: Cannot connect the database! at servermysql.ServerMysql.main(ServerMysql.java:34) Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
SERVERはUBUNTU 14.04サーバ
ですフリーズありがとう
ありがとうございます。出来た! :) –