关注JEECG发展历程 关注最新动态和版本, 记录JEECG成长点滴 更新日志 - 技术支持 - 招聘英才

JEECG最新版本下载 JEECG智能开发平台 - 显著提高开发效率 常见问题 - 入门视频 - 参与开源团队

商务QQ: 69893005、418799587 商务热线(5*8小时): 010-64808099 官方邮箱: jeecgos@163.com

查看: 7872|回复: 9

[环境搭建] sqlserver下报错,估计是聊天插件有问题

[复制链接]
发表于 2018-2-6 13:59:57 | 显示全部楼层 |阅读模式
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [select a.id,a.realname,d.imsign,a.userkey,a.username ,c.org_code as departid ,SUBSTR(c.org_code,1,3) as maindepartid ,d.portrait from t_s_base_user a , t_s_user_org b ,t_s_depart c ,t_s_user d where a.ID =b.user_id and b.org_id=c.id and a.ID=d.id]; SQL state [S00010]; error code [195]; 'SUBSTR' 不是可以识别的 内置函数名称。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 'SUBSTR' 不是可以识别的 内置函数名称。
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:660)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:722)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:772)
        at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:192)
        at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.query(NamedParameterJdbcTemplate.java:199)
        at org.jeecgframework.minidao.aop.MiniDaoHandler.getReturnMinidaoResult(MiniDaoHandler.java:317)
        at org.jeecgframework.minidao.aop.MiniDaoHandler.invoke(MiniDaoHandler.java:102)
        at com.sun.proxy.$Proxy118.getUsers(Unknown Source)
        at com.jeecg.chat.service.impl.ImServiceImpl.getUsersOrcl(ImServiceImpl.java:67)
        at com.jeecg.chat.service.impl.ImServiceImpl.getUsers(ImServiceImpl.java:35)
        at com.jeecg.chat.web.ImController.getUsers(ImController.java:108)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:747)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:676)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.jeecgframework.core.aop.GZipFilter.doFilter(GZipFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:140)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 'SUBSTR' 不是可以识别的 内置函数名称。
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:285)
        at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2708)
        at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465)
        at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2705)
        at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:99)
        at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:211)
        at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:703)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
        ... 61 more
[2018-02-06 13:55:24] [ERROR] [com.jeecg.chat.service.impl.ImServiceImpl:38] 数据库不兼容rg.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [select a.id,a.realname,d.imsign,a.userkey,a.username ,c.org_code as departid ,SUBSTR(c.org_code,1,3) as maindepartid ,d.portrait from t_s_base_user a , t_s_user_org b ,t_s_depart c ,t_s_user d where a.ID =b.user_id and b.org_id=c.id and a.ID=d.id]; SQL state [S00010]; error code [195]; 'SUBSTR' 不是可以识别的 内置函数名称。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 'SUBSTR' 不是可以识别的 内置函数名称。
发表于 2018-2-6 14:18:09 | 显示全部楼层
你用的是那个版本?
引用下新的
<dependency>
  <groupId>org.p3framework</groupId>
  <artifactId>jeecg-p3-biz-chat</artifactId>
  <version>1.0.2</version>
</dependency>
 楼主| 发表于 2018-2-6 14:35:31 | 显示全部楼层
admin 发表于 2018-2-6 14:18
你用的是那个版本?
引用下新的


版本3.7.2

pom参数
                 <!-- 在线聊天工具-->
                <dependency>
                        <groupId>org.p3framework</groupId>
                        <artifactId>jeecg-p3-biz-chat</artifactId>
                        <version>1.0.2</version>
                        <type>jar</type>
            <scope>compile</scope>
                </dependency>
 楼主| 发表于 2018-2-6 14:52:26 | 显示全部楼层
com.jeecg.chat.service.impl.ImServiceImpl:38
应该修改为select a.id,a.realname,d.imsign,a.userkey,a.username ,c.org_code as departid ,substring(c.org_code,1,3) as maindepartid , d.portrait from t_s_base_user a , t_s_user_org b ,t_s_depart c ,t_s_user d where a.ID =b.user_id and b.org_id=c.id and a.ID=d.id
因为sqlserver 没有substr函数,只有substring函数,没有这个chat插件的java源文件,改不了
 楼主| 发表于 2018-2-6 14:52:41 | 显示全部楼层
com.jeecg.chat.service.impl.ImServiceImpl:38
应该修改为select a.id,a.realname,d.imsign,a.userkey,a.username ,c.org_code as departid ,substring(c.org_code,1,3) as maindepartid , d.portrait from t_s_base_user a , t_s_user_org b ,t_s_depart c ,t_s_user d where a.ID =b.user_id and b.org_id=c.id and a.ID=d.id
因为sqlserver 没有substr函数,只有substring函数,没有这个chat插件的java源文件,改不了
发表于 2018-2-6 15:05:36 | 显示全部楼层
本地仓库删了,重新下载
 楼主| 发表于 2018-2-6 15:42:55 | 显示全部楼层
admin 发表于 2018-2-6 15:05
本地仓库删了,重新下载

重新下载依然报错
 楼主| 发表于 2018-2-6 16:08:17 | 显示全部楼层
为什么没有找到org.jeecgframework.minidao.aop.MiniDaoHandler
 楼主| 发表于 2018-2-6 16:20:35 | 显示全部楼层
经过反编译com.jeecg.chat.service.impl.ImServiceImpl后看到以下代码部分
public List<P3ImTSBaseUser> getUsers()
  {
    List<P3ImTSBaseUser> imTSUsers = new ArrayList();
    try
    {
      MiniDaoHandler minidaoConfig = (MiniDaoHandler)ApplicationContextUtil.getContext().getBean(MiniDaoHandler.class);
      if ("sqlserver".equals(minidaoConfig.getDbType())) {
        imTSUsers = getUsersSqlServer();
      } else {
        imTSUsers = getUsersOrcl();
      }
    }
    catch (Exception e)
    {
      this.log.error("数据库不兼容:" + e.toString());
    }
    return imTSUsers;
  }
还有com.jeecg.chat.dao.ImDao的代码
@Sql("select a.id,a.realname,d.imsign,a.userkey,a.username ,c.org_code as departid ,SUBSTR(c.org_code,1,3) as maindepartid ,d.portrait from t_s_base_user a , t_s_user_org b ,t_s_depart  c ,t_s_user d where a.ID =b.user_id and b.org_id=c.id and a.ID=d.id")
  public abstract List<P3ImTSBaseUser> getUsers();
  
  @Sql("select a.id,a.realname,d.imsign,a.userkey,a.username ,c.org_code as departid ,SUBSTRING(c.org_code,1,3) as maindepartid ,d.portrait from t_s_base_user a , t_s_user_org b ,t_s_depart  c ,t_s_user d where a.ID =b.user_id and b.org_id=c.id and a.ID=d.id")
  public abstract List<P3ImTSBaseUser> getUsersSqlServer();
那就是说如果修改了数据库为sqlserver后,系统通过MiniDaoHandler 来捕捉数据库类型后来执行相应的数据库语句。
找到jeecg/scr/main/resources/spring-minidao.xml
<!-- MiniDao动态代理类 -->
        <bean id="miniDaoHandler" class="org.jeecgframework.minidao.factory.MiniDaoBeanScannerConfigurer">
                <!-- 是使用什么字母做关键字Map的关键字 默认值origin 即和sql保持一致,lower小写(推荐),upper 大写 -->
                <property name="keyType" value="lower"></property>
                <!-- 格式化sql -->
                <property name="formatSql" value="false"></property>
                <!-- 输出sql -->
                <property name="showSql" value="false"></property>
                <!-- 数据库类型  mysql/postgresql/oracle/sqlserver -->
                <property name="dbType" value="mysql"></property>
把mysql改成sqlserver,问题顺利解决
 楼主| 发表于 2018-2-6 16:29:32 | 显示全部楼层
管理员可结贴
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表