zoukankan      html  css  js  c++  java
  • com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 ‘DUAL‘ 无效 | Druid双数据源MySQL+SQL server

    原文地址:https://blog.csdn.net/qq_35764460/article/details/113392270

    Druid双数据源
    解决方法
    背景信息:使用若依框架,配置mysql和sql server的双数据源,报错 'DUAL’无效

    com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'DUAL' 无效。
    1
    nested exception is org.apache.ibatis.exceptions.PersistenceException:
    ### Error querying database.
    Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
    Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'DUAL' 无效。
    ### The error may exist in file [D:workspace(IDEA)xxxxxxx argetclassesmapperxxxxxx.xml]
    ### The error may involve com.xxx.xxx.mapper.xxx.countMaleXunwu
    ### The error occurred while executing a query
    ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection;
    nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'DUAL' 无效。

    com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'DUAL' 无效。

    ### Error querying database.
    Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
    Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'DUAL' 无效。
    ### The error may exist in file [D:workspace(IDEA)xxxxxx argetclassesmapperxxxxxx.xml]
    ### The error may involve com.xxx.xxx.xxx.xxxx.countMaleXunwu
    ### The error occurred while executing a query
    ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'DUAL' 无效。]
    15:24:52.057 [Druid-ConnectionPool-Create-1458706578] ERROR c.a.d.p.DruidDataSource - [run,2787] - create connection SQLException, url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test, errorCode 208, state S0002
    com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'DUAL' 无效。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    我们在自己的代码里面全局搜索这个DUAL,只有在Druid里面使用了这个语句去验证数据库的连接信息

    # 配置检测连接是否有效
    validationQuery: SELECT 1 FROM DUAL
    1
    2
    SELECT 1 FROM DUAL
    1
    在MySQL下面可以正常的使用返回1,MySQL有对象DUAL

    但是SQL server 没有对象DUAL,也就是这个语句在SQL server下面是不能运行的,所以报错了

    解决方法
    改成

    validationQuery: SELECT 1

  • 相关阅读:
    tyvj4751 NOIP春季系列课程 H's Problem (树状数组)
    卡牌分组([AtCoder ARC073]Ball Coloring)
    bzoj1036 [ZJOI2008]树的统计Count (树链剖分+线段树)
    bzoj2287 POJ Challenge 消失之物(背包)
    不能建立引用数组
    CString和string的区别
    防止应用程序重复启动
    public,protected,private
    ATL
    c++头文件中定义全局变量
  • 原文地址:https://www.cnblogs.com/eyesfree/p/15062447.html
Copyright © 2011-2022 走看看