我想使用Schema Spy生成模式图,
我指定了以下命令
java -jar schemaSpy_5.0.0.jar -t pgsql -host 10.100.71.21[:5432] -db mydb -s public -u username -p password -dp postgresql-8.0-312.jdbc3.jar -o output/
我的postgresql驱动程序jar文件与schema spy jar文件位于同一目录中。但它给出了以下错误
[schemaSpy_5.0.0.jar]/net/sourceforge/schemaspy/dbTypes/pgsql.properties
java.lang.ClassNotFoundException: org.postgresql.Driver
Failed to load driver 'org.postgresql.Driver'from: [file:/home/panx/postgresql-8.0- 312.jdbc3.jar]
This entry doesn't point to a valid file/directory: [/whereever/postgresql-8.0-312.jdbc3.jar]
Use the -dp option to specify the location of the database
drivers for your database (usually in a .jar or .zip/.Z).
如有任何帮助,我们将不胜感激。
谢谢,
Pankaj
我认为问题在于您没有将类路径添加到驱动程序中。您必须像这样添加类路径
java -jar schemaSpy_5.0.0.jar -t pgsql -host 10.100.71.21[:5432] -db mydb -s public -u username -p password -dp /home/panx/postgresql-8.0-312.jdbc3.jar -o output/
If it does not work you can download the source code of this project. In the project there is pgsql.properties file in dbTypes folder. You can change it with your classpath and I think this solves your problem.Download the driver from here.
Specify the path to the driver file with
-dp
.For example:
java -jar schemaSpy.jar -t pgsql11 -host <host>:<port> -db <database_name> -s <schema_name> -u <database_user> -p <password> -o <output_directory> -dp <path_to_downloaded_driver>
Windows上的一行:
java -jar schemaSpy.jar -t pgsql -host localhost:5432 -db _dbname_ -s _schena_name_ -u postgres -p -o D:RVApostgreSQL -dp "D:Program Files (x86)PostgreSQLpgJDBCpostgresql-42.2.5.jar"
注意:对于PostgreSQL,数据库类型的值(
-t
)有两个可能的值:$ schemaspy --dbhelp ... INFO - PostgreSQL Before Version 11 (-t pgsql) INFO - -host host of database, may contain port INFO - -port optional port if not default INFO - -db database name INFO - PostgreSQL On Or After Version 11 (-t pgsql11) INFO - -host host of database, may contain port INFO - -port optional port if not default INFO - -db database name ...
我想补充几点。
- 您将使用带有Graphviz的Schema Spy。版本2.31+不会向Window的系统路径变量添加条目。因此,在您下载并安装Graphviz后,更新路径变量,使其具有路径,直到Graphvi兹的bin目录。(C:\Program Files(x86)\Graphviz2.38\bin)
- 下载整个项目源以更改属性文件中的类路径的另一种选择是使用7-zip更新jar
- 使用7-zip导航到net/sourceforge/schemaspy/dbTypes/打开jar文件右键单击pgsql.properties说编辑
- 更改driverPath的以下条目,使其指向jdbc jar文件driverPath=D:/Work/JavaProjects/tools/postgresql-9.3-1100.jdbc4.jar
- 单击保存并更新。这应该奏效