5

結論については下部を参照してください。

schemacrawler を使用して sqlite データベースを図にしようとしています。私のセットアップ:

  • OS X 10.8
  • ここからダウンロードしたSchemaCrawler 10.5
  • Oracle からダウンロードした Java バージョン 1.7.0_45
  • sqlite バージョン: 3.7.12 2012-04-03 19:43:07 86b8481be7e76cccc92d14ce762d21bfb69504af

schemacrawler をインストールしたディレクトリにいて、次のコマンド ラインを使用しています。

stebro$ java -classpath lib/*:. schemacrawler.tools.sqlite.Main /Library/Application\ Support/MyApp/Data/MyApp.db -command="select count(*) from myTable" -infolevel=maximum
SchemaCrawler 10.5
Copyright (c) 2000-2013, Sualeh Fatehi.

SchemaCrawler is a database schema discovery and comprehension tool. 
You can search for database schema objects using regular expressions, 
and output the schema and data in a readable text format. You can find 
potential schema design issues with lint. The output serves for 
database documentation is designed to be diff-ed against other database 
schemas. SchemaCrawler also generates schema diagrams.
password: 
java.sql.SQLException: Could not connect to database, for user null
    at schemacrawler.schemacrawler.BaseDatabaseConnectionOptions.getConnection(BaseDatabaseConnectionOptions.java:93)
    at schemacrawler.schemacrawler.BaseDatabaseConnectionOptions.getConnection(BaseDatabaseConnectionOptions.java:70)
    at schemacrawler.tools.commandline.SchemaCrawlerCommandLine.execute(SchemaCrawlerCommandLine.java:173)
    at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:93)
    at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:52)
    at schemacrawler.tools.sqlite.Main.main(Main.java:43)
Caused by: java.lang.IllegalArgumentException: Insufficient parameters for database connection URL: missing [database]
    at schemacrawler.schemacrawler.DatabaseConfigConnectionOptions.getConnectionUrl(DatabaseConfigConnectionOptions.java:73)
    at schemacrawler.schemacrawler.BaseDatabaseConnectionOptions.getConnection(BaseDatabaseConnectionOptions.java:89)
    ... 5 more

-password を指定すると同じエラーが発生し、-user にさまざまな値を指定しても同じことが起こります。Sqlite はユーザー/パスワードを必要としません - なぜ jdbc または schemacrawler が私にそれを要求するのですか?

補遺:

以下は、単純なデータベースを作成し、schemacrawler で図を作成しようとする特定の一連のコマンドです。

bash-3.2$ sqlite3 MyApp.db
sqlite3 MyApp.db
SQLite version 3.7.12 2012-04-03 19:43:07
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table smbtest(col1 integer, col2 integer);
create table smbtest(col1 integer, col2 integer);
sqlite> ^D 
bash-3.2$ ~/bin/sunjava -classpath lib/*:. schemacrawler.tools.sqlite.Main -database=MyApp.db -infolevel=maximum -command=graph -outputformat=pdf -outputfile=myapp.pdf
SchemaCrawler 10.5
Copyright (c) 2000-2013, Sualeh Fatehi.

SchemaCrawler is a database schema discovery and comprehension tool. 
You can search for database schema objects using regular expressions, 
and output the schema and data in a readable text format. You can find 
potential schema design issues with lint. The output serves for 
database documentation is designed to be diff-ed against other database 
schemas. SchemaCrawler also generates schema diagrams.
password: 

Graphviz was not available to create the requested graph. Please reinstall 
Graphviz, and make it available on the system PATH. Meanwhile, a .dot text file 
has been created instead. This .dot file can be opened in any Graphviz file 
viewer.
java.io.IOException: Cannot run program "dot": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at schemacrawler.tools.integration.graph.ProcessExecutor.execute(ProcessExecutor.java:124)
at schemacrawler.tools.integration.graph.GraphGenerator.generateDiagram(GraphGenerator.java:87)
at schemacrawler.tools.integration.graph.GraphExecutable.executeOn(GraphExecutable.java:123)
at schemacrawler.tools.executable.SchemaCrawlerExecutable.executeOn(SchemaCrawlerExecutable.java:87)
at schemacrawler.tools.executable.BaseExecutable.execute(BaseExecutable.java:77)
at schemacrawler.tools.commandline.SchemaCrawlerCommandLine.execute(SchemaCrawlerCommandLine.java:176)
at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:93)
at schemacrawler.tools.commandline.SchemaCrawlerMain.main(SchemaCrawlerMain.java:52)
at schemacrawler.tools.sqlite.Main.main(Main.java:43)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 9 more

最終的な結論: 問題は、私のデータベースへのパスにスペースが含まれていたという事実にありました。バックスラッシュ、二重引用符、単一引用符、またはその両方を組み合わせても問題は解決しませんでした。私のdbファイルと同じディレクトリからコマンドを実行すると、うまくいきました。スペースの問題は、bash で使用する正しいエスケープ シーケンスを理解していないことが原因である可能性があります。schemacrawler がコマンド ラインの一部として自分の名前を使用して他のプロセスを生成している場合は、スペースを二重にエスケープする必要があります。

ただし、アプリは引き続きパスワードを要求しましたが、Enter キーを押すだけで正常に続行できました。

4

3 に答える 3

1

スティーブ、

次のようにデータベースを指定する必要があります。

"-database=/Library/Application Support/MyApp/Data/MyApp.db"

データベース ファイルへのパスにスペースを確保するための二重引用符と、-database コマンド ライン スイッチに注意してください。スイッチ全体が二重引用符で囲まれているため、バックスラッシュも削除しました。

コマンドラインでヘルプが必要な場合は、次のコマンドを実行してください:

java -classpath lib/*:. schemacrawler.tools.sqlite.Main

Sualeh Fatehi、SchemaCrawler

于 2013-11-01T23:53:19.607 に答える
0

私はあなたが-classpath正しく指定しているとは思わない。.jarそれぞれを展開して文字libで区切るには、そのコマンドの周りにラッパーシェルスクリプトが必要だと思います:

#!/bin/sh

classpath="."

for j in lib/*.jar
do
    classpath=$classpath:$j
done

java -classpath $classpath schemacrawler.tools.sqlite.Main /Library/Application\ Support/MyApp/Data/MyApp.db -command="select count(*) from myTable" -infolevel=maximum

ただの突き刺しですが、それが私がいつも行ってきた方法です。jar非クラスパスも含める必要がある場合、明らかにこれはより複雑になります...

于 2013-10-29T14:30:23.023 に答える