|
本帖最后由 licaiks 于 2022-2-12 17:51 编辑
查看一下这个问题:
java.sql.SQLSyntaxErrorException: Table 'bdm287135315_db.user_tab_cols' doesn't exist
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1200)
at org.jeecgframework.codegenerate.database.DbReadTableUtil.readAllTableNames(DbReadTableUtil.java:96)
at org.jeecg.modules.online.cgform.c.d.a(OnlCgformHeadController.java:488)
at org.jeecg.modules.online.cgform.c.d$$FastClassBySpringCGLIB$$b70991d.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687)
at org.jeecg.modules.online.cgform.c.d$$EnhancerBySpringCGLIB$$374d2b43.a(<generated>)
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.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
1. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) 我的数据库是mysql,明显异常也报了
2. java.sql.SQLSyntaxErrorException: Table 'bdm287135315_db.user_tab_cols' doesn't exist 却以oracle查找表的【user_tab_cols】 去查询表,很明显,MySQL没有这张表。
问题在哪里?
在底层代码生成器的逻辑中:
红框位置判断出现问题,如果我是MySQL,刚好我的表名中有【dm】,关键字就有问题了,所以,劳驾你们底层开发把这个地方修复一下。
解决方案也很简单:
- public static List<String> readAllTableNames() throws SQLException {
- String var1 = null;
- ArrayList var2 = new ArrayList(0);
- try {
- Class.forName(org.jeecgframework.codegenerate.a.a.b);
- b = DriverManager.getConnection(org.jeecgframework.codegenerate.a.a.c, org.jeecgframework.codegenerate.a.a.d, org.jeecgframework.codegenerate.a.a.e);
- c = b.createStatement(1005, 1007);
- String var3 = b.getCatalog();
- a.info(" connect databaseName : " + var3);
- if (org.jeecgframework.codegenerate.database.a.a(org.jeecgframework.codegenerate.a.a.c)) {
- var1 = MessageFormat.format("select distinct table_name from information_schema.columns where table_schema = {0}", org.jeecgframework.codegenerate.generate.util.f.c(var3));
- }
- <font color="#ffffff" style="background-color: red;">//TO-DO 此处需要讲if修改成elseif</font>
- if (org.jeecgframework.codegenerate.database.a.b(org.jeecgframework.codegenerate.a.a.c)) {
- var1 = " select distinct colstable.table_name as table_name from user_tab_cols colstable order by colstable.table_name";
- }
- if (org.jeecgframework.codegenerate.database.a.d(org.jeecgframework.codegenerate.a.a.c)) {
- if (org.jeecgframework.codegenerate.a.a.a.indexOf(",") == -1) {
- var1 = MessageFormat.format("select tablename from pg_tables where schemaname in( {0} )", org.jeecgframework.codegenerate.generate.util.f.c(org.jeecgframework.codegenerate.a.a.a));
- } else {
- StringBuffer var4 = new StringBuffer();
- String[] var5 = org.jeecgframework.codegenerate.a.a.a.split(",");
- String[] var6 = var5;
- int var7 = var5.length;
- for(int var8 = 0; var8 < var7; ++var8) {
- String var9 = var6[var8];
- var4.append(org.jeecgframework.codegenerate.generate.util.f.c(var9) + ",");
- }
- var1 = MessageFormat.format("select tablename from pg_tables where schemaname in( {0} )", var4.toString().substring(0, var4.toString().length() - 1));
- }
- }
- if (org.jeecgframework.codegenerate.database.a.c(org.jeecgframework.codegenerate.a.a.c)) {
- var1 = "select distinct c.name as table_name from sys.objects c where c.type = 'U' ";
- }
- a.debug("--------------sql-------------" + var1);
- ResultSet var0 = c.executeQuery(var1);
- while(var0.next()) {
- String var20 = var0.getString(1);
- var2.add(var20);
- }
- } catch (Exception var18) {
- var18.printStackTrace();
- } finally {
- try {
- if (c != null) {
- c.close();
- c = null;
- System.gc();
- }
- if (b != null) {
- b.close();
- b = null;
- System.gc();
- }
- } catch (SQLException var17) {
- throw var17;
- }
- }
- return var2;
- }
复制代码
红框的第二个if,修改成elseif 就可以了,或者看todo位置也可以
|
|