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

informix分页sql报错 #129

Closed
damacheng009 opened this issue Oct 19, 2017 · 9 comments
Closed

informix分页sql报错 #129

damacheng009 opened this issue Oct 19, 2017 · 9 comments
Labels

Comments

@damacheng009
Copy link

PageHelper版本:5.1.2
informix版本:11.5

改成SELECT count(*) FROM t_customer则正常。

报错信息如下:
org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: java.sql.SQLException: A syntax error has occurred.

The error may exist in cn/itcast/vo/CustomerMapper.xml

The error may involve cn.itcast.dao.CustomerMapper.findAll_COUNT

The error occurred while executing a query

SQL: SELECT count(0) FROM t_customer

Cause: java.sql.SQLException: A syntax error has occurred.

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy5.findAll(Unknown Source)
at cn.itcast.dao.MybatisCustomerDaoImpl.findByPage(MybatisCustomerDaoImpl.java:108)
@abel533
Copy link
Collaborator

abel533 commented Oct 19, 2017

@damacheng009
Copy link
Author

多谢,可以了。
还发现个小问题,就是如果不显式配置
helperDialect为informix就会报错:
org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: com.github.pagehelper.PageException: 无法自动获取数据库类型,请通过 helperDialect 参数指定!

Cause: com.github.pagehelper.PageException: 无法自动获取数据库类型,请通过 helperDialect 参数指定!

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy5.findAll(Unknown Source)
at cn.itcast.dao.MybatisCustomerDaoImpl.findByPage(MybatisCustomerDaoImpl.java:108)

其他数据库不需要显示指定。

@abel533
Copy link
Collaborator

abel533 commented Oct 20, 2017

方便提供一下你们infomix的jdbcurl吗?(修改关键部分)。

@damacheng009
Copy link
Author

jdbc:informix-sqli://localhost:9090/test:INFORMIXSERVER=xcc;IFX_USE_STRENC=true;CLIENT_LOCALE=EN_US.utf8;DB_LOCALE=EN_US.utf8;

@abel533
Copy link
Collaborator

abel533 commented Oct 20, 2017

找到原因了,默认根据:informix-sqli:这部分内容识别数据库,识别时没有-sql部分,所以没法自动识别。

informix 这部分有几种情况呢?

@damacheng009
Copy link
Author

我也是第一次接触Informix,不过网上搜到的都是jdbc:informix-sqli开头的。

@abel533
Copy link
Collaborator

abel533 commented Oct 20, 2017

确实是这个,我后面加个映射关系。

@abel533 abel533 added the bug label Oct 20, 2017
abel533 added a commit that referenced this issue Oct 21, 2017
@abel533 abel533 closed this as completed Oct 21, 2017
@xueyuchen
Copy link

accidentPage = PageHelper.startPage(1, 10).countColumn("id")
                    .doSelectPage(() -> this.accidentMapper.findUnGarageFinish(null, null, user.getRegionId(), 7));

为什么我这样写,countColumn不起作用呢??
实际执行的sql还是

select count(0) from

@abel533
Copy link
Collaborator

abel533 commented Nov 22, 2018

@xueyuchen 单独开个issue吧。

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

No branches or pull requests

3 participants