LoginSignup
0
0

More than 1 year has passed since last update.

「Communications link failure」MySQL接続エラー

Last updated at Posted at 2021-05-19

状況

Maven build したjarファイルを、WSL2(Ubuntu20.04)上で環境変数付きで実行しようとした際、下記のエラーがでた。
java -jar ファイル名.jar --spring.profiles.active=local

エラー

2021-05-19 14:56:37.594 ERROR 384 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

注意

Eclipse上では動いていたけど、ビルドすると Communications link failure が出る状況限定です。

参考 (他の状況で Communications link failure が出る場合)

疎通確認を行うか(サーバーが起動していない、Javaの設定ファイルのURLのポート番号が間違っている、など)、タイムアウト時間の設定を疑おう、とのことです。
dev.mysql.com

今回の解決策

Windows PowerShellでやる!!!!

jsonのcurlとかであんまり上手くいかなくて、敬遠してた Windows PowerShell がまさかのです。←エスケープとかややこしい印象です。
Windows触るときに、Git操作では使っていますよw

java -jar ファイル名.jar --spring.profiles.active=local

c.f. Macの方は

java -jar -Dspring.profiles.active=local ./ファイル名

でいけたと思います。

感想

なんやかんや、Windows上での開発のコマンド操作はWSL2上でやっていたけど、今回はまさかの、Windows PowerShellが解決策だったとは!ww
(Mac使いなので、macOSのTerminalライクに使えるwsl2ばかり使ってます)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0