comparison src/main/java/nl/cwi/monetdb/client/JdbcClient.java @ 354:b1f8750e6cde

Switch to Java 8 compilation and distribution as Java 7 is no longer supported.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Wed, 12 Feb 2020 18:23:58 +0100 (2020-02-12)
parents 54137aeb1f92
children 34ce6e1b1be8
comparison
equal deleted inserted replaced
353:017e8a35eb99 354:b1f8750e6cde
39 * program. Although it looks like this client is designed for MonetDB, 39 * program. Although it looks like this client is designed for MonetDB,
40 * it demonstrates the power of the JDBC interface since it built on top 40 * it demonstrates the power of the JDBC interface since it built on top
41 * of JDBC only. 41 * of JDBC only.
42 * 42 *
43 * @author Fabian Groffen, Martin van Dinther 43 * @author Fabian Groffen, Martin van Dinther
44 * @version 1.3 44 * @version 1.4
45 */ 45 */
46 46
47 public final class JdbcClient { 47 public final class JdbcClient {
48 48
49 private static Connection con; 49 private static Connection con;
54 private static Exporter exporter; 54 private static Exporter exporter;
55 55
56 /** 56 /**
57 * JdbcClient is a command line query tool for MonetDB, similar to mclient. 57 * JdbcClient is a command line query tool for MonetDB, similar to mclient.
58 * It uses the JDBC API and the MonetDB JDBC driver to communicate with a 58 * It uses the JDBC API and the MonetDB JDBC driver to communicate with a
59 * MonetDB server. The MonetDB JDBC driver is included in the jdbcclient.jre7.jar 59 * MonetDB server. The MonetDB JDBC driver is included in the jdbcclient.jre8.jar
60 * for ease of use, so only 1 jar file is needed to use it. 60 * for ease of use, so only 1 jar file is needed to use it.
61 * 61 *
62 * <pre>Usage java -jar jdbcclient.jre7.jar 62 * <pre>Usage java -jar jdbcclient.jre8.jar
63 * [-h host[:port]] [-p port] [-f file] [-u user] 63 * [-h host[:port]] [-p port] [-f file] [-u user]
64 * [-l language] [-d database] [-e] [-D [table]] 64 * [-l language] [-d database] [-e] [-D [table]] [-X&lt;opt&gt;]
65 * [-X&lt;opt&gt;] 65 * | [--help] | [--version]
66 * or using long option equivalents --host --port --file --user --language 66 * or using long option equivalents --host --port --file --user --language
67 * --dump --echo --database. 67 * --dump --echo --database.
68 * Arguments may be written directly after the option like -p50000. 68 * Arguments may be written directly after the option like -p50000.
69 * 69 *
70 * If no host and port are given, localhost and 50000 are assumed. 70 * If no host and port are given, localhost and 50000 are assumed.
212 if (user != copts.getOption("user").getArgument()) 212 if (user != copts.getOption("user").getArgument())
213 pass = null; 213 pass = null;
214 214
215 if (copts.getOption("help").isPresent()) { 215 if (copts.getOption("help").isPresent()) {
216 System.out.print( 216 System.out.print(
217 "Usage java -jar jdbcclient.jre7.jar\n" + 217 "Usage java -jar jdbcclient.jre8.jar\n" +
218 "\t\t[-h host[:port]] [-p port] [-f file] [-u user]\n" + 218 "\t\t[-h host[:port]] [-p port] [-f file] [-u user]\n" +
219 "\t\t[-l language] [-d database] [-e] [-D [table]]\n" + 219 "\t\t[-l language] [-d database] [-e] [-D [table]] [-X<opt>]\n" +
220 "\t\t[-X<opt>]\n" + 220 "\t\t| [--help] | [--version]\n" +
221 "or using long option equivalents --host --port --file --user --language\n" + 221 "or using long option equivalents --host --port --file --user --language\n" +
222 "--dump --echo --database.\n" + 222 "--dump --echo --database.\n" +
223 "Arguments may be written directly after the option like -p50000.\n" + 223 "Arguments may be written directly after the option like -p50000.\n" +
224 "\n" + 224 "\n" +
225 "If no host and port are given, localhost and 50000 are assumed.\n" + 225 "If no host and port are given, localhost and 50000 are assumed.\n" +
677 break; 677 break;
678 } else if (command.equals("\\?") || command.equals("\\h")) { 678 } else if (command.equals("\\?") || command.equals("\\h")) {
679 out.println("Available commands:"); 679 out.println("Available commands:");
680 out.println("\\q quits this program (you can also use: quit or exit)"); 680 out.println("\\q quits this program (you can also use: quit or exit)");
681 if (dbmd != null) { 681 if (dbmd != null) {
682 out.println("\\d list available tables and views in current schema"); 682 out.println("\\d list available user tables and views in current schema");
683 out.println("\\dS list available system tables and views in sys schema"); 683 out.println("\\dS list available system tables and views in sys schema");
684 out.println("\\d <obj> describes the given table or view"); 684 out.println("\\d <obj> describes the given table or view");
685 } 685 }
686 out.println("\\l<uri> executes the contents of the given file or URL"); 686 out.println("\\l<uri> executes the contents of the given file or URL");
687 out.println("\\i<uri> batch executes the inserts from the given file or URL"); 687 out.println("\\i<uri> batch executes the inserts from the given file or URL");
934 stmt.clearWarnings(); 934 stmt.clearWarnings();
935 935
936 warn = con.getWarnings(); 936 warn = con.getWarnings();
937 while (warn != null) { 937 while (warn != null) {
938 // suppress warning when issueing a "set schema xyz;" command 938 // suppress warning when issueing a "set schema xyz;" command
939 if ( !(warn.getMessage()).equals("Server enabled auto commit mode while local state already was auto commit.") ) 939 // if ( !(warn.getMessage()).equals("Server enabled auto commit mode while local state already was auto commit.") )
940 System.err.println("Connection warning: " + warn.getMessage()); 940 System.err.println("Connection warning: " + warn.getMessage());
941 warn = warn.getNextWarning(); 941 warn = warn.getNextWarning();
942 } 942 }
943 con.clearWarnings(); 943 con.clearWarnings();
944 } 944 }