Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException #11

Closed
heixiaoma opened this issue Jan 7, 2020 · 2 comments
Closed

ArrayIndexOutOfBoundsException #11

heixiaoma opened this issue Jan 7, 2020 · 2 comments

Comments

@heixiaoma
Copy link

执行这个sql 报错,select * from telegram_gorup where name like '%b%';
我有两个数据库,一个数据报错,一个不报错,很尴尬

Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at java.util.Arrays$ArrayList.get(Arrays.java:3841)
at com.simonalong.neo.Neo.replaceHolderParameters(Neo.java:1622)
at com.simonalong.neo.Neo.generateExeSqlPair(Neo.java:1500)
at com.simonalong.neo.Neo.lambda$execute$21(Neo.java:841)
at com.simonalong.neo.Neo.execute(Neo.java:1279)
at com.simonalong.neo.Neo.execute(Neo.java:841)
at com.hserver.service.UserService.sql(UserService.java:42)
at com.hserver.action.UserAction.sql(UserAction.java:37)
... 14 more

@heixiaoma
Copy link
Author

    String sql = "select * from telegram_gorup where name like %s";
    List<List<NeoMap>> execute = neo.execute(sql," '%b%'");

原来是替换规则出问题了,我这样写就好使了

@simonalong
Copy link
Owner

目前0.4.4之前的版本中,对含有%b、%h等等这些字符的sql有预处理(都是替换符使用),针对数据库支持的%c、%b这样来说目前算是个问题,因为sql中也会有一些这样的符号。因此这个也算是错误,之前已经发现在0.4.4版本中已经解决,做了简化,替换符只用%s,其他的都删除了

?作为占位符使用(同mybatis中的#{xxx})
%s 作为替换符使用(同mybatis中的${xxx})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants