首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带有jOOQ数据库的SQLite无法生成SQLite代码

带有jOOQ数据库的SQLite无法生成SQLite代码
EN

Stack Overflow用户
提问于 2022-07-20 09:55:10
回答 1查看 96关注 0票数 0

我使用jOOQ 3.16.5来生成Java代码,当我运行该代码时,终端告诉我成功,但是代码没有生成,我不知道为什么,所以我将代码复制到这里,希望有人帮助我

  1. 我是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’}
  2. 这是生成POJO类和其他文件的Java代码 进口org.jooq.codegen.GenerationTool;进口org.jooq.meta.jaxb.Configuration;进口org.jooq.meta.jaxb.Database;进口org.jooq.meta.jaxb.Generate;进口org.jooq.meta.jaxb.Generator;进口org.jooq.meta.jaxb.Jdbc;进口org.jooq.meta.jaxb.Property;进口org.jooq.meta.jaxb.Target;公共类JooqConfig { public静态void (String[] args) {String[]配置=新配置() //在这里配置数据库连接(.withJdbc(新的Jdbc() .withDriver("org.sqlite.JDBC")) .withName("org.jooq.meta.sqlite.SQLiteDatabase") .withIncludes(".*")。withExcludes(“+ "UNUSED_TABLE #此表(非限定名)不应生成”+“具有给定前缀的PREFIX_.* #对象,不应生成”+“这个表(限定名)不应该生成“+”SECRET_SCHEMA\.SECRET_TABLE SECRET_ROUTINE #这个例程(非限定名).“+”) .withInputSchema("public")) //生成标志:参见高级配置属性.withGenerate(新生成().withPojos(真).withComments(真).withCommentsOnCatalogs(真).withRelations(真).withImmutablePojos(假) //如果为真,不能使用'into()‘方法.withInterfaces(真).withDaos(真)).withTarget(新目标() .withPackageName("com.changdao.game.db") )。withDirectory(“桌面/src”) );尝试{GenerationTool.generate(配置);} catch (异常e) { e.printStackTrace();}

这是我的数据库

SQL就在这里,通过一种方式,我使用天桥创建了一个表。

代码语言:javascript
运行
复制
create table product(
     id INTEGER primary key,
     create_time TEXT
);

我使用Java 11,我不知道它是否重要

2022-07-21

就像Lukas Eder说的,我像这样修改了代码

代码语言:javascript
运行
复制
                    .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) ..." +
                                    "")
                    )

并有一些错误

代码语言:javascript
运行
复制
   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

在这里输入图像描述

EN

回答 1

Stack Overflow用户

发布于 2022-07-20 11:58:10

你已经明确指出:

代码语言:javascript
运行
复制
withInputSchema("public")

但是SQLite不支持模式。因此,它没有public模式(例如,PostgreSQL)。只要把这个去掉,它就能工作了。

注意,在代码生成输出中应该有一条关于此的INFO消息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73049505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档