GithubHelp home page GithubHelp logo

waitingforhandle / jdbcjson Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cramey/jdbcjson

0.0 2.0 0.0 100 KB

JDBCJSON is a simple utility for generating JSON from SQL queries using JDBC

License: BSD 2-Clause "Simplified" License

Java 100.00%

jdbcjson's Introduction

jdbcjson

JDBCJSON is a simple utility for generating JSON from SQL queries using JDBC. JDBCJSON takes a simple properties file for it's configuration.

basic usage

First, create your properties file. JDBCJSON breaks properties down by jobs. Each job has four parameters: driver, url, sql, and out. driver is an optional parameter for specifying the driver class to be registered. driver is only required for non-JDBC4 drivers. JDBC4 drivers 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:

    people.driver = net.sourceforge.jtds.jdbc.Driver
    people.url = jdbc:jtds:sqlserver://myserver/db;user=sa;password=sa
    people.sql = SELECT * FROM people
    people.out = people.json

This properties file will create a job called people that will query a SQL Server database on localhost, selecting all the columns from people, and output the result to people.json. Multiple jobs may be specified in a single properties file.

Next, run JDBCJSON. It's always a good idea to specify the debug switch the first time you run a new properties file against JDBC. The debug switch will give you additional warnings about things like unsupported fields (BLOBs, for example.)

    java -jar jdbcjson.jar -d people.properties

advanced usage

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 defaults to SELECT * FROM <jobname>. The out parameter defaults to <jobname>.json. Thus:

    mytable.url = jdbc:postgresql://localhost/mydb?user=postgres&password=postgres

Is the same as:

    mytable.url = jdbc:postgresql://localhost/mydb?user=postgres&password=postgres
    mytable.sql = SELECT * FROM mytable
    mytable.out = mytable.json

jdbcjson's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.