尝试使用OSX使用schemacrawler连接到sqlite db-为什么它要求用户? [英] Trying to connect to sqlite db using schemacrawler using OSX - why is it asking for a user?

查看:75
本文介绍了尝试使用OSX使用schemacrawler连接到sqlite db-为什么它要求用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结论见底:

我正在尝试使用schemacrawler绘制sqlite数据库.我的设置:

I'm trying to use schemacrawler to diagram a sqlite database. My setup:

  • OSX 10.8
  • 此处 SchemaCrawler 10.5 >
  • 从Oracle下载的Java版本1.7.0_45
  • sqlite版本:3.7.12 2012-04-03 19:43:07 86b8481be7e76cccc92d14ce762d21bfb69504af
  • OSX 10.8
  • SchemaCrawler 10.5 downloaded from Here
  • Java version 1.7.0_45 downloaded from Oracle
  • sqlite version: 3.7.12 2012-04-03 19:43:07 86b8481be7e76cccc92d14ce762d21bfb69504af

我位于安装schemacrawler的目录中,并且使用以下命令行:

I'm in the directory where I installed schemacrawler, and using this command line:

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要求我输入密码?

If I specify -password, I get the same error, and specifying various values for -user does the same. Sqlite requires no user/password - why is the jdbc or schemacrawler asking me for one?

附录:

以下是一系列特定的命令,它们创建一个简单的数据库,然后尝试使用schemacrawler对其进行图示:

Here is a specific series of commands that creates a simple database then attempts to diagram it with 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使用我的名字作为命令行的一部分来生成其他进程,则可能不得不对空格进行两次转义.

Final conclusion: The problem lay in the fact that the path to my db had a space in it; no combination of backslashing, double or single quotes, or both resolved the issue. Running the command from the same directory as my db file did the trick. The space issue may be due to my not understanding the right escape sequences to use in bash - I may have to double-escape the spaces if schemacrawler is spawning other processes using my name as part of the command line.

但是,该应用程序确实继续询问我的密码,但是只需按Enter键就可以成功继续.

However, the app did continue to ask for my password, but just pressing enter allowed it to continue successfully.

推荐答案

史蒂夫

您需要这样指定数据库:

You need to specify the database like this:

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

请注意在双引号中应留出数据库文件路径中的空格,以及-database命令行开关.我还删除了反斜杠,因为整个开关都用双引号引起来.

Notice the double-quotes to allow for the space in the path to the database file, and the -database command-line switch. I also removed the back-slash, since the whole switch in enclosed in double-quotes.

要获取命令行帮助,只需运行:

For help on the command-line, simply run:

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

Sualeh Fatehi, SchemaCrawler

Sualeh Fate SchemaCrawler

这篇关于尝试使用OSX使用schemacrawler连接到sqlite db-为什么它要求用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆