数据库服务器带有ssh通道,通过navicat软件可以访问数据库(使用ssh方式),
可是spring boot工程中如何连接访问呢。
使用JDBC连接,Spring boot怎么用使用JDBC就不再说了,每种数据库连接时JDBC具体的配置方法见如下:
MySQL : http://www.razorsql.com/articles/mysql_ssl_jdbc.html
Oracle : http://www.dbforums.com/oracle/1620651-ssl-connection-jdbc-thin-driver.html
PostgreSQL : http://archives.postgresql.org/pgsql-jdbc/2003-08/msg00110.php
MS SQL Server : http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jdbc_drivers/mssqlserver.html
首先为什么要通过ssh访问?
如果要用ssh访问 可以去参考一下idea源码,idea源码中有用ssh协议,可以拷贝过来试试
谢谢各位的回答,普通的数据库连接配置,我知道,现在就是服务器有ssh通道,不知道怎么连接上去
spring.datasource.url=jdbc:mysql://192.168.1.112:3306/dbname?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.max-active=100
spring.datasource.max-idle=100
spring.datasource.max-wait=30000
spring.datasource.min-idle=10
spring.datasource.initial-size=10
spring.datasource.validation-query=SELECT 1
spring.datasource.test-on-borrow=false
spring.datasource.test-while-idle=true
spring.datasource.time-between-eviction-runs-millis=5000
spring.datasource.url=jdbc:mysql://192.168.1.112:3306/dbname?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.max-active=100
spring.datasource.max-idle=100
spring.datasource.max-wait=30000
spring.datasource.min-idle=10
spring.datasource.initial-size=10
spring.datasource.validation-query=SELECT 1
spring.datasource.test-on-borrow=false
spring.datasource.test-while-idle=true
spring.datasource.time-between-eviction-runs-millis=500