SQL Server问题记录

问题

DataGrip连接SQL Server

连接SQL Server失败,默认使用的驱动是sqljdbc4:
在这里插入图片描述
结果报错信息如下:

[08S01] 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]”。
javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12].

参考DataGrip连接SQL Server,提示驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server建立安全连接的解决方法

结果使用Microsoft SQL Server(jTds)之后,报错信息如下:

[08S01] Network error IOException: The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]
javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12].

参考解决方法

新建文件custom.java.security,内容如下:

jdk.tls.disabledAlgorithms=SSLv3, TLSv1.1, RC4, DES, MD5withRSA, \
    DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
    include jdk.disabled.namedCurves

选中数据库,右键属性,点击高级,在VM options里面增加如下内容:
-Djava.security.properties=C:\Users\<awesome_me>\Downloads\custom.java.security

然后重新点击Test Connection,如果不行,请清除DataGrip缓存重启:Invalidate Caches,然后Invalidate And Restart。

事实上,这个报错,对于其他数据源也是适用的。

SQLServerException: 语句被终止。完成执行语句前已用完最大递归100

SQL语句中有递归查询,要么是递归次数过大,要么进入递归死循环。检查SQL语句。

服务器范围的默认值为 100。如果指定 0,则没有限制。

SQLServerException: A result set was generated for update

报错信息:java.lang.Exception: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.
解决方法:

private void dealExecuteWithDbType(String sql, String driver, Statement stat) throws SQLException {
    if (driver.equals(DbDriverTypeEnum.SQLSERVER.getDbDriverType())) {
        // SQL Server特殊处理:SQLServerException: A result set was generated for update.
        stat.executeQuery(sql);
    } else {
        stat.executeUpdate(sql);
    }
}

SQLServerException: The statement did not return a result set.

报错信息:java.lang.Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.

解决方法:把stat.executeQuery(sql);改成stat.execute(sql);

Error encountered when performing Introspect database master: 不支持“variant”数据类型

在使用Intellij IDEA或者DataGrip连接SQL Server数据源报错。
解决方案:勾选Introspect using JDBC metadata
在这里插入图片描述

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

johnny233

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值