How to connect to remote MySQL server via SSH using JPA?

后端 未结 2 996
小蘑菇
小蘑菇 2021-01-03 04:53

I\'m trying to connect to a remote MySQL server via SSH in my Java project. How can I integrate SSH connection with JPA?

I\'m using Netbeans 6.9.1, JPA, MySQL 5.2.

2条回答
  •  情书的邮戳
    2021-01-03 05:31

    You can't ... You have to set up external ssh tunel.

    ssh -N -f -L 3307:localhost:3306 login@remotwhostwithmysql
    

    Later change connection-url jdbc:mysql://127.0.0.1:3307/yourdatabase

提交回复
热议问题