Spring / Hibernate MySQL driver settings for SSH connectivity

I was not able to find how to configure MySql data source settings to enable an SSH database connection (instead of using the classic IP based connection) in my Spring / Hibernate persistence context. Here is my definition of persistenceContext.xml datasource bean:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${database.driver}"/> <property name="url" value="${database.url}"/> <property name="username" value="${database.user}"/> <property name="password" value="${database.password}"/> </bean> 

And here is my section of the persistence.properties file in which these properties are defined (this only works with an IP connection):

 database.driver=com.mysql.jdbc.Driver database.url=jdbc:mysql://192.168.1.2:3306/db database.user=root database.password=password 

I think there must be more properties to configure an ssh connection, such as database.ssh.url and database.ssh.username , or something similar. Do you know how to do this?

+4
source share
1 answer

To access a database server from your local application via ssh, the "only" extra thing you will need to do is establish the previous SSH connection before the DataSource object tries to get the connection.

A possible solution is described in detail in this other post.

0
source

Source: https://habr.com/ru/post/1496054/


All Articles