@wenshao 你好,想跟你请教个问题:
连接池配置
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="filters" value="stat" /> <property name="connectionProperties" value="druid.stat.mergeSql=true"/> <property name="maxActive" value="20" /> <property name="initialSize" value="1" /> <property name="maxWait" value="60000" /> <property name="minIdle" value="1" /> <property name="timeBetweenEvictionRunsMillis" value="3000" /> <property name="minEvictableIdleTimeMillis" value="300000" /> <property name="validationQuery" value="SELECT 'x'" /> <property name="testWhileIdle" value="true" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="false" /> <property name="poolPreparedStatements" value="true" /> <property name="maxPoolPreparedStatementPerConnectionSize" value="20" /> </bean>如果配置 <property name="connectionProperties" value="druid.stat.mergeSql=true" />
这条的话,就会报这个错
03:15:10,196 ERROR StatFilter:147 - merge sql error, dbType postgresql, sql : SELECT nextval('passport_id_seq'::regclass) as id com.alibaba.druid.sql.parser.SQLParseException: syntax error, expect RPAREN, actual VARIANT : at com.alibaba.druid.sql.parser.SQLExprParser.accept(SQLExprParser.java:1204) at com.alibaba.druid.sql.parser.SQLExprParser.methodRest(SQLExprParser.java:534) at com.alibaba.druid.sql.parser.SQLExprParser.primaryRest(SQLExprParser.java:499) at com.alibaba.druid.sql.parser.SQLSelectParser.parseSelectList(SQLSelectParser.java:257) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSelectParser.query(PGSelectParser.java:79) at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:59) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser.parseSelect(PGSQLStatementParser.java:316) at com.alibaba.druid.sql.dialect.postgresql.parser.PGSQLStatementParser.parseSelect(PGSQLStatementParser.java:40) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:86) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:70) at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:41) at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145) at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:627) 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:446) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:321) at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:72) at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:82) at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:54) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:70) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) at org.apache.ibatis.executor.keygen.SelectKeyGenerator.processGeneratedKeys(SelectKeyGenerator.java:65) at org.apache.ibatis.executor.keygen.SelectKeyGenerator.processBefore(SelectKeyGenerator.java:41) at org.apache.ibatis.executor.statement.BaseStatementHandler.generateKeys(BaseStatementHandler.java:127) at org.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:60) at org.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:36) at org.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:42) at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:436) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:43) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100) at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148) at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354) at com.sun.proxy.$Proxy17.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:236) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:46) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)去掉那句话,就不问题
快照版本这里:http://code.alibabatech.com/mvn/snapshots/com/alibaba/druid/0.2.16-SNAPSHOT
我测试过,问题已经解决了。正式版本下个星期发布。
十分感谢!这是postgres-styletypecast表达式,你提问之后,我查文档才懂。下个星期发布版本解决此问题。 createtableTUSER(IDvarchar(36)notnull,CREATEDATETIMEdatetime,MODIFYDATETIMEdatetime,NAMEvarchar(100)notnull,PWDvarchar(32)notnull,primarykey(ID))com.alibaba.druid.sql.parser.ParserException:TODOatcom.alibaba.druid.sql.parser.SQLExprParser.parsePrimaryKey(SQLExprParser.java:1298)atcom.alibaba.druid.sql.parser.SQLCreateTableParser.parseCrateTable(SQLCreateTableParser.java:75)atcom.alibaba.druid.sql.parser.SQLStatementParser.parseCreate(SQLStatementParser.java:556)atcom.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:102)atcom.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:76)atcom.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:42)atcom.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145)atcom.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:629)atcom.alibaba.druid.filter.stat.StatFilter.internalBeforeStatementExecute(StatFilter.java:397)atcom.alibaba.druid.filter.stat.StatFilter.statementExecuteUpdateBefore(StatFilter.java:325)atcom.alibaba.druid.filter.FilterEventAdapter.statement_executeUpdate(FilterEventAdapter.java:324)atcom.alibaba.druid.filter.FilterChainImpl.statement_executeUpdate(FilterChainImpl.java:2373)atcom.alibaba.druid.proxy.jdbc.StatementProxyImpl.executeUpdate(StatementProxyImpl.java:225)atcom.alibaba.druid.pool.DruidPooledStatement.executeUpdate(DruidPooledStatement.java:169)atorg.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:227)atorg.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178)atorg.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:505)atorg.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1769)atorg.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)atorg.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:242)atorg.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:372)atorg.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:357)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:591)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)atorg.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1113)atorg.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1671)atjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)atjava.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)atjava.util.concurrent.FutureTask.run(FutureTask.java:138)atjava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)atjava.lang.Thread.run(Thread.java:619)sqlserver也报错啊
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。