Schema Spy unable to find postgresql driver

10.1k Views Asked by At

I want to use Schema Spy to generate schema diagrams,

I have specifed the following command

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/

I have the postgresql driver jar file in the same directory as schema spy jar file. But it gives the following error

[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).

Any help would be appreciated.

Thanks,

Pankaj

3

There are 3 best solutions below

2
On BEST ANSWER

I think the problem is you didn't add the classpath to the driver. You have to add your classpath like this

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.

0
On

I'd like to add a few points.

  1. You would be using Schema Spy with Graphviz. Versions 2.31+ does not add an entry to Window's System path variable. So after you download and install Graphviz update the path variable to have path till Graphviz's bin directory. (C:\Program Files (x86)\Graphviz2.38\bin)
  2. Alternative to downloading entire project source to change the classpath in the property file would be to update the jar using 7-zip.
  3. Open the jar file using 7-zip navigate to net/sourceforge/schemaspy/dbTypes/ right click pgsql.properties say edit.
  4. Change the following entry for driverPath to make it point to jdbc jar file driverPath=D:/Work/JavaProjects/tools/postgresql-9.3-1100.jdbc4.jar
  5. Click on save and update. This should do the trick.
1
On
  1. Download the driver from here.

  2. 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>
    

    One-liner on Windows:

    java -jar schemaSpy.jar  -t pgsql -host localhost:5432 -db _dbname_ -s _schena_name_ -u postgres -p  -o D:\RVA\postgreSQL\  -dp "D:\Program Files (x86)\PostgreSQL\pgJDBC\postgresql-42.2.5.jar"
    

NOTE: There are two possible values for database type's value (-t) when it comes to PostgreSQL:

$ 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
...