我使用jOOQ 3.16.5来生成Java代码,当我运行该代码时,终端告诉我成功,但是代码没有生成,我不知道为什么,所以我将代码复制到这里,希望有人帮助我
build.gradle
buildscript { mavenLocal() mavenCentral() gradlePluginPortal() maven { url "https://oss.sonatype.org/content/repositories/snapshots/“} maven { url 'https://maven.aliyun.com/repository/public/'} google() }依赖项{ classpath”org.jooq:jooq codegen:3.16.5“类路径'org.postgresql:postgresql:42.2.14‘类路径’org.xerial:sqlite:3.30.1‘类路径'org.codehaus.groovy:groovy-all:3.0.11‘} plugins { id "org.flywaydb.flyway“版本"8.5.13”}依赖项{实现项目(“:"com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop”“) api api”com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop“api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop”api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop“api "com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion”api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop“//flyway实现组:'org.flywaydb',名称:'flyway-core',版本:'8.5.13‘//jooq实现组:'org.jooq',名称:'jooq',版本:'3.16.5’实现组:'org.jooq',名称:'jooq-meta',版本:'3.16.5‘实现组:'org.jooq',名称:'jooq-codegen',版本:'3.16.5’实现组:'org.jooq',名称:‘jooq-meta-扩展名’,版本:'3.16.5‘//groovy实现'org.codehaus.groovy:groovy-all:3.0.11’/sqlitejdbc实现'sqlitejdbc:sqlitejdbc:0.5.6‘/postgresql实现'org.postgresql:postgresql:42.2.14’}这是我的数据库
SQL就在这里,通过一种方式,我使用天桥创建了一个表。
create table product(
id INTEGER primary key,
create_time TEXT
);
我使用Java 11,我不知道它是否重要
2022-07-21
就像Lukas Eder说的,我像这样修改了代码
.withDatabase(new Database()
.withName("org.jooq.meta.sqlite.SQLiteDatabase")
.withIncludes(".*")
.withExcludes("" +
"sqlite_master # This table (unqualified name) should not be generated" +
"| PREFIX_.* # Objects with a given prefix should not be generated" +
"| SECRET_SCHEMA\\.SECRET_TABLE # This table (qualified name) should not be generated" +
"| SECRET_ROUTINE # This routine (unqualified name) ..." +
"")
)
并有一些错误
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.jooq.codegen.GeneratorException: Error generating code for catalog
at org.jooq.codegen.JavaGenerator.generate0(JavaGenerator.java:488)
at org.jooq.codegen.AbstractGenerator.generate(AbstractGenerator.java:182)
at org.jooq.codegen.JavaGenerator.generate(JavaGenerator.java:202)
at org.jooq.codegen.GenerationTool.run0(GenerationTool.java:912)
at org.jooq.codegen.GenerationTool.run(GenerationTool.java:239)
at org.jooq.codegen.GenerationTool.generate(GenerationTool.java:234)
at com.changdao.game.publicclass.JooqConfig.main(JooqConfig.java:57)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.jooq.exception.DataAccessException: SQL [with virtual_tables(name) as (select coalesce(sqlite_master.name, '') from sqlite_master where lower(sqlite_master.sql) like lower('%create virtual table%')) select sqlite_master.name, case when sqlite_master.type = 'view' then 'VIEW' else 'TABLE' end as table_type, sqlite_master.sql from sqlite_master where (sqlite_master.type in (?, ?) and ((sqlite_master.name not like '%!_content' escape '!' and sqlite_master.name not like '%!_segments' escape '!' and sqlite_master.name not like '%!_segdir' escape '!' and sqlite_master.name not like '%!_docsize' escape '!' and sqlite_master.name not like '%!_stat' escape '!') or (sqlite_master.name like '%!_content' escape '!' and "replace"(sqlite_master.name, '_content', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segments' escape '!' and "replace"(sqlite_master.name, '_segments', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segdir' escape '!' and "replace"(sqlite_master.name, '_segdir', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_docsize' escape '!' and "replace"(sqlite_master.name, '_docsize', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_stat' escape '!' and "replace"(sqlite_master.name, '_stat', '') not in (select virtual_tables.name from virtual_tables)))) order by sqlite_master.name]; near "with": syntax error
at org.jooq.meta.AbstractDatabase.onError(AbstractDatabase.java:3369)
at org.jooq.meta.AbstractDatabase.getEmbeddables(AbstractDatabase.java:2045)
at org.jooq.meta.AbstractDatabase.getEmbeddables(AbstractDatabase.java:2065)
at org.jooq.codegen.JavaGenerator.generateSchemaIfEmpty(JavaGenerator.java:527)
at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:528)
at org.jooq.codegen.JavaGenerator.generateCatalogIfEmpty(JavaGenerator.java:520)
at org.jooq.codegen.JavaGenerator.generate0(JavaGenerator.java:482)
... 6 more
Caused by: java.lang.RuntimeException: org.jooq.exception.DataAccessException: SQL [with virtual_tables(name) as (select coalesce(sqlite_master.name, '') from sqlite_master where lower(sqlite_master.sql) like lower('%create virtual table%')) select sqlite_master.name, case when sqlite_master.type = 'view' then 'VIEW' else 'TABLE' end as table_type, sqlite_master.sql from sqlite_master where (sqlite_master.type in (?, ?) and ((sqlite_master.name not like '%!_content' escape '!' and sqlite_master.name not like '%!_segments' escape '!' and sqlite_master.name not like '%!_segdir' escape '!' and sqlite_master.name not like '%!_docsize' escape '!' and sqlite_master.name not like '%!_stat' escape '!') or (sqlite_master.name like '%!_content' escape '!' and "replace"(sqlite_master.name, '_content', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segments' escape '!' and "replace"(sqlite_master.name, '_segments', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segdir' escape '!' and "replace"(sqlite_master.name, '_segdir', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_docsize' escape '!' and "replace"(sqlite_master.name, '_docsize', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_stat' escape '!' and "replace"(sqlite_master.name, '_stat', '') not in (select virtual_tables.name from virtual_tables)))) order by sqlite_master.name]; near "with": syntax error
at org.jooq.meta.AbstractDatabase.onError(AbstractDatabase.java:3369)
at org.jooq.meta.AbstractDatabase.getTables(AbstractDatabase.java:1783)
at org.jooq.meta.AbstractDatabase.getEmbeddables0(AbstractDatabase.java:2087)
at org.jooq.meta.AbstractDatabase.lambda$getEmbeddables$13(AbstractDatabase.java:2046)
at org.jooq.meta.AbstractDatabase.onError(AbstractDatabase.java:3359)
... 21 more
Caused by: org.jooq.exception.DataAccessException: SQL [with virtual_tables(name) as (select coalesce(sqlite_master.name, '') from sqlite_master where lower(sqlite_master.sql) like lower('%create virtual table%')) select sqlite_master.name, case when sqlite_master.type = 'view' then 'VIEW' else 'TABLE' end as table_type, sqlite_master.sql from sqlite_master where (sqlite_master.type in (?, ?) and ((sqlite_master.name not like '%!_content' escape '!' and sqlite_master.name not like '%!_segments' escape '!' and sqlite_master.name not like '%!_segdir' escape '!' and sqlite_master.name not like '%!_docsize' escape '!' and sqlite_master.name not like '%!_stat' escape '!') or (sqlite_master.name like '%!_content' escape '!' and "replace"(sqlite_master.name, '_content', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segments' escape '!' and "replace"(sqlite_master.name, '_segments', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segdir' escape '!' and "replace"(sqlite_master.name, '_segdir', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_docsize' escape '!' and "replace"(sqlite_master.name, '_docsize', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_stat' escape '!' and "replace"(sqlite_master.name, '_stat', '') not in (select virtual_tables.name from virtual_tables)))) order by sqlite_master.name]; near "with": syntax error
at org.jooq_3.16.5.SQLITE.debug(Unknown Source)
at org.jooq.impl.Tools.translate(Tools.java:3102)
at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:670)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:354)
at org.jooq.impl.AbstractResultQuery.fetch(AbstractResultQuery.java:284)
at org.jooq.impl.SelectImpl.fetch(SelectImpl.java:2843)
at org.jooq.impl.ResultQueryTrait.iterator(ResultQueryTrait.java:300)
at org.jooq.meta.sqlite.SQLiteDatabase.getTables0(SQLiteDatabase.java:373)
at org.jooq.meta.AbstractDatabase.lambda$getTables$11(AbstractDatabase.java:1784)
at org.jooq.meta.AbstractDatabase.onError(AbstractDatabase.java:3359)
... 25 more
Caused by: java.sql.SQLException: near "with": syntax error
at org.sqlite.DB.throwex(DB.java:288)
at org.sqlite.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:114)
at org.sqlite.PrepStmt.<init>(PrepStmt.java:37)
at org.sqlite.Conn.prepareStatement(Conn.java:231)
at org.sqlite.Conn.prepareStatement(Conn.java:224)
at org.sqlite.Conn.prepareStatement(Conn.java:213)
at org.jooq.impl.ProviderEnabledConnection.prepareStatement(ProviderEnabledConnection.java:109)
at org.jooq.impl.SettingsEnabledConnection.prepareStatement(SettingsEnabledConnection.java:82)
at org.jooq.impl.AbstractResultQuery.prepare(AbstractResultQuery.java:210)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:307)
... 31 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.jooq.exception.DataAccessException: SQL [with virtual_tables(name) as (select coalesce(sqlite_master.name, '') from sqlite_master where lower(sqlite_master.sql) like lower('%create virtual table%')) select sqlite_master.name, case when sqlite_master.type = 'view' then 'VIEW' else 'TABLE' end as table_type, sqlite_master.sql from sqlite_master where (sqlite_master.type in (?, ?) and ((sqlite_master.name not like '%!_content' escape '!' and sqlite_master.name not like '%!_segments' escape '!' and sqlite_master.name not like '%!_segdir' escape '!' and sqlite_master.name not like '%!_docsize' escape '!' and sqlite_master.name not like '%!_stat' escape '!') or (sqlite_master.name like '%!_content' escape '!' and "replace"(sqlite_master.name, '_content', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segments' escape '!' and "replace"(sqlite_master.name, '_segments', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segdir' escape '!' and "replace"(sqlite_master.name, '_segdir', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_docsize' escape '!' and "replace"(sqlite_master.name, '_docsize', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_stat' escape '!' and "replace"(sqlite_master.name, '_stat', '') not in (select virtual_tables.name from virtual_tables)))) order by sqlite_master.name]; near "with": syntax error
Caused by: java.lang.RuntimeException: org.jooq.exception.DataAccessException: SQL [with virtual_tables(name) as (select coalesce(sqlite_master.name, '') from sqlite_master where lower(sqlite_master.sql) like lower('%create virtual table%')) select sqlite_master.name, case when sqlite_master.type = 'view' then 'VIEW' else 'TABLE' end as table_type, sqlite_master.sql from sqlite_master where (sqlite_master.type in (?, ?) and ((sqlite_master.name not like '%!_content' escape '!' and sqlite_master.name not like '%!_segments' escape '!' and sqlite_master.name not like '%!_segdir' escape '!' and sqlite_master.name not like '%!_docsize' escape '!' and sqlite_master.name not like '%!_stat' escape '!') or (sqlite_master.name like '%!_content' escape '!' and "replace"(sqlite_master.name, '_content', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segments' escape '!' and "replace"(sqlite_master.name, '_segments', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segdir' escape '!' and "replace"(sqlite_master.name, '_segdir', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_docsize' escape '!' and "replace"(sqlite_master.name, '_docsize', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_stat' escape '!' and "replace"(sqlite_master.name, '_stat', '') not in (select virtual_tables.name from virtual_tables)))) order by sqlite_master.name]; near "with": syntax error
Caused by: org.jooq.exception.DataAccessException: SQL [with virtual_tables(name) as (select coalesce(sqlite_master.name, '') from sqlite_master where lower(sqlite_master.sql) like lower('%create virtual table%')) select sqlite_master.name, case when sqlite_master.type = 'view' then 'VIEW' else 'TABLE' end as table_type, sqlite_master.sql from sqlite_master where (sqlite_master.type in (?, ?) and ((sqlite_master.name not like '%!_content' escape '!' and sqlite_master.name not like '%!_segments' escape '!' and sqlite_master.name not like '%!_segdir' escape '!' and sqlite_master.name not like '%!_docsize' escape '!' and sqlite_master.name not like '%!_stat' escape '!') or (sqlite_master.name like '%!_content' escape '!' and "replace"(sqlite_master.name, '_content', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segments' escape '!' and "replace"(sqlite_master.name, '_segments', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_segdir' escape '!' and "replace"(sqlite_master.name, '_segdir', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_docsize' escape '!' and "replace"(sqlite_master.name, '_docsize', '') not in (select virtual_tables.name from virtual_tables)) or (sqlite_master.name like '%!_stat' escape '!' and "replace"(sqlite_master.name, '_stat', '') not in (select virtual_tables.name from virtual_tables)))) order by sqlite_master.name]; near "with": syntax error
Caused by: java.sql.SQLException: near "with": syntax error
发布于 2022-07-20 11:58:10
你已经明确指出:
withInputSchema("public")
但是SQLite不支持模式。因此,它没有public
模式(例如,PostgreSQL)。只要把这个去掉,它就能工作了。
注意,在代码生成输出中应该有一条关于此的INFO
消息。
https://stackoverflow.com/questions/73049505
复制相似问题