【linux环境下连接sqlserver时的问题记录】

前言 linux环境下连接sqlserver时的问题记录 一、乱码报错 The server time zone value ‘???ú±ê×??±??’ is unrecognized or represents more than o

前言

linux环境下连接sqlserver时的问题记录


一、乱码报错

The server time zone value ‘???ú±ê×??±??’ is unrecognized or represents more than one time zone.
原因:linux不能用windows下的连接sqlserver的配置:

        datasource:
          url: jdbc:sqlserver://sqlserverIP:port;DatabaseName=databaseName
          username: username 
          password: password
          driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver

正确的配置应该是,同时在pom文件中添加依赖包:

#       url: jdbc:sqlserver://sqlserverIP:port;DatabaseName=databaseName     #windows
          url: jdbc:jtds:sqlserver://sqlserverIP:port/databaseName                        #linux
          username: username 
          password: password
          driver-class-name: net.sourceforge.jtds.jdbc.Driver
          hikari: 									#默认数据库连接池
            connection-test-query: SELECT 1

pom.xml

		<!-- sql server-->
		<dependency>
			<groupId>net.sourceforge.jtds</groupId>
			<artifactId>jtds</artifactId>
			<version>1.3.1</version>
		</dependency>

如果连接配置中的url书写错误还会报如下错误:
com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。
网上其他文章说是jdk8的java.security中的加密方法需要修改,但是尝试过发现如果配置写错也会导致如上错误。

tips:idea中连接mysql时驱动选择Microsoft SQL Server (jTds)
因为在linux中连接sqlserver还需要下载对应的可视化工具,如果只是简单的查看修改操作使用idea的数据库连接就行了

发布者:admin,转转请注明出处:http://www.yc00.com/web/1741229218a4330097.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信