Question

I have been learning to use databene benerator (the latest one 0.8.1), but i'm having a problem trying to populate a H2 database (was 1.3.170 and now 1.3.171). first of all i was getting catalog null exception, but on reading further the benerator documentation (0.7.6), i found this

When importing database metadata, you might encounter exceptions when Benerator tries to get metadata of catalogs or schemas it has no access privileges to. Usually can fix this by choosing the right schema for your database, e.g. <database id="db" ... schema="PUBLIC" />

and

Table X not found in the expected catalog Y and schema Z This message tells you, that you database configuration is wrong. Check and fix the 'schema' and 'catalog' settings in your database configuration, e.g. <database … catalog="main" schema="Z" />

so i explicitly wrote the catalog and schema name in the database tag

    <database id="db"
        url="jdbc:h2:tcp://localhost/D:/databases/databaseName"
        driver="org.h2.Driver"
        schema="PUBLIC"
        user="admin"
        catalog = "DATABASENAME"
        password="xxxxxx"
    />

but then i started getting Table null exception when benerator is just starting to populate the first table, here is the stacktrace

D:\test3> benerator benerator.xml
Local classpath: .;D:\databene-benerator-0.8.1\bin;D:\databene-benerator-0.8.1\lib\*
12:06:58,495 INFO  (main) [CONFIG] Running file benerator.xml
12:06:58,511 INFO  (main) [CONFIG] Benerator 0.8.1 build 2335
12:06:58,511 INFO  (main) [CONFIG] Java version 1.7.0_17
12:06:58,511 INFO  (main) [CONFIG] JVM Java HotSpot(TM) Client VM 23.7-b01 (Oracle   
Corporation)
12:06:58,511 INFO  (main) [CONFIG] OS Windows 7 6.1 (x86)
12:06:58,511 INFO  (main) [CONFIG] Installed JSR 223 Script Engines:
12:06:58,526 INFO  (main) [CONFIG] - Mozilla Rhino[js, rhino, JavaScript, javascript, 
ECMAScript, ecmascript]
12:06:58,526 INFO  (main) [CONFIG] Max heap size: 247 MB
12:06:58,636 DEBUG (main) [CONFIG] Initializing Script mapping from file org/databene 
/script/script.properties
12:06:59,837 DEBUG (main) [COMMENT] Reproduces an existing database
12:06:59,837 DEBUG (main) [COMMENT] defining a database that will be referred by the  
id 'db' later
12:06:59,868 DEBUG (main) [COMMENT] Drop the current tables and sequences if they 
already exist
12:06:59,884 INFO  (main) [EvaluateStatement] Executing script drop_hotel_tables.sql
12:07:00,118 INFO  (main) [JDBC] Connected to H2 1.3.171 (2013-03-17)
12:07:00,118 INFO  (main) [JDBC] Using driver H2 JDBC Driver 1.3.171 (2013-03-17)
12:07:00,118 INFO  (main) [JDBC] JDBC version 4.0
12:07:00,180 DEBUG (main) [COMMENT] Create the tables and sequences
12:07:00,180 INFO  (main) [EvaluateStatement] Executing script create_tables_h2.sql
12:07:00,227 DEBUG (main) [COMMENT] Generating a single constant profile...
12:07:00,305 INFO  (main) [JDBCDBImporter] Importing tables from environment '___temp'
12:07:00,336 INFO  (main) [DefaultDBSystem] Fetching table details and ordering  
tables  by dependency

12:07:00,508 INFO  (main) [TaskExecutor] Running task  
StateTrackingTaskProxy[GenerateAndConsumeTask(PROFILE)]
12:07:00,508 ERROR (main) [DescriptorRunner] Error in Benerator execution
    org.databene.commons.ObjectNotFoundException: Table null
    at org.databene.platform.db.DBSystem.getTable(DBSystem.java:802)
    at org.databene.platform.db.DBSystem.getWriteColumnInfos(DBSystem.java:744)
    at org.databene.platform.db.DBSystem.persistOrUpdate(DBSystem.java:831)
    at org.databene.platform.db.DBSystem.store(DBSystem.java:360)
    at  

    org.databene.benerator.storage.StorageSystemInserter.startProductConsumption(
    StorageSystemInserter.java:53)
    at   
    org.databene.benerator.consumer.AbstractConsumer.startConsuming(AbstractConsumer.
    java:47)
    at   
    org.databene.benerator.consumer.ConsumerProxy.startConsuming(
    ConsumerProxy.java:62)
    at org.databene.benerator.engine.statement.ConsumptionStatement.execute(
    ConsumptionStatement.java:53)
    at org.databene.benerator.engine.statement.GenerateAndConsumeTask.execute(
    GenerateAndConsumeTask.java:159)
    at org.databene.task.TaskProxy.execute(TaskProxy.java:59)
    at org.databene.task.StateTrackingTaskProxy.execute(StateTrackingTaskProxy.java:52)
    at org.databene.task.TaskExecutor.runWithoutPage(TaskExecutor.java:136)
    at org.databene.task.TaskExecutor.runPage(TaskExecutor.java:126)
    at org.databene.task.TaskExecutor.run(TaskExecutor.java:101)
    at org.databene.task.TaskExecutor.run(TaskExecutor.java:77)
    at org.databene.task.TaskExecutor.execute(TaskExecutor.java:71)
    at org.databene.benerator.engine.statement.GenerateOrIterateStatement.executeTask(
    GenerateOrIterateStatement.java:156)
    at org.databene.benerator.engine.statement.GenerateOrIterateStatement.execute(
    GenerateOrIterateStatement.java:99)
    at   
    org.databene.benerator.engine.statement.LazyStatement.execute(LazyStatement.
    java:58)
    at  
    org.databene.benerator.engine.statement.StatementProxy.execute(
    StatementProxy.java:46)
    at org.databene.benerator.engine.statement.TimedGeneratorStatement.execute(
    TimedGeneratorStatement.java:70)
    at    
    org.databene.benerator.engine.statement.SequentialStatement.executeSubStatements(
    SequentialStatement.java:52)
    at org.databene.benerator.engine.statement.SequentialStatement.execute(
    SequentialStatement.java:47)
    at org.databene.benerator.engine.BeneratorRootStatement.execute(
    BeneratorRootStatement.java:63)
    at   
    org.databene.benerator.engine.DescriptorRunner.execute(DescriptorRunner.java:127)
    at org.databene.benerator.engine.DescriptorRunner.runWithoutShutdownHook(
    DescriptorRunner.java:109)
    at org.databene.benerator.engine.DescriptorRunner.run(DescriptorRunner.java:102)
    at org.databene.benerator.main.Benerator.runFile(Benerator.java:99)
    at org.databene.benerator.main.Benerator.runFromCommandLine(Benerator.java:82)
    at org.databene.benerator.main.Benerator.main(Benerator.java:75)
12:07:00,617 INFO  (main) [CachingDBImporter] Exporting Database meta data of ___temp 
to cache file
12:07:00,695 INFO  (main) [CONFIG] Max. committed heap size: 15 MB

what could be the issue, or what have i forgotten to do? for when i created the project using "reproduce and scale existing database", benerator captured all the tables properly even the primary and foreign key and unique constraints. help would be appreciated since i have not found any other data generator that is flexible enough, open source, extensible and supports JDBC and java databases

Was it helpful?

Solution

This is what i finally came to realize about databene benerator. If you are using mysql as your database of choice, always let the schema and the catalog attribute in the database definition be the same as the database name. Like this

<database id="db"
    url="jdbc:mysql://localhost:3306/DatabaseName"
    driver="org.h2.Driver"
    schema="DatabaseName"
    catalog = "DatabaseName"
    user="admin"
    password="xxxxxx"
/>

It will give you an output like

[WARNING] Table 'TableName' not found in the expected catalog 'DatabaseName' and schema 'DatabaseName'. I have taken it from catalog 'DatabaseName' and schema 'null' instead. You better make sure this is right and fix the configuration

but it is actually doing what you want. I haven't tried with other databases, but i hope it works for them too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top