Score
0
Watch 3.4K Star 8.5K Fork 3.8K

卓源软件 / JeeSite 4.1JavaAGPL-3.0

jeesite连接H2数据库

Open
pjhpeter  Opened this issue

该问题是怎么引起的?

连接了内嵌的H2数据库,数据库文件在项目里面,能够成功连接,但是启动过程中报错:org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "JS_SYS_MODULE" not found; SQL statement:

重现步骤

  1. 在使用h2工具创建一个h2数据库到项目中
  2. 将原来的mysql数据库表导出成sql,并在h2数据库中执行
  3. 配置application.yml
type: h2
  driver: org.h2.Driver
  url: jdbc:h2:file:../db/test;MODE=MySQL
  username: root
  password: root
  testSql: SELECT 1
  1. 启动服务

报错信息

org.springframework.jdbc.BadSqlGrammarException: 
### Error querying database.  Cause: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "JS_SYS_MODULE" not found; SQL statement:
SELECT a.status AS "status", a.create_by AS "createBy", a.create_date AS "createDate", a.update_by AS "updateBy", a.update_date AS "updateDate", a.remarks AS "remarks", a.module_code AS "moduleCode", a.module_name AS "moduleName", a.description AS "description", a.main_class_name AS "mainClassName", a.current_version AS "currentVersion", a.upgrade_info AS "upgradeInfo" FROM js_sys_module a WHERE a.status = ? ORDER BY a.update_date DESC [42102-199]
### The error may exist in com/jeesite/modules/sys/dao/ModuleDao.java (best guess)
### The error may involve com.jeesite.modules.sys.dao.ModuleDao.findList
### The error occurred while executing a query
### SQL: SELECT a.status AS "status", a.create_by AS "createBy", a.create_date AS "createDate", a.update_by AS "updateBy", a.update_date AS "updateDate", a.remarks AS "remarks", a.module_code AS "moduleCode", a.module_name AS "moduleName", a.description AS "description", a.main_class_name AS "mainClassName", a.current_version AS "currentVersion", a.upgrade_info AS "upgradeInfo" FROM js_sys_module a WHERE a.status = ? ORDER BY a.update_date DESC
### Cause: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "JS_SYS_MODULE" not found; SQL statement:
SELECT a.status AS "status", a.create_by AS "createBy", a.create_date AS "createDate", a.update_by AS "updateBy", a.update_date AS "updateDate", a.remarks AS "remarks", a.module_code AS "moduleCode", a.module_name AS "moduleName", a.description AS "description", a.main_class_name AS "mainClassName", a.current_version AS "currentVersion", a.upgrade_info AS "upgradeInfo" FROM js_sys_module a WHERE a.status = ? ORDER BY a.update_date DESC [42102-199]
; bad SQL grammar []; nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "JS_SYS_MODULE" not found; SQL statement:
SELECT a.status AS "status", a.create_by AS "createBy", a.create_date AS "createDate", a.update_by AS "updateBy", a.update_date AS "updateDate", a.remarks AS "remarks", a.module_code AS "moduleCode", a.module_name AS "moduleName", a.description AS "description", a.main_class_name AS "mainClassName", a.current_version AS "currentVersion", a.upgrade_info AS "upgradeInfo" FROM js_sys_module a WHERE a.status = ? ORDER BY a.update_date DESC [42102-199]
	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:234)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
	at com.sun.proxy.$Proxy95.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
	at com.sun.proxy.$Proxy141.findList(Unknown Source)
	at com.jeesite.common.service.QueryService.findList(mg:482)
	at com.jeesite.common.service.QueryService$$FastClassBySpringCGLIB$$f024fa1f.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)
	at com.jeesite.modules.sys.service.support.ModuleServiceSupport$$EnhancerBySpringCGLIB$$8ddd2da8.findList(<generated>)
	at com.jeesite.common.service.QueryService$$FastClassBySpringCGLIB$$f024fa1f.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:684)
	at com.jeesite.modules.sys.service.support.ModuleServiceSupport$$EnhancerBySpringCGLIB$$b2c4df66.findList(<generated>)
	at com.jeesite.modules.sys.utils.ModuleUtils.getModuleList(nn:37)
	at com.jeesite.common.h.l.float(qs:209)
	at com.jeesite.common.h.l.if(qs:49)
	at com.jeesite.common.h.l.onApplicationEvent(qs:88)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354)
	at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:97)
	at org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:72)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
	at com.jeesite.modules.Application.main(Application.java:20)
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "JS_SYS_MODULE" not found; SQL statement:
SELECT a.status AS "status", a.create_by AS "createBy", a.create_date AS "createDate", a.update_by AS "updateBy", a.update_date AS "updateDate", a.remarks AS "remarks", a.module_code AS "moduleCode", a.module_name AS "moduleName", a.description AS "description", a.main_class_name AS "mainClassName", a.current_version AS "currentVersion", a.upgrade_info AS "upgradeInfo" FROM js_sys_module a WHERE a.status = ? ORDER BY a.update_date DESC [42102-199]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:451)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
	at org.h2.message.DbException.get(DbException.java:205)
	at org.h2.message.DbException.get(DbException.java:181)
	at org.h2.command.Parser.readTableOrView(Parser.java:7146)
	at org.h2.command.Parser.readTableFilter(Parser.java:1895)
	at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:2641)
	at org.h2.command.Parser.parseSelectSimple(Parser.java:2788)
	at org.h2.command.Parser.parseSelectSub(Parser.java:2636)
	at org.h2.command.Parser.parseSelectUnion(Parser.java:2469)
	at org.h2.command.Parser.parseSelect(Parser.java:2440)
	at org.h2.command.Parser.parsePrepared(Parser.java:814)
	at org.h2.command.Parser.parse(Parser.java:788)
	at org.h2.command.Parser.parse(Parser.java:760)
	at org.h2.command.Parser.prepareCommand(Parser.java:683)
	at org.h2.engine.Session.prepareLocal(Session.java:627)
	at org.h2.engine.Session.prepareCommand(Session.java:565)
	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1292)
	at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:77)
	at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:739)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:615)
	at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:943)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:610)
	at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:943)
	at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:143)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:610)
	at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:374)
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:387)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:55)
	at com.sun.proxy.$Proxy198.prepareStatement(Unknown Source)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:85)
	at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
	at com.jeesite.common.mybatis.h.H.if(rq:187)
	at com.jeesite.common.mybatis.h.H.float(rq:152)
	at com.jeesite.common.mybatis.interceptor.PaginationInterceptor.intercept(cz:55)
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
	at com.sun.proxy.$Proxy197.prepare(Unknown Source)
	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
	at com.jeesite.common.mybatis.interceptor.l.float(vr:186)
	at com.jeesite.common.mybatis.interceptor.l.if(vr:206)
	at com.jeesite.common.mybatis.interceptor.DataSourceInterceptor.intercept(vr:217)
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
	at com.sun.proxy.$Proxy196.query(Unknown Source)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
	... 30 common frames omitted
total 1 participants

Comments (0)

Sign in to comment

Assignees
Labels
Not set
Projects
Milestones
Branches
Planed to start
Not set
Planed to end
Not set
Top level
Priority
Java
1
https://gitee.com/thinkgem/jeesite4.git
git@gitee.com:thinkgem/jeesite4.git
thinkgem
jeesite4
JeeSite 4.1

Help Search

182353 aa51c838 1899542 205747 347fc4a1 1899542