Why does not jOOQ generate code for SQLite database?

2,017 views
Skip to first unread message

Вячеслав Бойко

unread,
Aug 22, 2014, 5:01:30 AM8/22/14
to jooq...@googlegroups.com
Hello!

I'm trying to work with SQLIte database using jOOQ in my maven-project.

Here is my dependencies:

<configuration>

<!-- JDBC connection parameters -->  
<jdbc>  
<driver>org.sqlite.JDBC</driver>  
<url>jdbc:sqlite:patan.sqlite</url>  
<user></user>  
<password></password>  
</jdbc>

<!-- Generator parameters -->  
<generator>  
<name>org.jooq.util.DefaultGenerator</name>  
<database>  
<name>org.jooq.util.sqlite.SQLiteDatabase</name>  
<includes>.*</includes>  
<excludes></excludes>
<inputSchema></inputSchema>
</database>
<target>
<packageName>ru.PatAn.database</packageName>
<directory>target/database</directory>
</target>
</generator>
</configuration>


here is the result of code generation:


[INFO] No <inputSchema/> was provided. Generating ALL available schemata instead!  
[INFO] Database parameters  
[INFO] ----------------------------------------------------------  
[INFO] dialect : SQLITE  
[INFO] target dir : target/database  
[INFO] target package : ru.diowo.PatAn.database  
[INFO] ----------------------------------------------------------  
[INFO]  
[INFO] DefaultGenerator parameters
[INFO] ----------------------------------------------------------
[INFO] strategy : class org.jooq.util.DefaultGeneratorStrategy
[INFO] deprecated : true
[INFO] generated annotation : true
[INFO] JPA annotations : false
[INFO] validation annotations : false
[INFO] instance fields : true
[INFO] records : true
[INFO] pojos : false
[INFO] immutable pojos : false
[INFO] interfaces : false
[INFO] daos : false
[INFO] relations : true
[INFO] global references : true
[INFO] ----------------------------------------------------------
[INFO] Emptying : /home/bvn13/workspace/PatAn/ru.diowo.PatAn.database/target/database/ru/diowo/PatAn/database
[INFO] Generating schemata : Total: 1
[INFO] Generating schema : DefaultSchema.java
[INFO] ----------------------------------------------------------
[INFO] Sequences fetched : 0 (0 included, 0 excluded)
[INFO] Tables fetched : 0 (0 included, 0 excluded)
[INFO] UDTs fetched : 0 (0 included, 0 excluded)
[INFO] ARRAYs fetched : 0 (0 included, 0 excluded)
[INFO] Enums fetched : 0 (0 included, 0 excluded)
[INFO] Routines fetched : 0 (0 included, 0 excluded)
[INFO] Packages fetched : 0 (0 included, 0 excluded)
[INFO] GENERATION FINISHED! : Total: 528.291ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS


and here is my libs and their versions:

    <dependency>
       
<groupId>org.jooq</groupId>
       
<artifactId>jooq</artifactId>
       
<version>3.3.1</version>
   
</dependency>
   
<dependency>
       
<groupId>org.jooq</groupId>
       
<artifactId>jooq-codegen</artifactId>
       
<version>3.3.1</version>
   
</dependency>
   
<dependency>
       
<groupId>org.jooq</groupId>
       
<artifactId>jooq-codegen-maven</artifactId>
       
<version>3.3.1</version>
       
<type>maven-plugin</type>
   
</dependency>
   
<dependency>
       
<groupId>org.jooq</groupId>
       
<artifactId>jooq-meta</artifactId>
       
<version>3.3.1</version>
   
</dependency>
   
<dependency>
       
<groupId>org.xerial</groupId>
       
<artifactId>sqlite-jdbc</artifactId>
       
<version>3.7.2</version>
   
</dependency>



Why does this occur? Why jOOQ can't read the database correctly?

The database is placed in the project directory.

Lukas Eder

unread,
Aug 22, 2014, 5:19:19 AM8/22/14
to jooq...@googlegroups.com
What happens when you execute the following query?

SELECT * FROM sqlite_master

Also, the JDBC connection URL that you're using: <url>jdbc:sqlite:patan.sqlite</url>, it points to a patan.sqlite file at the place of execution of the code generator. Are you sure you're referencing the right file in the right place? You might need to provide an absolute path to the database file instead.





--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Вячеслав Бойко

unread,
Aug 22, 2014, 5:35:50 AM8/22/14
to jooq...@googlegroups.com
My database file is placed right near pom.xml. Is it correct?

пятница, 22 августа 2014 г., 13:19:19 UTC+4 пользователь Lukas Eder написал:

Lukas Eder

unread,
Aug 22, 2014, 5:39:27 AM8/22/14
to jooq...@googlegroups.com
In principle, yes. An easy way to check if the wrong location is chosen is to see whether there are two patan.sqlite files on your disk.

Вячеслав Бойко

unread,
Aug 22, 2014, 5:48:29 AM8/22/14
to jooq...@googlegroups.com
There is only one file on my disk. I just have created it right in at described place with SQLite Database Browser.

пятница, 22 августа 2014 г., 13:39:27 UTC+4 пользователь Lukas Eder написал:

Lukas Eder

unread,
Aug 22, 2014, 5:50:49 AM8/22/14
to jooq...@googlegroups.com
And, what happens when you execute the following query?

SELECT * FROM sqlite_master

Thorsten Schöning

unread,
Aug 22, 2014, 5:55:37 AM8/22/14
to Вячеслав Бойко
Guten Tag Вячеслав Бойко,
am Freitag, 22. August 2014 um 11:48 schrieben Sie:

> There is only one file on my disk. I just have created it right in
> at described place with SQLite Database Browser.

Then just try with an absolute path, relative paths are only valid if
you exactly know what they are relative too and that can be really
hard depending on a lot of things, like current working directory,
which application uses a relative path etc.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning E-Mail:Thorsten....@AM-SoFT.de
AM-SoFT IT-Systeme http://www.AM-SoFT.de/

Telefon...........05151- 9468- 55
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

Вячеслав Бойко

unread,
Aug 22, 2014, 2:54:02 PM8/22/14
to jooq...@googlegroups.com
I have copied sqlite-jdbc-3.7.2.jar from ~/.m2/repository directory to my project dir, added it to my classpath in Eclipse and run this code:

Class.forName("org.sqlite.JDBC");
           
Connection connection = DriverManager.getConnection("jdbc:sqlite:/home/bvn13/workspace/PatAn/patan.sqlite");  
Statement statement = connection.createStatement();
System.out.println("Successfully connected.");
ResultSet resultSet = statement  
         
.executeQuery("SELECT * FROM sqlite_master");
resultSet
.next();
System.out.println("RES: "+resultSet.getString("tbl_name"));

And the result is:

Successfully connected.
RES: cases

[deleted] hm... I wanted to write that error occurs, but all is fine now. Strange...

Ok. I now understand, that it works. Fine. But I don't understand how to specify the relative path to the database into pom.xml to make jOOQ generate the sources.
OMG... I just now looked on my directories tree. My database is placed not into the directory of THIS project (maven module) but into the parent one...
Database was replaced into the right directory and jOOQ generated the code correctly.

Sorry. It was my mistake!

пятница, 22 августа 2014 г., 13:50:49 UTC+4 пользователь Lukas Eder написал:

Lukas Eder

unread,
Aug 25, 2014, 2:43:16 AM8/25/14
to jooq...@googlegroups.com
Hello,

Great to see that you were able to resolve the issue.

I suspect you could use an external config and load that config into Maven properties to specify an absolute path to the sqlite file. Petri Kainulainen has written a blog post about how to do this with jOOQ (and other Maven plugins):

This is essentially repeated in our jOOQ / Maven / Spring example project:
Reply all
Reply to author
Forward
0 new messages