org.springframework.jdbc.BadSqlGrammarException:
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘null, null’ at line 33
The error may exist in class path resource [mybatis/mapper/settle/SettleCashierRecordNewMapper.xml]
The error may involve com.pocket.pay.settle.dao.impl.SettleCashierRecordNewDaoImpl.getSettleCashierRecordListByPage-Inline
The error occurred while setting parameters
SQL: SELECT srn.id, srn.settle_date, srn.merchant_id, m.merchant_name, s.sales_man_name, srn.bank_name, srn.bank_code, srn.status, srn.return_code, srn.return_description, (SELECT payee FROM settle_merchant_cashier_return_batch_record WHERE record_id = srn.id) AS ‘payee’, (SELECT account_no FROM settle_merchant_cashier_return_batch_record WHERE record_id = srn.id) AS ‘account_no’, srn.settle_amount, srn.total_real_amount, bps.org_name AS bank_payment_service_name, m.account_name as now_account_name, m.bank_card_no as now_bank_card_no FROM settle_merchant_cashier_record srn LEFT JOIN bank_payment_service_info bps ON bps.id = srn.bank_payment_service_id LEFT JOIN merchant_info m ON srn.merchant_id = m.id LEFT JOIN bank_sales_man_info s ON m.salesman_id = s.id WHERE 1 = 1 order by srn.create_time desc limit ?, ?
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘null, null’ at line 33
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘null, null’ at line 33
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate
S
q
l
S
e
s
s
i
o
n
I
n
t
e
r
c
e
p
t
o
r
.
i
n
v
o
k
e
(
S
q
l
S
e
s
s
i
o
n
T
e
m
p
l
a
t
e
.
j
a
v
a
:
447
)
a
t
c
o
m
.
s
u
n
.
p
r
o
x
y
.
SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447) at com.sun.proxy.
SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447)atcom.sun.proxy.Proxy29.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223)
at com.pocket.pay.settle.dao.impl.SettleCashierRecordNewDaoImpl.getSettleCashierRecordList(SettleCashierRecordNewDaoImpl.java:25)
at com.pocket.pay.settle.service.impl.SettleCashierServiceImpl.getSettleCashierRecordList(SettleCashierServiceImpl.java:24)
at com.pocket.pay.settle.service.impl.SettleCashierServiceImpl
F
a
s
t
C
l
a
s
s
B
y
S
p
r
i
n
g
C
G
L
I
B
FastClassBySpringCGLIB
FastClassBySpringCGLIBc3136420.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor
1.
p
r
o
c
e
e
d
W
i
t
h
I
n
v
o
c
a
t
i
o
n
(
T
r
a
n
s
a
c
t
i
o
n
I
n
t
e
r
c
e
p
t
o
r
.
j
a
v
a
:
99
)
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
t
r
a
n
s
a
c
t
i
o
n
.
i
n
t
e
r
c
e
p
t
o
r
.
T
r
a
n
s
a
c
t
i
o
n
A
s
p
e
c
t
S
u
p
p
o
r
t
.
i
n
v
o
k
e
W
i
t
h
i
n
T
r
a
n
s
a
c
t
i
o
n
(
T
r
a
n
s
a
c
t
i
o
n
A
s
p
e
c
t
S
u
p
p
o
r
t
.
j
a
v
a
:
282
)
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
t
r
a
n
s
a
c
t
i
o
n
.
i
n
t
e
r
c
e
p
t
o
r
.
T
r
a
n
s
a
c
t
i
o
n
I
n
t
e
r
c
e
p
t
o
r
.
i
n
v
o
k
e
(
T
r
a
n
s
a
c
t
i
o
n
I
n
t
e
r
c
e
p
t
o
r
.
j
a
v
a
:
96
)
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
a
o
p
.
f
r
a
m
e
w
o
r
k
.
R
e
f
l
e
c
t
i
v
e
M
e
t
h
o
d
I
n
v
o
c
a
t
i
o
n
.
p
r
o
c
e
e
d
(
R
e
f
l
e
c
t
i
v
e
M
e
t
h
o
d
I
n
v
o
c
a
t
i
o
n
.
j
a
v
a
:
179
)
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
a
o
p
.
f
r
a
m
e
w
o
r
k
.
C
g
l
i
b
A
o
p
P
r
o
x
y
1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy
1.proceedWithInvocation(TransactionInterceptor.java:99)atorg.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)atorg.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)atorg.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)atorg.springframework.aop.framework.CglibAopProxyDynamicAdvisedInterceptor.intercept(CglibAopProxy.java:656)
at com.pocket.pay.settle.service.impl.SettleCashierServiceImpl
E
n
h
a
n
c
e
r
B
y
S
p
r
i
n
g
C
G
L
I
B
EnhancerBySpringCGLIB
EnhancerBySpringCGLIB5b8b667.getSettleCashierRecordList()
at com.pocket.pay.settle.service.impl.SettleCashierServiceImpl
F
a
s
t
C
l
a
s
s
B
y
S
p
r
i
n
g
C
G
L
I
B
FastClassBySpringCGLIB
FastClassBySpringCGLIBc3136420.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:721)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
大家看到这句话了吗?server version for the right syntax to use near ‘null, null’ at line 33,大概意思是sql语句的33行值是空的,相当于没传进来,但是后台打印出来是有值的,sql语句放到查询器里也能查出来,那为什么呢?
通过分析,发现执行的sql需要的参数是空的,检查来检查去,检查了很久才知道原来我在调用sql语句的时候没有把参数传进来,我也太粗心了。