NutzCN Logo
问答 dao操作报check the manual that corresponds to your GBase server version for the right syntax to use near
发布于 2640天前 作者 qq_4945a577 5526 次浏览 复制 上一个帖子 下一个帖子
标签:

org.nutz.dao.DaoException: !Nutz SQL Error: 'SELECT * FROM wcc_warning WHERE chain_price>0 ORDER BY chain_price DESC '
PreparedStatement:
'SELECT * FROM wcc_warning WHERE chain_price>? ORDER BY chain_price DESC '
CaseMessage=192.168.0.234:5050Failed to query in gnode:
DETAIL: You have an error in your SQL syntax; check the manual that corresponds to your GBase server version for the right syntax to use near '?) LIMIT 0 ; commit' at line 1
SQL: CREATE TABLE gctmpdb._tmp_3925911744_554610_t18257_4_1503404897_s AS SELECT /*192.168.0.234_554610_9_2017-08-31_14:16:58*/ /*+ TID('1132369') */ wcc_warning.province_name AS c15, wcc_warning.cat_name AS c16, wcc_warning.picture AS c17, wcc_warning.`
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)

  cri.where().andGT("chain_price",0);
12 回复

这是nutz的问题还是数据库的问题

用 "插入代码"按钮重新贴一次,完整的报错信息

nutz dao 在我的action层自定义的sql查询是没问题页面出来数了,但是下边这样

  cri.where().andGT("chain_price",0);
list=dao.query(WccWarningView.class,cri);

这种生成dao自己的sql就报上边的错了。

java.sql.SQLException: [192.168.0.234:5050](GBA-02AD-0005)Failed to query in gnode:
DETAIL: You have an error in your SQL syntax; check the manual that corresponds to your GBase server version for the right syntax to use near '?) LIMIT 0 ; commit' at line 1
SQL: CREATE TABLE `gctmpdb`._tmp_3925911744_560791_t18406_4_1503404897_s AS SELECT /*192.168.0.234_560791_9_2017-08-31_14:36:14*/ /*+ TID('1132518') */ `w_warning`.`province_name` AS `c15`, `w_warning`.`cat_name` AS `c16`, `w_warning`.`picture` AS `c17`, `w_warning`.`
	at com.gbase.jdbc.SQLError.createSQLException(SQLError.java:946)
	at com.gbase.jdbc.GbaseIO.checkErrorPacket(GbaseIO.java:2870)
	at com.gbase.jdbc.GbaseIO.sendCommand(GbaseIO.java:1573)
	at com.gbase.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
	at com.gbase.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
	at com.gbase.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1262)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2830)
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2827)
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:182)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:228)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:272)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:483)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:488)

PreparedStatement: 
'SELECT * FROM w_warning  WHERE chain_price>? ORDER BY chain_price DESC  '
CaseMessage=[192.168.0.234:5050](GBA-02AD-0005)Failed to query in gnode:
DETAIL: You have an error in your SQL syntax; check the manual that corresponds to your sysBase server version for the right syntax to use near '?) LIMIT 0 ; commit' at line 1
SQL: CREATE TABLE `gctmpdb`._tmp_3925911744_560791_t18406_4_1503404897_s AS SELECT /*192.168.0.234_560791_9_2017-08-31_14:36:14*/ /*+ TID('1132518') */ `w_warning`.`province_name` AS `c15`, `w_warning`.`cat_name` AS `c16`, `w_warning`.`picture` AS `c17`, `w_warning`.`
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:483)
	at org.nutz.dao.impl.NutDao.query(NutDao.java:488)
	at net.nutz.w.controller.WarningAction.QueryWaring(WarningAction.java:82)
	at net.nutz.w.controller.WarningAction$FM$QueryWaring$8101c8b5c0af664cebe32906dd0e2c2a.invoke(WarningAction.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLException: [192.168.0.234:5050](GBA-02AD-0005)Failed to query in gnode:
DETAIL: You have an error in your SQL syntax; check the manual that corresponds to your sysBase server version for the right syntax to use near '?) LIMIT 0 ; commit' at line 1
SQL: CREATE TABLE `gctmpdb`._tmp_3925911744_560791_t18406_4_1503404897_s AS SELECT /*192.168.0.234_560791_9_2017-08-31_14:36:14*/ /*+ TID('1132518') */ `w_warning`.`province_name` AS `c15`, `w_warning`.`cat_name` AS `c16`, `w_warning`.`picture` AS `c17`, `w_warning`.`
	at com.sysBase.jdbc.SQLError.createSQLException(SQLError.java:946)
	at com.sysBase.jdbc.sysBaseIO.checkErrorPacket(sysBaseIO.java:2870)
	at com.sysBase.jdbc.sysBaseIO.sendCommand(sysBaseIO.java:1573)
	at com.sysBase.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
	at com.sysBase.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
	at com.sysBase.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1262)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2830)
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2827)
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:182)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:228)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:272)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
	... 51 more

gbase? sysbase ? 为何有2种数据库???

问题的原因找到了就是dao自己生成的sql,需要放变量的地方是个“?”,数据库返回异常,手动拼写sql就行了,但是兽总手拼sql的查询dao的回调有点蛋疼(几十个字段),希望以后能出个简单的方式执行sql后的回调接收函数

那么多内置回调没一个合适?

Sqls.callback.records()
Sqls.callback.maps()

直接按这么模板做的,还没有发现到过你说的那两个

List<String> demoSql(Dao dao) {
    Sql sql = Sqls.create("SELECT name FROM t_abc WHERE name LIKE @name");
    sql.params().set("name", "A%");
    sql.setCallback(new SqlCallback() {
        public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
            List<String> list = new LinkedList<String>();
            while (rs.next())
                list.add(rs.getString("name"));
            return list;
        }
    });
    dao.execute(sql);
    return sql.getList(String.class);
}

下面的回调跟你的功能等价

Sqls.callback.strs()

用Sqls.queryString的话, 连回调都设置好了.

dao执行sql 中文给转成乱码 怎么办
PreparedStatement:
'select * from wcc_warning where chain_price>=0and cat_name='药品' order by chain_price desc'
CaseMessage=You have an error in your SQL syntax; check the manual that corresponds to your GBase server version for the right syntax to use near 'cat_name='蔬�' order by chain_price desc' at line 1
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)

一个帖,一个事。

添加回复
请先登陆
回到顶部