15

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

Pankaj Bhambhani
  • 659
  • 3
  • 12
  • 20
  • Is there any configuration file which has this line /whereever/postgresql-8.0-312.jdbc3.jar . Maybe it is something you have to edit. – mbaydar Apr 05 '12 at 13:56
  • @mbaydar The -dp configuration is used to specify path to driver file which is what I am doing – Pankaj Bhambhani Apr 05 '12 at 19:45
  • Can you add your configuration file ? – mbaydar Apr 05 '12 at 19:51
  • The configuration file is actually embedded in SchemaSpy.jar. I cant modify it by I can override it by using "-dp" option. – Pankaj Bhambhani Apr 05 '12 at 20:04
  • Please do **not** use that out-dated and obsolete driver. Use a current driver (9.0 or 9.1). If your driver is actually matching your PostgreSQL version you should immediately update to a supported and current version. –  Apr 06 '12 at 07:52

3 Answers3

19

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.
Ramy
  • 20,541
  • 41
  • 103
  • 153
mbaydar
  • 1,144
  • 1
  • 13
  • 18
  • Downloading the source code was the only option left with me. And it worked :) – Pankaj Bhambhani Apr 12 '12 at 22:02
  • 4
    I did not know where to look for the jdbc3 driver path on my computer so I downloaded it from this page: http://jdbc.postgresql.org/download.html and it worked. – poiuytrez Oct 16 '13 at 09:51
4
  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
...
toraritte
  • 6,300
  • 3
  • 46
  • 67
  • Could you add backticks around the executable statements, it makes the comment more readable and easier to execute the commands. – Marthyn Olthof Jun 18 '19 at 14:01
3

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.
albert
  • 8,285
  • 3
  • 19
  • 32
jithin iyyani
  • 751
  • 1
  • 7
  • 19