line 1:20 no viable alternative at input ‘point,‘

  • 背景
    遇到一个蛋疼的问题,搞得老夫难受的一,解决了索性记录下
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@61b0005f] was not registered for synchronization because synchronization is not active
JDBC Connection [org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.MasterSlaveConnection@5ef7aaef] will not be managed by Spring
==>  Preparing: SELECT user_id,point,create_time,update_time FROM tb_user_point WHERE user_id=? 
line 1:20 no viable alternative at input 'point,'
line 1:20 no viable alternative at input 'point,'
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: java.lang.NullPointerException
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
	at com.sun.proxy.$Proxy116.selectOne(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:99)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:61)
	at com.sun.proxy.$Proxy342.selectById(Unknown Source)
	at com.meta.plant.service.impl.UserPointServiceImpl.getUserPoint(UserPointServiceImpl.java:82)
	at com.meta.plant.service.impl.UserPointServiceImpl$$FastClassBySpringCGLIB$$6bca9f86.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687)
	at com.meta.plant.service.impl.UserPointServiceImpl$$EnhancerBySpringCGLIB$$dfcd4aae.getUserPoint(<generated>)
	at com.meta.plant.service.impl.BurningPlantServiceImpl.getJUserPoints(BurningPlantServiceImpl.java:765)
	at com.meta.plant.controller.BurningController.getJUserPoints(BurningController.java:51)
	at com.meta.plant.controller.BurningController$$FastClassBySpringCGLIB$$fc3baf7c.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:62)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:55)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749<
该错误 `line 1:54 no viable alternative at input '(now( )-interval'?1 minute'` 通常是 SQL 语法错误,可能是 Apollo 配置中心在执行 SQL 查询时遇到了无法解析的语句,以下是一些可能的解决办法: ### 检查数据库配置 Apollo 配置中心依赖数据库存储配置信息,错误可能源于数据库配置问题。要保证数据库连接信息(如数据库地址、端口、用户名、密码)准确无误,同时确保数据库服务正常运行。可以使用以下命令测试数据库连接: ```bash mysql -h <host> -P <port> -u <username> -p ``` 其中 `<host>` 是数据库地址,`<port>` 是端口,`<username>` 是用户名。输入密码后若能成功登录,说明数据库连接正常。 ### 检查 SQL 脚本 错误提示表明 SQL 语法存在问题,需要检查 Apollo 配置中心使用的 SQL 脚本。查看配置中心的 SQL 脚本文件,搜索包含 `(now( )-interval'?1 minute'` 的语句,修正其中的语法错误。例如,在 MySQL 里正确的时间间隔计算语法可能是 `NOW() - INTERVAL 1 MINUTE`。 ### 更新数据库驱动 旧版本的数据库驱动可能不支持某些 SQL 语法,导致解析错误。可以尝试更新数据库驱动到最新版本。以 Maven 项目为例,在 `pom.xml` 文件中更新数据库驱动依赖: ```xml <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.26</version> <!-- 使用最新版本 --> </dependency> ``` 更新后重新编译并启动 Apollo 配置中心。 ### 检查数据库版本兼容性 确保使用的数据库版本与 Apollo 配置中心兼容。不同版本的数据库对 SQL 语法的支持有所差异,不兼容的数据库版本可能引发语法错误。参考 Apollo 官方文档,确认支持的数据库版本,并根据需要升级或降级数据库。 ### 查看日志文件 查看 Apollo 配置中心的日志文件,获取更多错误详情。日志文件通常位于配置中心的 `logs` 目录下,查看其中的错误堆栈信息,定位具体出错的代码和 SQL 语句,进而进行针对性修复。 ### 示例代码 以下是一个简单的 Python 脚本,用于测试数据库连接: ```python import mysql.connector try: connection = mysql.connector.connect( host="<host>", port="<port>", user="<username>", password="<password>", database="<database>" ) print("数据库连接成功") connection.close() except mysql.connector.Error as error: print(f"数据库连接失败: {error}") ``` 将 `<host>`、`<port>`、`<username>`、`<password>`、`<database>` 替换为实际的数据库信息,运行该脚本测试连接。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Hello Bug

谢谢老板,老板大气,老板硬邦邦

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

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

打赏作者

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

抵扣说明:

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

余额充值