NutzCN Logo
问答 1.r.58 oracle 合并sql报错
发布于 2987天前 作者 qq_895c9d88 3157 次浏览 复制 上一个帖子 下一个帖子
标签:
2016-10-18 15:59:53,189 [DEBUG][org.nutz.dao.impl.FileSqlManager] - load 4 sql >> erp.sql from root=sql/erp/erp.sql
2016-10-18 15:59:53,193 [DEBUG][org.nutz.dao.impl.FileSqlManager] - load >> isp.sql from root=sql/isp/isp.sql
2016-10-18 15:59:53,193 [DEBUG][org.nutz.dao.impl.FileSqlManager] - load 0 sql >> isp.sql from root=sql/isp/isp.sql
2016-10-18 15:59:53,193 [DEBUG][org.nutz.dao.impl.DaoSupport] - SqlManager Sql count=4
2016-10-18 15:59:53,282 [ERROR][com.alibaba.druid.filter.stat.StatFilter] - merge sql error, dbType oracle, sql : 
show index from factory_head
com.alibaba.druid.sql.parser.ParserException: TODO : INDEX index
	at com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser.parseStatementList(OracleStatementParser.java:495)
	at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:121)
	at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:116)
	at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:53)
	at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145)
	at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:629)
	at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:305)
	at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:124)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448)
	at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342)
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:318)
	at org.nutz.dao.util.Daos$4.invoke(Daos.java:841)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:147)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:114)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:70)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:266)
	at org.nutz.dao.util.Daos.migration(Daos.java:766)
	at org.nutz.dao.util.Daos.migration(Daos.java:1042)
	at org.nutz.dao.util.Daos.migration(Daos.java:1060)
	at schedule.go.MvcSetup.init(MvcSetup.java:48)
	at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:277)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:121)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4841)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
2016-10-18 15:59:53,291 [DEBUG][org.nutz.dao.util.Daos] - migration Table 'factory_head' fail!
java.sql.SQLSyntaxErrorException: ORA-00900: 无效 SQL 语句

	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:208)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1046)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3613)
	at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3657)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1495)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2714)
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_executeQuery(FilterEventAdapter.java:465)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_executeQuery(FilterChainImpl.java:2711)
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.executeQuery(PreparedStatementProxyImpl.java:132)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:227)
	at org.nutz.dao.util.Daos$4.invoke(Daos.java:842)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:147)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:114)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:70)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:266)
	at org.nutz.dao.util.Daos.migration(Daos.java:766)
	at org.nutz.dao.util.Daos.migration(Daos.java:1042)
	at org.nutz.dao.util.Daos.migration(Daos.java:1060)
	at schedule.go.MvcSetup.init(MvcSetup.java:48)
	at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:277)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:121)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4841)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5535)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

跟踪源码,Daos类migration方法:

// show index from mytable;
                    String showIndexs = "show index from " + en.getTableName();
                    PreparedStatement ppstat = conn.prepareStatement(showIndexs);
                    ResultSet rest = ppstat.executeQuery();
                    while (rest.next()) {
                        String index = rest.getString(3);
                        _indexs.add(index);
                    }

oracle 并不是通过show index from tablename获取索引状态

10 回复

嗯, 应该怎么写呢??

第一个异常是druid的bug, 虽然报错但不影响运行, 不知道你是不是用最新版的druid,如果是的话, 请向druid报issue

com.alibaba.druid.sql.parser.ParserException: TODO : INDEX index

@wendal
1. 是使用druid最新版本

com.alibaba
druid
1.0.26

2. 在使用nutz 1.b.53的时候,没有报这个错误,而nutz 1.r.58有这个问题
3. druid只是运行这个sql而已
4. 目前日记是sql有误,oracle不支持 ”show index from 表名“语句!!!

需要用到索引增加?

看来要开个issue了

@wendal
1. 请看org.nutz.dao.util.Daos 763行,sql是来自这里String showIndexs = "show index from " + en.getTableName();
2. 我的实体类中配置了@TableIndexes

@Table("factory_head")
@TableIndexes({ @Index(name = "factory_planId", fields = { "planId", "type" }, unique = true) })

我知道问题在这里,只是还不知道oracle应该怎么查索引状态...

@wendal

额... 还有sql server。。。

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