我尝试使用 SchemaSpy 连接到我的 PostgresSQL 服务器。我使用 ppa:webupd8team/java 中的
oracle-java8-installer
安装了 Java。
(我的 PostgreSQL 服务器在 Docker 容器上工作,所以我将端口转发到 5431)
我的 schemaspy.properties
文件是:
# type of database. Run with -dbhelp for details
schemaspy.t=pgsql
# optional path to alternative jdbc drivers.
# database properties: host, port number, name user, password
schemaspy.host=localhost:5431
schemaspy.port=5431
schemaspy.db=dbname
schemaspy.u=dbuser
schemaspy.p=dbpassword
# output dir to save generated files
schemaspy.o=dbschema
# db scheme for which generate diagrams
schemaspy.s=public
当我运行这个命令时:
java -jar schemaspy-6.0.0.jar -configFile schemaspy.properties
我确定可以在 lcoalhost:5431 上访问数据库。但是我收到:
user@hostname:~/path-to-app$ java -jar schemaspy-6.0.0.jar -configFile schemaspy.properties ____ _ ____ / ___| ___| |__ ___ _ __ ___ __ _/ ___| _ __ _ _ \___ \ / __| '_ \ / _ \ '_ ` _ \ / _` \___ \| '_ \| | | | ___) | (__| | | | __/ | | | | | (_| |___) | |_) | |_| | |____/ \___|_| |_|\___|_| |_| |_|\__,_|____/| .__/ \__, | |_| |___/ 6.0.0 SchemaSpy generates an HTML representation of a database schema's relationships. SchemaSpy comes with ABSOLUTELY NO WARRANTY. SchemaSpy is free software and can be redistributed under the conditions of LGPL version 3 or later. http://www.gnu.org/licenses/ INFO - Starting Main v6.0.0 on hostname with PID 18555 (/home/user/path-to-app/schemaspy-6.0.0.jar started by user in /home/user/path-to-app) INFO - The following profiles are active: default INFO - Found configuration file: schemaspy.properties INFO - Started Main in 3.406 seconds (JVM running for 4.519) INFO - Starting schema analysis WARN - Connection Failure
我应该添加驱动程序吗?我尝试使用 postgresql-42.2.4.jar
。我是从jdbc.postgresql.org下载的站点并将此行添加到配置文件。
schemaspy.dp=postgresql-42.2.4.jar
但是它仍然显示相同的错误。
最佳答案
好吧,我终于知道问题出在哪里了。这行 schemaspy.dp=postgresql-42.2.4.jar
应该直接添加到数据库类型的定义之后。现在我的 schemaspy.properties
文件是:
# type of database. Run with -dbhelp for details
schemaspy.t=pgsql
# optional path to alternative jdbc drivers.
schemaspy.dp=postgresql-42.2.4.jar
# database properties: host, port number, name user, password
schemaspy.host=localhost:5431
schemaspy.port=5431
schemaspy.db=dbname
schemaspy.u=dbuser
schemaspy.p=dbpassword
# output dir to save generated files
schemaspy.o=/home/user/dump
# db scheme for which generate diagrams
schemaspy.s=public
并且正常工作。
关于java - SchemaSpy PostgreSQL - 警告 - 连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51726374/