Issue
I have a spring boot application which is using mySQL db.DB is accessible on ssh via a different server.In Mysql Workbench i have created tunnel to access the mysql DB.
Now my question is there any way that i can do the same(tunnel over ssh) in my spring boot application? I have already searched on google but didn't get any fix for it.
If anyone can give an idea how to implement that would be really helpful.
Regards,
Solution
Assuming that you are on a UNIX/Linux platform, the idea is that you do a
ssh -L 3306:mysql-server:3306 username@mysql-server
From within you spring boot application, you do a connect to localhost:3306
which is forwarded to the mysql-server
on port 3306
.
Doing it directly inside spring boot, you should go with Java Secure Channel. An example for port forwarding is described here.
Answered By - JGK Answer Checked By - Senaida (WPSolving Volunteer)