THIS IS A FORK FROM https://sourceforge.net/projects/jdbcsql/ PORTED TO GRADLE
java -cp postgresql-9.3-1102-jdbc4.jar:jdbc2csv-2.1.jar com.azsoftware.jdbc2csv.Main \
-u 'jdbc:postgresql://host:port/dbname?user=postgres&password=secretkey' <<EOF
select version()
EOF
echo 'select version()' | java -cp postgresql-9.3-1102-jdbc4.jar:jdbc2csv-2.1.jar com.azsoftware.jdbc2csv.Main \
-f PostgreSQLText \
-u 'jdbc:postgresql://host:port/dbname?user=postgres&password=secretkey'
$ java -jar jdbc2csv-2.0.jar
jdbc2csv execute queries in JDBC copmpatible databases such as mysql, oracle, postgresql etc.
Run a SQL query with resultset output to stdout in CSV format.
usage: jdbc2csv [OPTION]... SQL
-f,--csv-format <FORMAT> Output CSV format with possibale values:
Default, Excel, InformixUnload,
InformixUnloadCsv, MongoDBCsv, MongoDBTsv,
MySQL, Oracle, PostgreSQLCsv,
PostgreSQLText, RFC4180 and TDF. Default
format is "Default".
-h,--help show this help, then exit
-H,--hide-headers hide headers on output
-u,--jdbc-url <URL STRING> JDBC driver connection URL string
$ java -cp postgresql-9.3-1102-jdbc4.jar:jdbc2csv-2.0.jar com.azsoftware.jdbc2csv.Main \
-f PostgreSQLText \
-u 'jdbc:postgresql://host:port/dbname?user=postgres&password=secretkey' \
'select version()'
$ java -cp ojdbc8-12.2.0.1.jar:jdbc2csv-2.0.jar com.azsoftware.jdbc2csv.Main \
-u 'jdbc:oracle:thin:<user>/<password>@host:port:dbname' \
'select * from V$VERSION'
$ java -cp mysql-connector-java-8.0.18.jar:jdbc2csv-2.0.jar com.azsoftware.jdbc2csv.Main \
-u 'jdbc:mysql://user:password@host:port/dbname' \
'SHOW VARIABLES LIKE "%version%"'