5

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

<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 persistence.properties file section where these properties are defined (this works with IP based connection only):

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 should be more properties available in order to setup the ssh connection such as database.ssh.url and database.ssh.username or something similar. Do you know some way to do this?

Manuel Ortiz Bey
  • 409
  • 2
  • 7
  • 14

1 Answers1

0

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

A possible solution is detailed in this other post

Community
  • 1
  • 1
Val Martinez
  • 617
  • 6
  • 15