a utility for generating JSON from SQL queries using JDBC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

12 years ago
  1. jdbcjson
  2. ========
  3. JDBCJSON is a simple utility for generating JSON from SQL queries
  4. using JDBC. JDBCJSON takes a simple properties file for it's
  5. configuration.
  6. basic usage
  7. -----------
  8. First, create your properties file. JDBCJSON breaks properties down
  9. by jobs. Each job has three parameters, url, sql and out. url is
  10. the JDBC connection URL. sql is the SQL statement executed whose result
  11. is used to generate the JSON. out is the path for resulting JSON. Take
  12. the following example:
  13. mytable.url = jdbc:postgresql://localhost/mydb
  14. mytable.sql = SELECT * FROM mytable
  15. mytable.out = mytable.json
  16. This properties file will create a job called "mytable" that will query
  17. a postgresql database on localhost, selecting all the columns from
  18. mytable, and output the result to mytable.json. Multiple jobs may be
  19. specified in a single properties file.
  20. Next, run JDBCJSON. It's always a good idea to specify the debug switch
  21. the first time you run a new properties file against JDBC. The debug
  22. switch will give you additional warnings about things like unsupported
  23. fields (BLOBs, for example.)
  24. java -jar jdbcjson.jar -d mytable.properties
  25. advanced usage
  26. --------------
  27. Only the url parameter of a properties file is required. The other two
  28. properties have default values, based on the job name. The sql parameter
  29. defaults to "SELECT * FROM <jobname>". The out parameter defaults to
  30. "<jobname>.json". Thus,
  31. mytable.url = jdbc:postgresql://localhost/mydb
  32. Is the same as
  33. mytable.url = jdbc:postgresql://localhost/mydb
  34. mytable.sql = SELECT * FROM mytable
  35. mytable.out = mytable.json