私はdatabene benerator (最新のもの 0.8.1) を使用することを学んでいますが、H2 データベース (以前は 1.3.170 で、現在は 1.3.171) にデータを入力しようとして問題が発生しています。まず最初に、カタログの null 例外を取得していましたが、ベネレーターのドキュメント (0.7.6) をさらに読むと、これが見つかりました
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" />
と
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" />
だから私はデータベースタグにカタログとスキーマ名を明示的に書きました
<database id="db"
url="jdbc:h2:tcp://localhost/D:/databases/databaseName"
driver="org.h2.Driver"
schema="PUBLIC"
user="admin"
catalog = "DATABASENAME"
password="xxxxxx"
/>
しかし、ベネレーターが最初のテーブルにデータを入力し始めたときに、テーブルの null 例外が発生し始めました。ここにスタックトレースがあります
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
何が問題なのか、または何をするのを忘れたのか? 「既存のデータベースの再現とスケーリング」を使用してプロジェクトを作成したとき、ベネレーターは主キーと外部キー、一意の制約を含め、すべてのテーブルを適切にキャプチャしました。十分に柔軟で、オープンソースで、拡張可能で、JDBCおよびJavaデータベースをサポートする他のデータジェネレーターが見つからないため、助けていただければ幸いです