Updated README with better examples and driver parameter

This commit is contained in:
Christopher Ramey 2012-08-23 03:46:12 +00:00 committed by cdramey
parent 45e3f863f5
commit 01bb3ba36a

View File

@ -10,19 +10,23 @@ basic usage
----------- -----------
First, create your properties file. JDBCJSON breaks properties down First, create your properties file. JDBCJSON breaks properties down
by jobs. Each job has three parameters, url, sql and out. url is by jobs. Each job has four parameters: `driver`, `url`, `sql`, and `out`.
the JDBC connection URL. sql is the SQL statement executed whose result `driver` is an optional parameter for specifying the driver class to be
is used to generate the JSON. out is the path for resulting JSON. Take registered. `driver` is only required for non-JDBC4 drivers. JDBC4 drivers
the following example: should self register. `url` is the JDBC connection URL (see your driver
documentation for more details.) `sql` is the SQL statement executed
whose result is used to generate the JSON. `out` is the path for
resulting JSON. Take the following example:
mytable.url = jdbc:postgresql://localhost/mydb people.driver = net.sourceforge.jtds.jdbc.Driver
mytable.sql = SELECT * FROM mytable people.url = jdbc:jtds:sqlserver://myserver/db;user=sa;password=sa
mytable.out = mytable.json people.sql = SELECT * FROM people
people.out = people.json
This properties file will create a job called "mytable" that will query This properties file will create a job called _people_ that will query
a postgresql database on localhost, selecting all the columns from a SQL Server database on localhost, selecting all the columns from
mytable, and output the result to mytable.json. Multiple jobs may be _people_, and output the result to _people.json_. Multiple jobs may be
specified in a single properties file. specified in a single properties file.
@ -31,21 +35,21 @@ the first time you run a new properties file against JDBC. The debug
switch will give you additional warnings about things like unsupported switch will give you additional warnings about things like unsupported
fields (BLOBs, for example.) fields (BLOBs, for example.)
java -jar jdbcjson.jar -d mytable.properties java -jar jdbcjson.jar -d people.properties
advanced usage advanced usage
-------------- --------------
Only the url parameter of a properties file is required. The other two Only the url parameter of a properties file is required. The `url` and `out`
properties have default values, based on the job name. The sql parameter properties have default values, based on the job name. The `sql` parameter
defaults to "SELECT * FROM <jobname>". The out parameter defaults to defaults to `SELECT * FROM <jobname>`. The `out` parameter defaults to
"<jobname>.json". Thus, `<jobname>.json`. Thus:
mytable.url = jdbc:postgresql://localhost/mydb mytable.url = jdbc:postgresql://localhost/mydb?user=postgres&password=postgres
Is the same as Is the same as:
mytable.url = jdbc:postgresql://localhost/mydb mytable.url = jdbc:postgresql://localhost/mydb?user=postgres&password=postgres
mytable.sql = SELECT * FROM mytable mytable.sql = SELECT * FROM mytable
mytable.out = mytable.json mytable.out = mytable.json