简体   繁体   中英

Spring/Hibernate MySQL Driver settings for SSH connection

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM