Mercurial > hg > monetdb-java
changeset 391:f523727db392
Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
This naming complies to the Java Package Naming convention as MonetDB's main website is www.monetdb.org.
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,22 @@ # ChangeLog file for monetdb-java # This file is updated with Maddlog +* Thu Nov 12 2020 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> +- Moved Java classes from packages starting with nl.cwi.monetdb.* + to package org.monetdb.* This naming complies to the Java Package + Naming convention as MonetDB's main website is www.monetdb.org. + To prevent problems with existing Java programs and JDBC driver + configurations we still support usage of the following classes: + nl.cwi.monetdb.jdbc.MonetDriver + nl.cwi.monetdb.jdbc.types.INET + nl.cwi.monetdb.jdbc.types.URL + nl.cwi.monetdb.mcl.net.MapiSocket + nl.cwi.monetdb.client.JdbcClient + They are implemented as simple wrappers of their org.monetdb.* equivalents. + Note: These nl.cwi.monetdb.* classes are now marked as deprecated and may be + removed in a future release. If you still use them in your Java code, + update them to use the new package names. + * Thu Oct 29 2020 Martin van Dinther <martin.van.dinther@monetdbsolutions.com> - Extended JdbcClient program with 3 new commands to quickly validate data integrity:
--- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ -all: src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java +all: src/main/java/org/monetdb/jdbc/MonetDriver.java ant -f build.xml distjdbc distmerocontrol cd tests; ant -f build.xml jar_jdbctests -src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java: build.properties src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in - . ./build.properties; sed -e "s/@MCL_MAJOR@/$$MCL_MAJOR/g;s/@MCL_MINOR@/$$MCL_MINOR/g;s/@JDBC_MAJOR@/$$JDBC_MAJOR/g;s/@JDBC_MINOR@/$$JDBC_MINOR/g;s/@JDBC_VER_SUFFIX@/$$JDBC_VER_SUFFIX $$buildno/g;s/@JDBC_DEF_PORT@/$$JDBC_DEF_PORT/g" src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in > src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java +src/main/java/org/monetdb/jdbc/MonetDriver.java: build.properties src/main/java/org/monetdb/jdbc/MonetDriver.java.in + . ./build.properties; sed -e "s/@MCL_MAJOR@/$$MCL_MAJOR/g;s/@MCL_MINOR@/$$MCL_MINOR/g;s/@JDBC_MAJOR@/$$JDBC_MAJOR/g;s/@JDBC_MINOR@/$$JDBC_MINOR/g;s/@JDBC_VER_SUFFIX@/$$JDBC_VER_SUFFIX $$buildno/g;s/@JDBC_DEF_PORT@/$$JDBC_DEF_PORT/g" src/main/java/org/monetdb/jdbc/MonetDriver.java.in > src/main/java/org/monetdb/jdbc/MonetDriver.java doc: ant -f build.xml doc clean: - rm -f src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java + rm -f src/main/java/org/monetdb/jdbc/MonetDriver.java rm -rf build tests/build jars doc
--- a/build.xml +++ b/build.xml @@ -19,16 +19,21 @@ Copyright 1997 - July 2008 CWI, August 2 <!-- set global properties for this build --> - <property name="srcdir" value="src/main/java" /> - <property name="libdir" value="lib" /> - <property name="jardir" value="jars" /> - <property name="builddir" value="build" /> - <property name="docdir" value="doc" /> - <property name="jdbc-package" value="nl/cwi/monetdb/jdbc" /> - <property name="mcl-package" value="nl/cwi/monetdb/mcl" /> - <property name="client-package" value="nl/cwi/monetdb/client" /> - <property name="util-package" value="nl/cwi/monetdb/util" /> - <property name="mero-control-package" value="nl/cwi/monetdb/merovingian" /> + <property name="srcdir" value="src/main/java" /> + <property name="libdir" value="lib" /> + <property name="jardir" value="jars" /> + <property name="builddir" value="build" /> + <property name="docdir" value="doc" /> + <property name="jdbc-package" value="org/monetdb/jdbc" /> + <property name="mcl-package" value="org/monetdb/mcl" /> + <property name="client-package" value="org/monetdb/client" /> + <property name="util-package" value="org/monetdb/util" /> + <property name="mero-control-package" value="org/monetdb/merovingian" /> + + <!-- old nl/cwi/monetdb packages for some deprecated classes as of nov2020 --> + <property name="nl-cwi-jdbc-package" value="nl/cwi/monetdb/jdbc" /> + <property name="nl-cwi-mcl-package" value="nl/cwi/monetdb/mcl" /> + <property name="nl-cwi-client-package" value="nl/cwi/monetdb/client" /> <property file="build.local.properties" /> <property file="build.properties" /> @@ -94,12 +99,15 @@ Copyright 1997 - July 2008 CWI, August 2 <!-- jar targets --> <target name="jar_jdbc" depends="compile_mcl,compile_jdbc" unless="uptodate.jdbc-jar"> - <echo file="${builddir}/META-INF/services/java.sql.Driver" append="false">nl.cwi.monetdb.jdbc.MonetDriver</echo> + <echo file="${builddir}/META-INF/services/java.sql.Driver" append="false">org.monetdb.jdbc.MonetDriver</echo> <jar jarfile="${jdbc-jar}"> <fileset dir="${builddir}"> + <include name="META-INF/services/java.sql.Driver" /> <include name="${jdbc-package}/**/*.class" /> + <include name="${nl-cwi-jdbc-package}/MonetDriver.class" /> + <include name="${nl-cwi-jdbc-package}/types/*.class" /> <include name="${mcl-package}/**/*.class" /> - <include name="META-INF/services/java.sql.Driver" /> + <include name="${nl-cwi-mcl-package}/net/MapiSocket.class" /> </fileset> </jar> </target> @@ -108,6 +116,7 @@ Copyright 1997 - July 2008 CWI, August 2 <jar jarfile="${mcl-jar}"> <fileset dir="${builddir}"> <include name="${mcl-package}/**/*.class" /> + <include name="${nl-cwi-mcl-package}/net/MapiSocket.class" /> </fileset> </jar> </target> @@ -116,6 +125,7 @@ Copyright 1997 - July 2008 CWI, August 2 <jar jarfile="${jardir}/monetdb-clients.jar"> <fileset dir="${builddir}"> <include name="${client-package}/**/*.class" /> + <include name="${nl-cwi-client-package}/JdbcClient.class" /> <include name="${util-package}/**/*.class" /> </fileset> </jar> @@ -128,15 +138,19 @@ Copyright 1997 - July 2008 CWI, August 2 <echo message="Building jdbcclient + JDBC driver convenience jar" /> <jar jarfile="${jdbcclient-jar}"> <fileset dir="${builddir}"> - <include name="${jdbc-package}/**/*.class" /> - <include name="${mcl-package}/**/*.class" /> <include name="${client-package}/**/*.class" /> + <include name="${nl-cwi-client-package}/JdbcClient.class" /> <include name="${util-package}/**/*.class" /> <include name="META-INF/services/java.sql.Driver" /> + <include name="${jdbc-package}/**/*.class" /> + <include name="${nl-cwi-jdbc-package}/MonetDriver.class" /> + <include name="${nl-cwi-jdbc-package}/types/*.class" /> + <include name="${mcl-package}/**/*.class" /> + <include name="${nl-cwi-mcl-package}/net/MapiSocket.class" /> </fileset> <manifest> <attribute name="Built-By" value="${user.name}" /> - <attribute name="Main-Class" value="nl.cwi.monetdb.client.JdbcClient" /> + <attribute name="Main-Class" value="org.monetdb.client.JdbcClient" /> </manifest> </jar> </target> @@ -150,12 +164,12 @@ Copyright 1997 - July 2008 CWI, August 2 <fileset dir="${builddir}"> <include name="${mero-control-package}/**/*.class" /> <include name="${mcl-package}/**/*.class" /> - <include name="${client-package}/**/JMonetDB.class" /> + <include name="${client-package}/JMonetDB.class" /> <include name="${util-package}/**/*.class" /> </fileset> <manifest> <attribute name="Built-By" value="${user.name}" /> - <attribute name="Main-Class" value="nl.cwi.monetdb.client.JMonetDB" /> + <attribute name="Main-Class" value="org.monetdb.client.JMonetDB" /> </manifest> </jar> </target> @@ -186,6 +200,9 @@ Copyright 1997 - July 2008 CWI, August 2 > <src path="${srcdir}" /> <include name="${jdbc-package}/**/*.java" /> + <include name="${nl-cwi-jdbc-package}/MonetDriver.java" /> + <include name="${nl-cwi-jdbc-package}/types/*.java" /> + <include name="${nl-cwi-mcl-package}/net/MapiSocket.java" /> <compilerarg line="${javac.flags}" /> </javac> </target> @@ -203,6 +220,7 @@ Copyright 1997 - July 2008 CWI, August 2 target="${jvm.version}" > <include name="${mcl-package}/**/*.java" /> + <include name="${nl-cwi-mcl-package}/net/MapiSocket.java" /> <compilerarg line="${javac.flags}" /> </javac> </target> @@ -220,6 +238,7 @@ Copyright 1997 - July 2008 CWI, August 2 target="${jvm.version}" > <include name="${client-package}/**/*.java" /> + <include name="${nl-cwi-client-package}/JdbcClient.java" /> <compilerarg line="${javac.flags}" /> </javac> </target> @@ -312,14 +331,21 @@ Copyright 1997 - July 2008 CWI, August 2 <uptodate targetfile="${jdbc-jar}" property="uptodate.jdbc-jar"> <srcfiles dir="${srcdir}"> <include name="${jdbc-package}/**/*.java" /> + <include name="${nl-cwi-jdbc-package}/MonetDriver.java" /> + <include name="${nl-cwi-jdbc-package}/types/*.java" /> <include name="${mcl-package}/**/*.java" /> + <include name="${nl-cwi-mcl-package}/net/MapiSocket.java" /> </srcfiles> </uptodate> <uptodate targetfile="${jdbcclient-jar}" property="uptodate.jdbcclient-jar"> <srcfiles dir="${srcdir}"> <include name="${client-package}/**/*.java" /> + <include name="${nl-cwi-client-package}/JdbcClient.java" /> <include name="${jdbc-package}/**/*.java" /> + <include name="${nl-cwi-jdbc-package}/MonetDriver.java" /> + <include name="${nl-cwi-jdbc-package}/types/*.java" /> <include name="${mcl-package}/**/*.java" /> + <include name="${nl-cwi-mcl-package}/net/MapiSocket.java" /> </srcfiles> </uptodate> <uptodate targetfile="${jmonetdb-jar}" property="uptodate.jmonetdb-jar">
--- a/pom.xml +++ b/pom.xml @@ -46,8 +46,8 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <jdbc.sources>nl/cwi/monetdb/jdbc/**/*.java</jdbc.sources> - <mcl.sources>nl/cwi/monetdb/mcl/**/*.java</mcl.sources> + <jdbc.sources>org/monetdb/jdbc/**/*.java</jdbc.sources> + <mcl.sources>org/monetdb/mcl/**/*.java</mcl.sources> </properties> <build>
--- a/release.txt +++ b/release.txt @@ -146,8 +146,8 @@ Currently implemented JDBC 4.2 interface - setCharacterStream * java.sql.SQLData - implemented by class: nl.cwi.monetdb.jdbc.types.INET - and by class: nl.cwi.monetdb.jdbc.types.URL + implemented by class: org.monetdb.jdbc.types.INET + and by class: org.monetdb.jdbc.types.URL * javax.sql.DataSource (not tested)
--- a/src/main/java/nl/cwi/monetdb/client/JdbcClient.java +++ b/src/main/java/nl/cwi/monetdb/client/JdbcClient.java @@ -8,1317 +8,12 @@ package nl.cwi.monetdb.client; -import nl.cwi.monetdb.util.CmdLineOpts; -import nl.cwi.monetdb.util.Exporter; -import nl.cwi.monetdb.util.MDBvalidator; -import nl.cwi.monetdb.util.OptionsException; -import nl.cwi.monetdb.util.SQLExporter; -import nl.cwi.monetdb.util.XMLExporter; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.File; -import java.io.PrintWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; // import is required as it will load the nl.cwi.monetdb.jdbc.MonetDriver class -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.Statement; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.Types; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; +import java.sql.DriverManager; // import is required as it will load the org.monetdb.jdbc.MonetDriver class /** - * This program acts like an extended client program for MonetDB. Its - * look and feel is very much like PostgreSQL's interactive terminal - * program. Although it looks like this client is designed for MonetDB, - * it demonstrates the power of the JDBC interface since it built on top - * of JDBC only. - * - * @author Fabian Groffen - * @author Martin van Dinther - * @version 1.6 + * a wrapper class for old programs who still depend on + * class nl.cwi.monetdb.client.JdbcClient to work. + * This class is deprecated since nov 2020 and will be removed in a future release. */ - -public final class JdbcClient { - - private static Connection con; - private static DatabaseMetaData dbmd; - private static Statement stmt; - private static BufferedReader in; - private static PrintWriter out; - private static Exporter exporter; - - /** - * JdbcClient is a command line query tool for MonetDB, similar to mclient. - * It uses the JDBC API and the MonetDB JDBC driver to communicate with a - * MonetDB server. The MonetDB JDBC driver is included in the jdbcclient.jre8.jar - * for ease of use, so only 1 jar file is needed to use it. - * - * <pre>Usage java -jar jdbcclient.jre8.jar - * [-h host[:port]] [-p port] [-f file] [-u user] - * [-l language] [-d database] [-e] [-D [table]] [-X<opt>] - * | [--help] | [--version] - * or using long option equivalents --host --port --file --user --language - * --dump --echo --database. - * Arguments may be written directly after the option like -p50000. - * - * If no host and port are given, localhost and 50000 are assumed. - * An .monetdb file may exist in the user's home directory. This file can contain - * preferences to use each time JdbcClient is started. Options given on the - * command line override the preferences file. The .monetdb file syntax is - * <option>=<value> where option is one of the options host, port, file, mode - * debug, or password. Note that the last one is perilous and therefore not - * available as command line option. - * If no input file is given using the -f flag, an interactive session is - * started on the terminal. - * - * OPTIONS - * -h --host The hostname of the host that runs the MonetDB database. A port - * number can be supplied by use of a colon, i.e. -h somehost:12345. - * -p --port The port number to connect to. - * -f --file A file name to use either for reading or writing. The file will - * be used for writing when dump mode is used (-D --dump). In read - * mode, the file can also be an URL pointing to a plain text file - * that is optionally gzip compressed. - * -u --user The username to use when connecting to the database. - * -d --database Try to connect to the given database (only makes sense if - * connecting to monetdbd). - * -l --language Use the given language, defaults to 'sql'. - * --help This help screen. - * --version Display driver version and exit. - * -e --echo Also outputs the contents of the input file, if any. - * -q --quiet Suppress printing the welcome header. - * -D --dump Dumps the given table(s), or the complete database if none given. - * -Xoutput The output mode when dumping. Default is sql, xml may be used for - * an experimental XML output. - * -Xhash Use the given hash algorithm during challenge response. - * Supported algorithm names: SHA512, SHA384, SHA256 and SHA1. - * -Xdebug Writes a transmission log to disk for debugging purposes. If a - * file name is given, it is used, otherwise a file called - * monet<timestamp>.log is created. A given file never be - * overwritten; instead a unique variation of the file is used. - * -Xbatching Indicates that a batch should be used instead of direct - * communication with the server for each statement. If a number is - * given, it is used as batch size. i.e. 8000 would execute the - * contents on the batch after each 8000 statements read. Batching - * can greatly speedup the process of restoring a database dump.</pre> - * - * @param args optional list of startup arguments - * @throws Exception if uncaught exception is thrown - */ - public final static void main(String[] args) throws Exception { - final CmdLineOpts copts = new CmdLineOpts(); - - // arguments which take exactly one argument - copts.addOption("h", "host", CmdLineOpts.CAR_ONE, "localhost", - "The hostname of the host that runs the MonetDB database. " + - "A port number can be supplied by use of a colon, i.e. " + - "-h somehost:12345."); - copts.addOption("p", "port", CmdLineOpts.CAR_ONE, "50000", - "The port number to connect to."); - // todo make it CAR_ONE_MANY - copts.addOption("f", "file", CmdLineOpts.CAR_ONE, null, - "A file name to use either for reading or writing. The " + - "file will be used for writing when dump mode is used " + - "(-D --dump). In read mode, the file can also be an URL " + - "pointing to a plain text file that is optionally gzip " + - "compressed."); - copts.addOption("u", "user", CmdLineOpts.CAR_ONE, System.getProperty("user.name"), - "The username to use when connecting to the database."); - // this one is only here for the .monetdb file parsing, it is - // removed before the command line arguments are parsed - copts.addOption(null, "password", CmdLineOpts.CAR_ONE, null, null); - copts.addOption("d", "database", CmdLineOpts.CAR_ONE, "", - "Try to connect to the given database (only makes sense " + - "if connecting to monetdbd)."); - copts.addOption("l", "language", CmdLineOpts.CAR_ONE, "sql", - "Use the given language, defaults to 'sql'."); - - // arguments which have no argument(s) - copts.addOption(null, "help", CmdLineOpts.CAR_ZERO, null, - "This help screen."); - copts.addOption(null, "version", CmdLineOpts.CAR_ZERO, null, - "Display driver version and exit."); - copts.addOption("e", "echo", CmdLineOpts.CAR_ZERO, null, - "Also outputs the contents of the input file, if any."); - copts.addOption("q", "quiet", CmdLineOpts.CAR_ZERO, null, - "Suppress printing the welcome header."); - - // arguments which have zero to many arguments - copts.addOption("D", "dump", CmdLineOpts.CAR_ZERO_MANY, null, - "Dumps the given table(s), or the complete database if " + - "none given."); - - // extended options - copts.addOption(null, "Xoutput", CmdLineOpts.CAR_ONE, null, - "The output mode when dumping. Default is sql, xml may " + - "be used for an experimental XML output."); - copts.addOption(null, "Xhash", CmdLineOpts.CAR_ONE, null, - "Use the given hash algorithm during challenge response. " + - "Supported algorithm names: SHA512, SHA384, SHA256 and SHA1."); - // arguments which can have zero or one argument(s) - copts.addOption(null, "Xdebug", CmdLineOpts.CAR_ZERO_ONE, null, - "Writes a transmission log to disk for debugging purposes. " + - "If a file name is given, it is used, otherwise a file " + - "called monet<timestamp>.log is created. A given file " + - "never be overwritten; instead a unique variation of the " + - "file is used."); - copts.addOption(null, "Xbatching", CmdLineOpts.CAR_ZERO_ONE, null, - "Indicates that a batch should be used instead of direct " + - "communication with the server for each statement. If a " + - "number is given, it is used as batch size. i.e. 8000 " + - "would execute the contents on the batch after each 8000 " + - "statements read. Batching can greatly speedup the " + - "process of restoring a database dump."); - - // we store user and password in separate variables in order to - // be able to properly act on them like forgetting the password - // from the user's file if the user supplies a username on the - // command line arguments - String pass = null; - String user = null; - - // look for a file called .monetdb in the current dir or in the - // user's homedir and read its preferences - File pref = new File(".monetdb"); - if (!pref.exists()) - pref = new File(System.getProperty("user.home"), ".monetdb"); - if (pref.exists()) { - try { - copts.processFile(pref); - } catch (OptionsException e) { - System.err.println("Error in " + pref.getAbsolutePath() + ": " + e.getMessage()); - System.exit(1); - } - user = copts.getOption("user").getArgument(); - pass = copts.getOption("password").getArgument(); - } - - // process the command line arguments, remove password option - // first, and save the user we had at this point - copts.removeOption("password"); - try { - copts.processArgs(args); - } catch (OptionsException e) { - System.err.println("Error: " + e.getMessage()); - System.exit(1); - } - // we can actually compare pointers (objects) here - if (user != copts.getOption("user").getArgument()) - pass = null; - - if (copts.getOption("help").isPresent()) { - System.out.print( - "Usage java -jar jdbcclient.jre8.jar\n" + - "\t\t[-h host[:port]] [-p port] [-f file] [-u user]\n" + - "\t\t[-l language] [-d database] [-e] [-D [table]] [-X<opt>]\n" + - "\t\t| [--help] | [--version]\n" + - "or using long option equivalents --host --port --file --user --language\n" + - "--dump --echo --database.\n" + - "Arguments may be written directly after the option like -p50000.\n" + - "\n" + - "If no host and port are given, localhost and 50000 are assumed.\n" + - "An .monetdb file may exist in the user's home directory. This file can contain\n" + - "preferences to use each time JdbcClient is started. Options given on the\n" + - "command line override the preferences file. The .monetdb file syntax is\n" + - "<option>=<value> where option is one of the options host, port, file, mode\n" + - "debug, or password. Note that the last one is perilous and therefore not\n" + - "available as command line option.\n" + - "If no input file is given using the -f flag, an interactive session is\n" + - "started on the terminal.\n" + - "\n" + - "OPTIONS\n" + - copts.produceHelpMessage() - ); - System.exit(0); - } - - if (copts.getOption("version").isPresent()) { - // We cannot use the DatabaseMetaData here, because we - // cannot get a Connection. So instead, we just get the - // values we want out of the Driver directly. - System.out.println("JDBC Driver: v" + nl.cwi.monetdb.jdbc.MonetDriver.getDriverVersion()); - System.exit(0); - } - - // whether the semi-colon at the end of a String terminates the - // query or not (default = yes => SQL) - final boolean scolonterm = true; - final boolean xmlMode = "xml".equals(copts.getOption("Xoutput").getArgument()); - - // we need the password from the user, fetch it with a pseudo - // password protector - if (pass == null) { - final char[] tmp = System.console().readPassword("password: "); - if (tmp == null) { - System.err.println("Invalid password!"); - System.exit(1); - } - pass = String.valueOf(tmp); - } - - user = copts.getOption("user").getArgument(); - - // build the hostname - String host = copts.getOption("host").getArgument(); - if (host.indexOf(":") == -1) { - host = host + ":" + copts.getOption("port").getArgument(); - } - - // make sure the driver is loaded - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers - - // build the extra arguments of the JDBC connect string - String attr = "?"; - CmdLineOpts.OptionContainer oc = copts.getOption("language"); - final String lang = oc.getArgument(); - if (oc.isPresent()) - attr += "language=" + lang + "&"; - -/* Xquery is no longer functional or supported - // set some behaviour based on the language XQuery - if (lang.equals("xquery")) { - scolonterm = false; // no ; to end a statement - if (!copts.getOption("Xoutput").isPresent()) - xmlMode = true; // the user will like xml results, most probably - } -*/ - oc = copts.getOption("Xdebug"); - if (oc.isPresent()) { - attr += "debug=true&"; - if (oc.getArgumentCount() == 1) - attr += "logfile=" + oc.getArgument() + "&"; - } - oc = copts.getOption("Xhash"); - if (oc.isPresent()) - attr += "hash=" + oc.getArgument() + "&"; - - // request a connection suitable for MonetDB from the driver - // manager note that the database specifier is only used when - // connecting to a proxy-like service, since MonetDB itself - // can't access multiple databases. - con = null; - final String database = copts.getOption("database").getArgument(); - try { - con = DriverManager.getConnection( - "jdbc:monetdb://" + host + "/" + database + attr, - user, - pass - ); - SQLWarning warn = con.getWarnings(); - while (warn != null) { - System.err.println("Connection warning: " + warn.getMessage()); - warn = warn.getNextWarning(); - } - con.clearWarnings(); - } catch (SQLException e) { - System.err.println("Database connect failed: " + e.getMessage()); - System.exit(1); - } - - try { - dbmd = con.getMetaData(); - } catch (SQLException e) { - // we ignore this because it's probably because we don't use - // SQL language - dbmd = null; - } - - in = new BufferedReader(new InputStreamReader(System.in)); - out = new PrintWriter(new BufferedWriter(new java.io.OutputStreamWriter(System.out))); - - stmt = con.createStatement(); // is used by doDump - - // see if we will have to perform a database dump (only in SQL mode) - if ("sql".equals(lang) && copts.getOption("dump").isPresent() && dbmd != null) { - // use the given file for writing - oc = copts.getOption("file"); - if (oc.isPresent()) - out = new PrintWriter(new BufferedWriter(new java.io.FileWriter(oc.getArgument()))); - - // we only want user tables and views to be dumped, unless a specific table is requested - final String[] types = {"TABLE","VIEW","MERGE TABLE","REMOTE TABLE","REPLICA TABLE","STREAM TABLE"}; - // Future: fetch all type names using dbmd.getTableTypes() and construct String[] with all - // table type names excluding the SYSTEM ... ones and LOCAL TEMPORARY TABLE ones. - - // request the list of tables available in the current schema in the database - ResultSet tbl = dbmd.getTables(null, con.getSchema(), null, - (copts.getOption("dump").getArgumentCount() == 0) ? types : null); - // fetch all tables and store them in a LinkedList of Table objects - final LinkedList<Table> tables = new LinkedList<Table>(); - while (tbl.next()) { - tables.add(new Table( - tbl.getString(2), // 2 = "TABLE_SCHEM" - tbl.getString(3), // 3 = "TABLE_NAME" - tbl.getString(4))); // 4 = "TABLE_TYPE" - } - tbl.close(); - tbl = null; - - if (xmlMode) { - exporter = new XMLExporter(out); - exporter.setProperty(XMLExporter.TYPE_NIL, XMLExporter.VALUE_XSI); - } else { - exporter = new SQLExporter(out); - // stick with SQL INSERT INTO commands for now - // in the future we might do COPY INTO's here using VALUE_COPY - exporter.setProperty(SQLExporter.TYPE_OUTPUT, SQLExporter.VALUE_INSERT); - } - exporter.useSchemas(true); - - // start SQL output - if (!xmlMode) - out.println("START TRANSACTION;\n"); - - // dump specific table(s) or not? - if (copts.getOption("dump").getArgumentCount() > 0) { // yes we do - final String[] dumpers = copts.getOption("dump").getArguments(); - for (int i = 0; i < tables.size(); i++) { - Table ttmp = tables.get(i); - for (int j = 0; j < dumpers.length; j++) { - String dumptblnm = dumpers[j].toString(); - if (ttmp.getName().equalsIgnoreCase(dumptblnm) || - ttmp.getFqname().equalsIgnoreCase(dumptblnm)) - { - // dump the table - doDump(out, ttmp); - } - } - } - } else { - /* this returns everything, so including SYSTEM TABLE constraints */ - tbl = dbmd.getImportedKeys(null, null, null); - while (tbl.next()) { - // find FK table object 6 = "FKTABLE_SCHEM", 7 = "FKTABLE_NAME" - Table fk = Table.findTable(tbl.getString(6), tbl.getString(7), tables); - - // find PK table object 2 = "PKTABLE_SCHEM", 3 = "PKTABLE_NAME" - Table pk = Table.findTable(tbl.getString(2), tbl.getString(3), tables); - - // this happens when a system table has referential constraints - if (fk == null || pk == null) - continue; - - // add PK table dependency to FK table - fk.addDependency(pk); - } - tbl.close(); - tbl = null; - - // search for cycles of type a -> (x ->)+ b probably not - // the most optimal way, but it works by just scanning - // every table for loops in a recursive manor - for (Table t : tables) { - Table.checkForLoop(t, new ArrayList<Table>()); - } - - // find the graph, at this point we know there are no - // cycles, thus a solution exists - for (int i = 0; i < tables.size(); i++) { - final List<Table> needs = tables.get(i).requires(tables.subList(0, i + 1)); - if (needs.size() > 0) { - tables.removeAll(needs); - tables.addAll(i, needs); - - // re-evaluate this position, for there is a new - // table now - i--; - } - } - - // we now have the right order to dump tables - for (Table t : tables) { - // dump the table - doDump(out, t); - } - } - - if (!xmlMode) - out.println("COMMIT;"); - out.flush(); - - // free resources, close the statement - stmt.close(); - // close the connection with the database - con.close(); - // completed database dump - System.exit(0); - } - - if (xmlMode) { - exporter = new XMLExporter(out); - exporter.setProperty(XMLExporter.TYPE_NIL, XMLExporter.VALUE_XSI); - } else { - exporter = new SQLExporter(out); - // we want nice table formatted output - exporter.setProperty(SQLExporter.TYPE_OUTPUT, SQLExporter.VALUE_TABLE); - } - exporter.useSchemas(false); - - try { - // use the given file for reading - final boolean hasFile = copts.getOption("file").isPresent(); - final boolean doEcho = hasFile && copts.getOption("echo").isPresent(); - if (hasFile) { - final String tmp = copts.getOption("file").getArgument(); - try { - in = getReader(tmp); - } catch (Exception e) { - System.err.println("Error: " + e.getMessage()); - System.exit(1); - } - - // check for batch mode - int batchSize = 0; - oc = copts.getOption("Xbatching"); - if (oc.isPresent()) { - if (oc.getArgumentCount() == 1) { - // parse the number - try { - batchSize = Integer.parseInt(oc.getArgument()); - } catch (NumberFormatException ex) { - // complain to the user - throw new IllegalArgumentException("Illegal argument for Xbatching: " + oc.getArgument() + " is not a parseable number!"); - } - } - processBatch(batchSize); - } else { - processInteractive(true, doEcho, scolonterm, user); - } - } else { - if (!copts.getOption("quiet").isPresent()) { - // print welcome message - out.println("Welcome to the MonetDB interactive JDBC terminal!"); - if (dbmd != null) { - out.println("JDBC Driver: " + dbmd.getDriverName() + - " v" + dbmd.getDriverVersion()); - out.println("Database Server: " + dbmd.getDatabaseProductName() + - " v" + dbmd.getDatabaseProductVersion()); - } - out.println("Current Schema: " + con.getSchema()); - out.println("Type \\q to quit (you can also use: quit or exit), \\? or \\h for a list of available commands"); - out.flush(); - } - processInteractive(false, doEcho, scolonterm, user); - } - - // free resources, close the statement - stmt.close(); - // close the connection with the database - con.close(); - // close the file (if we used a file) - in.close(); - } catch (Exception e) { - System.err.println("A fatal exception occurred: " + e.toString()); - e.printStackTrace(System.err); - // at least try to close the connection properly, since it will - // close all statements associated with it - try { - con.close(); - } catch (SQLException ex) { - // ok... nice try - } - System.exit(1); - } - } - - /** - * Tries to interpret the given String as URL or file. Returns the - * assigned BufferedReader, or throws an Exception if the given - * string couldn't be identified as a valid URL or file. - * - * @param uri URL or filename as String - * @return a BufferedReader for the uri - * @throws Exception if uri cannot be identified as a valid URL or file - */ - static BufferedReader getReader(final String uri) throws Exception { - BufferedReader ret = null; - URL u = null; - - // Try and parse as URL first - try { - u = new URL(uri); - } catch (java.net.MalformedURLException e) { - // no URL, try as file - try { - ret = new BufferedReader(new java.io.FileReader(uri)); - } catch (java.io.FileNotFoundException fnfe) { - // the message is descriptive enough, adds "(No such file - // or directory)" itself. - throw new Exception(fnfe.getMessage()); - } - } - - if (ret == null) { - try { - HttpURLConnection.setFollowRedirects(true); - final HttpURLConnection con = (HttpURLConnection)u.openConnection(); - con.setRequestMethod("GET"); - final String ct = con.getContentType(); - if ("application/x-gzip".equals(ct)) { - // open gzip stream - ret = new BufferedReader(new InputStreamReader( - new java.util.zip.GZIPInputStream(con.getInputStream()))); - } else { - // text/plain otherwise just attempt to read as is - ret = new BufferedReader(new InputStreamReader(con.getInputStream())); - } - } catch (IOException e) { - // failed to open the url - throw new Exception("No such host/file: " + e.getMessage()); - } catch (Exception e) { - // this is an exception that comes from deep ... - throw new Exception("Invalid URL: " + e.getMessage()); - } - } - - return ret; - } - - /** - * Starts an interactive processing loop, where output is adjusted to an - * user session. This processing loop is not suitable for bulk processing - * as in executing the contents of a file, since processing on the given - * input is done after each row that has been entered. - * - * @param hasFile a boolean indicating whether a file is used as input - * @param doEcho a boolean indicating whether to echo the given input - * @param scolonterm whether a ';' makes this query part complete - * @param user a String representing the username of the current user - * @throws IOException if an IO exception occurs - * @throws SQLException if a database related error occurs - */ - private static void processInteractive( - final boolean hasFile, - final boolean doEcho, - final boolean scolonterm, - final String user) - throws IOException, SQLException - { - // an SQL stack keeps track of ( " and ' - final SQLStack stack = new SQLStack(); - boolean lastac = false; - - if (!hasFile) { - lastac = con.getAutoCommit(); - out.println("auto commit mode: " + (lastac ? "on" : "off")); - out.print(getPrompt(stack, true)); - out.flush(); - } - - String curLine; - String query = ""; - boolean doProcess; - boolean wasComplete = true; - - // the main (interactive) process loop - for (long i = 1; true; i++) { - // Manually read a line, because we want to detect an EOF - // (ctrl-D). Doing so allows to have a terminator for query - // which is not based on a special character, as is the - // problem for XQuery - curLine = in.readLine(); - if (curLine == null) { - out.println(""); - if (!query.isEmpty()) { - try { - executeQuery(query, stmt, out, !hasFile); - } catch (SQLException e) { - out.flush(); - do { - if (hasFile) { - System.err.println("Error on line " + i + ": [" + e.getSQLState() + "] " + e.getMessage()); - } else { - System.err.println("Error [" + e.getSQLState() + "]: " + e.getMessage()); - } - // print all error messages in the chain (if any) - } while ((e = e.getNextException()) != null); - } - query = ""; - wasComplete = true; - if (!hasFile) { - final boolean ac = con.getAutoCommit(); - if (ac != lastac) { - out.println("auto commit mode: " + (ac ? "on" : "off")); - lastac = ac; - } - out.print(getPrompt(stack, wasComplete)); - } - out.flush(); - // try to read again - continue; - } else { - // user did ctrl-D without something in the buffer, - // so terminate - break; - } - } - - if (doEcho) { - out.println(curLine); - out.flush(); - } - - // a query part is a line of an SQL query - QueryPart qp = scanQuery(curLine, stack, scolonterm); - if (!qp.isEmpty()) { - final String command = qp.getQuery(); - doProcess = true; - if (wasComplete) { - doProcess = false; - // check for commands only when the previous row was complete - if (command.equals("\\q") || command.equals("quit") || command.equals("exit")) { - // quit - break; - } else if (command.equals("\\?") || command.equals("\\h")) { - out.println("Available commands:"); - out.println("\\q quits this program (you can also use: quit or exit)"); - if (dbmd != null) { - out.println("\\d list available user tables and views in current schema"); - out.println("\\dS list available system tables and views in sys schema"); - out.println("\\d <obj> describes the given table or view"); - } - out.println("\\l<uri> executes the contents of the given file or URL"); - out.println("\\i<uri> batch executes the inserts from the given file or URL"); - out.println("\\vsci validate sql system catalog integrity"); - // out.println("\\vsni validate sql system netcdf tables integrity"); // depends on availability of netcdf library on server - // out.println("\\vsgi validate sql system geom tables integrity"); // depends on availability of geom library on server - out.println("\\vsi <schema> validate integrity of data in the given schema"); - out.println("\\vdbi validate integrity of data in all user schemas in the database"); - out.println("\\? or \\h this help screen"); - } else if (dbmd != null && command.startsWith("\\d")) { - ResultSet tbl = null; - try { - if (command.equals("\\dS")) { - // list available system tables and views in sys schema - tbl = dbmd.getTables(null, "sys", null, null); - - // give us a list of all non-system tables and views (including temp ones) - while (tbl.next()) { - final String tableType = tbl.getString(4); // 4 = "TABLE_TYPE" - if (tableType != null && tableType.startsWith("SYSTEM ")) { - String tableNm = tbl.getString(3); // 3 = "TABLE_NAME" - if (tableNm.contains(" ") || tableNm.contains("\t")) - tableNm = dq(tableNm); - out.println(tableType + "\t" + - tbl.getString(2) + "." + // 2 = "TABLE_SCHEM" - tableNm); - } - } - } else { - String object = command.substring(2).trim(); - if (scolonterm && object.endsWith(";")) - object = object.substring(0, object.length() - 1); - if (object.isEmpty()) { - // list available user tables and views in current schema - tbl = dbmd.getTables(null, con.getSchema(), null, null); - - // give us a list of all non-system tables and views (including temp ones) - while (tbl.next()) { - final String tableType = tbl.getString(4); // 4 = "TABLE_TYPE" - if (tableType != null && !tableType.startsWith("SYSTEM ")) { - String tableNm = tbl.getString(3); // 3 = "TABLE_NAME" - if (tableNm.contains(" ") || tableNm.contains("\t")) - tableNm = dq(tableNm); - out.println(tableType + "\t" + - tbl.getString(2) + "." + // 2 = "TABLE_SCHEM" - tableNm); - } - } - } else { - // describes the given table or view - String schema; - String obj_nm = object; - int len; - boolean found = false; - final int dot = object.indexOf("."); - if (dot > 0) { - // use specified schema - schema = object.substring(0, dot); - obj_nm = object.substring(dot + 1); - // remove potential surrounding double quotes around schema name - len = schema.length(); - if (len > 2 && schema.charAt(0) == '"' && schema.charAt(len -1) == '"') - schema = schema.substring(1, len -1); - } else { - // use current schema - schema = con.getSchema(); - } - // remove potential surrounding double quotes around table or view name - len = obj_nm.length(); - if (len > 2 && obj_nm.charAt(0) == '"' && obj_nm.charAt(len -1) == '"') - obj_nm = obj_nm.substring(1, len -1); - - // System.err.println("calling dbmd.getTables(" + schema + ", " + obj_nm + ")"); - tbl = dbmd.getTables(null, schema, obj_nm, null); - while (tbl.next() && !found) { - final String schemaName = tbl.getString(2); // 2 = "TABLE_SCHEM" - final String tableName = tbl.getString(3); // 3 = "TABLE_NAME" - if (obj_nm.equals(tableName) && schema.equals(schemaName)) { - // we found it, describe it - exporter.dumpSchema(dbmd, - tbl.getString(4), // 4 = "TABLE_TYPE" - schemaName, - tableName); - - found = true; - break; - } - } - if (!found) - System.err.println("No match found for table or view: " + object); - } - } - } catch (SQLException e) { - out.flush(); - do { - System.err.println("Error [" + e.getSQLState() + "]: " + e.getMessage()); - // print all error messages in the chain (if any) - } while ((e = e.getNextException()) != null); - } finally { - if (tbl != null) - tbl.close(); - } - } else if (command.equals("\\vsci")) { - MDBvalidator.validateSqlCatalogIntegrity(con); - } else if (command.equals("\\vsni")) { - MDBvalidator.validateSqlNetcdfTablesIntegrity(con); - } else if (command.equals("\\vsgi")) { - MDBvalidator.validateSqlGeomTablesIntegrity(con); - } else if (command.startsWith("\\vsi ")) { - String schema_arg = command.substring(5); - MDBvalidator.validateSchemaIntegrity(con, schema_arg); - } else if (command.equals("\\vdbi")) { - MDBvalidator.validateDBIntegrity(con); - } else if (command.startsWith("\\l") || command.startsWith("\\i")) { - String object = command.substring(2).trim(); - if (scolonterm && object.endsWith(";")) - object = object.substring(0, object.length() - 1); - if (object.isEmpty()) { - System.err.println("Usage: '" + command.substring(0, 2) + "<uri>' where <uri> is a file or URL"); - } else { - // temporarily redirect input from in - final BufferedReader console = in; - try { - in = getReader(object); - if (command.startsWith("\\l")) { - processInteractive(true, doEcho, scolonterm, user); - } else { - processBatch(0); - } - } catch (Exception e) { - out.flush(); - System.err.println("Error: " + e.getMessage()); - } finally { - // put back in redirection - in = console; - } - } - } else { - doProcess = true; - } - } - - if (doProcess) { - query += command + (qp.hasOpenQuote() ? "\\n" : " "); - if (qp.isComplete()) { - // strip off trailing ';' - query = query.substring(0, query.length() - 2); - // execute query - try { - executeQuery(query, stmt, out, !hasFile); - } catch (SQLException e) { - out.flush(); - final String startmsg = (hasFile ? ("Error on line " + i + ": [") : "Error ["); - do { - System.err.println(startmsg + e.getSQLState() + "] " + e.getMessage()); - // print all error messages in the chain (if any) - } while ((e = e.getNextException()) != null); - } - query = ""; - wasComplete = true; - } else { - wasComplete = false; - } - } - } - - if (!hasFile) { - final boolean ac = con.getAutoCommit(); - if (ac != lastac) { - out.println("auto commit mode: " + (ac ? "on" : "off")); - lastac = ac; - } - out.print(getPrompt(stack, wasComplete)); - } - out.flush(); - } - } - - /** - * Executes the given query and prints the result tabularised to the - * given PrintWriter stream. The result of this method is the - * default output of a query: tabular data. - * - * @param query the query to execute - * @param stmt the Statement to execute the query on - * @param out the PrintWriter to write to - * @param showTiming flag to specify if timing information nees to be printed - * @throws SQLException if a database related error occurs - */ - private static void executeQuery(final String query, - final Statement stmt, - final PrintWriter out, - final boolean showTiming) - throws SQLException - { - // warnings generated during querying - SQLWarning warn; - long startTime = (showTiming ? System.currentTimeMillis() : 0); - long finishTime = 0; - - // execute the query, let the driver decide what type it is - int aff = -1; - boolean nextRslt = stmt.execute(query, Statement.RETURN_GENERATED_KEYS); - if (!nextRslt) - aff = stmt.getUpdateCount(); - do { - if (nextRslt) { - // we have a ResultSet, print it - final ResultSet rs = stmt.getResultSet(); - - exporter.dumpResultSet(rs); - if (showTiming) { - finishTime = System.currentTimeMillis(); - out.println("Elapsed Time: " + (finishTime - startTime) + " ms"); - startTime = finishTime; - } - - // if there were warnings for this result, - // show them! - warn = rs.getWarnings(); - if (warn != null) { - // force stdout to be written so the - // warning appears below it - out.flush(); - do { - System.err.println("ResultSet warning: " + - warn.getMessage()); - warn = warn.getNextWarning(); - } while (warn != null); - rs.clearWarnings(); - } - rs.close(); - } else if (aff != -1) { - String timingoutput = ""; - if (showTiming) { - finishTime = System.currentTimeMillis(); - timingoutput = ". Elapsed Time: " + (finishTime - startTime) + " ms"; - startTime = finishTime; - } - - if (aff == Statement.SUCCESS_NO_INFO) { - out.println("Operation successful" + timingoutput); - } else { - // we have an update count - // see if a key was generated - final ResultSet rs = stmt.getGeneratedKeys(); - final boolean hasGeneratedKeyData = rs.next(); - out.println(aff + " affected row" + (aff != 1 ? "s" : "") + - (hasGeneratedKeyData ? ", last generated key: " + rs.getString(1) : "") + - timingoutput); - rs.close(); - } - } - - out.flush(); - } while ((nextRslt = stmt.getMoreResults()) || - (aff = stmt.getUpdateCount()) != -1); - - // if there were warnings for this statement, - // and/or connection show them! - warn = stmt.getWarnings(); - while (warn != null) { - System.err.println("Statement warning: " + warn.getMessage()); - warn = warn.getNextWarning(); - } - stmt.clearWarnings(); - - warn = con.getWarnings(); - while (warn != null) { - // suppress warning when issueing a "set schema xyz;" command -// if ( !(warn.getMessage()).equals("Server enabled auto commit mode while local state already was auto commit.") ) - System.err.println("Connection warning: " + warn.getMessage()); - warn = warn.getNextWarning(); - } - con.clearWarnings(); - } - - /** - * Starts a processing loop optimized for processing (large) chunks of - * continuous data, such as input from a file. Unlike in the interactive - * loop above, queries are sent only to the database if a certain batch - * amount is reached. No client side query checks are made, but everything - * is sent to the server as-is. - * - * @param batchSize the number of items to store in the batch before - * sending them to the database for execution. - * @throws IOException if an IO exception occurs. - */ - private static void processBatch(final int batchSize) throws IOException { - final StringBuilder query = new StringBuilder(2048); - int i = 0; - try { - String curLine; - // the main loop - for (i = 1; (curLine = in.readLine()) != null; i++) { - query.append(curLine); - if (curLine.endsWith(";")) { - // lousy check for end of statement, but in batch mode it - // is not very important to catch all end of statements... - stmt.addBatch(query.toString()); - query.setLength(0); // clear the buffer - } else { - query.append('\n'); - } - if (batchSize > 0 && i % batchSize == 0) { - stmt.executeBatch(); - // stmt.clearBatch(); // this is no longer needed after call executeBatch(), see https://www.monetdb.org/bugzilla/show_bug.cgi?id=6953 - } - } - stmt.addBatch(query.toString()); - stmt.executeBatch(); - // stmt.clearBatch(); // this is no longer needed after call executeBatch(), see https://www.monetdb.org/bugzilla/show_bug.cgi?id=6953 - } catch (SQLException e) { - do { - System.err.println("Error at line " + i + ": [" + e.getSQLState() + "] " + e.getMessage()); - // print all error messages in the chain (if any) - } while ((e = e.getNextException()) != null); - } - } - - /** - * Wrapper method that decides to dump SQL or XML. In the latter case, - * this method does the XML data generation. - * - * @param out a Writer to write the data to - * @param table the table to dump - * @throws SQLException if a database related error occurs - */ - private static void doDump(final PrintWriter out, final Table table) throws SQLException { - final String tableType = table.getType(); - - // dump CREATE definition of this table/view - exporter.dumpSchema(dbmd, tableType, table.getSchem(), table.getName()); - out.println(); - - // only dump data from real tables, not from views / MERGE / REMOTE / REPLICA tables - if (tableType.contains("TABLE") - && !tableType.equals("MERGE TABLE") - && !tableType.equals("REMOTE TABLE") - && !tableType.equals("REPLICA TABLE")) { - final ResultSet rs = stmt.executeQuery("SELECT * FROM " + table.getFqnameQ()); - if (rs != null) { - exporter.dumpResultSet(rs); - rs.close(); - out.println(); - } - } - } - - /** - * Simple helper method that generates a prompt. - * - * @param stack the current SQLStack - * @param compl whether the statement is complete - * @return a prompt which consist of "sql" plus the top of the stack - */ - private static String getPrompt(final SQLStack stack, final boolean compl) { - return (compl ? "sql" : "more") + (stack.empty() ? ">" : stack.peek()) + " "; - } - - /** - * Scans the given string and tries to discover if it is a complete query - * or that there needs something to be added. If a string doesn't end with - * a ; it is considered not to be complete. SQL string quotation using ' and - * SQL identifier quotation using " is taken into account when scanning a - * string this way. - * Additionally, this method removes comments from the SQL statements, - * identified by -- and removes white space where appropriate. - * - * @param query the query to parse - * @param stack query stack to work with - * @param scolonterm whether a ';' makes this query part complete - * @return a QueryPart object containing the results of this parse - */ - private static QueryPart scanQuery( - final String query, - final SQLStack stack, - final boolean scolonterm) - { - // examine string, char for char - boolean wasInString = (stack.peek() == '\''); - boolean wasInIdentifier = (stack.peek() == '"'); - boolean escaped = false; - int len = query.length(); - for (int i = 0; i < len; i++) { - switch(query.charAt(i)) { - case '\\': - escaped = !escaped; - break; - default: - escaped = false; - break; - case '\'': - /** - * We can not be in a string if we are in an identifier. So - * If we find a ' and are not in an identifier, and not in - * a string we can safely assume we will be now in a string. - * If we are in a string already, we should stop being in a - * string if we find a quote which is not prefixed by a \, - * for that would be an escaped quote. However, a nasty - * situation can occur where the string is like 'test \\'. - * As obvious, a test for a \ in front of a ' doesn't hold - * here. Because 'test \\\'' can exist as well, we need to - * know if a quote is prefixed by an escaping slash or not. - */ - if (!escaped && stack.peek() != '"') { - if (stack.peek() != '\'') { - // although it makes no sense to escape a quote - // outside a string, it is escaped, thus not meant - // as quote for us, apparently - stack.push('\''); - } else { - stack.pop(); - } - } - // reset escaped flag - escaped = false; - break; - case '"': - if (!escaped && stack.peek() != '\'') { - if (stack.peek() != '"') { - stack.push('"'); - } else { - stack.pop(); - } - } - // reset escaped flag - escaped = false; - break; - case '-': - if (!escaped && stack.peek() != '\'' && stack.peek() != '"' && i + 1 < len && query.charAt(i + 1) == '-') { - len = i; - } - escaped = false; - break; - case '(': - if (!escaped && stack.peek() != '\'' && stack.peek() != '"') { - stack.push('('); - } - escaped = false; - break; - case ')': - if (!escaped && stack.peek() == '(') { - stack.pop(); - } - escaped = false; - break; - } - } - - int start = 0; - if (!wasInString && !wasInIdentifier && len > 0) { - // trim spaces at the start of the string - for (; start < len && Character.isWhitespace(query.charAt(start)); start++); - } - int stop = len - 1; - if (stack.peek() != '\'' && !wasInIdentifier && stop > start) { - // trim spaces at the end of the string - for (; stop >= start && Character.isWhitespace(query.charAt(stop)); stop--); - } - stop++; - - if (start == stop) { - // we have an empty string - return new QueryPart(false, null, stack.peek() == '\'' || stack.peek() == '"'); - } else if (stack.peek() == '\'' || stack.peek() == '"') { - // we have an open quote - return new QueryPart(false, query.substring(start, stop), true); - } else { - // see if the string is complete - if (scolonterm && query.charAt(stop - 1) == ';') { - return new QueryPart(true, query.substring(start, stop), false); - } else { - return new QueryPart(false, query.substring(start, stop), false); - } - } - } - - static final String dq(final String in) { - return "\"" + in.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"") + "\""; - } +public final class JdbcClient extends org.monetdb.client.JdbcClient { } - -/** - * A QueryPart is (a part of) a SQL query. In the QueryPart object information - * like the actual SQL query string, whether it has an open quote and the like - * is stored. - */ -final class QueryPart { - private final boolean complete; - private final String query; - private final boolean open; - - QueryPart(final boolean complete, final String query, final boolean open) { - this.complete = complete; - this.query = query; - this.open = open; - } - - boolean isEmpty() { - return query == null; - } - - boolean isComplete() { - return complete; - } - - String getQuery() { - return query; - } - - boolean hasOpenQuote() { - return open; - } -} - -/** - * An SQLStack is a simple stack that keeps track of open brackets and - * (single and double) quotes in an SQL query. - */ -final class SQLStack { - final StringBuilder stack = new StringBuilder(); - - char peek() { - if (empty()) { - return '\0'; - } else { - return stack.charAt(stack.length() - 1); - } - } - - char pop() { - final char tmp = peek(); - if (tmp != '\0') { - stack.setLength(stack.length() - 1); - } - return tmp; - } - - char push(char item) { - stack.append(item); - return item; - } - - boolean empty() { - return stack.length() == 0; - } -} - -/** - * A Table represents an SQL table. All data required to - * generate a fully qualified name is stored, as well as dependency - * data. - */ -final class Table { - final String schem; - final String name; - final String type; - final String fqname; - final ArrayList<Table> needs = new ArrayList<Table>(); - - Table(final String schem, final String name, final String type) { - this.schem = schem; - this.name = name; - this.type = type; - this.fqname = schem + "." + name; - } - - void addDependency(final Table dependsOn) throws Exception { - if (this.fqname.equals(dependsOn.fqname)) - throw new Exception("Cyclic dependency graphs are not supported (foreign key relation references self)"); - - if (dependsOn.needs.contains(this)) - throw new Exception("Cyclic dependency graphs are not supported (foreign key relation a->b and b->a)"); - - if (!needs.contains(dependsOn)) - needs.add(dependsOn); - } - - List<Table> requires(final List<Table> existingTables) { - if (existingTables == null || existingTables.isEmpty()) - return new ArrayList<Table>(needs); - - final ArrayList<Table> req = new ArrayList<Table>(); - for (Table n : needs) { - if (!existingTables.contains(n)) - req.add(n); - } - - return req; - } - - final String getSchem() { - return schem; - } - - final String getName() { - return name; - } - - final String getType() { - return type; - } - - final String getFqname() { - return fqname; - } - - final String getFqnameQ() { - return JdbcClient.dq(schem) + "." + JdbcClient.dq(name); - } - - public final String toString() { - return fqname; - } - - static final Table findTable(final String schname, final String tblname, final List<Table> list) { - for (Table t : list) { - if (t.schem.equals(schname) && t.name.equals(tblname)) - return t; - } - // not found - return null; - } - - static final void checkForLoop(final Table table, final List<Table> parents) throws Exception { - parents.add(table); - for (int i = 0; i < table.needs.size(); i++) { - Table child = table.needs.get(i); - if (parents.contains(child)) - throw new Exception("Cyclic dependency graphs are not supported (cycle detected for " + child.fqname + ")"); - checkForLoop(child, parents); - } - } -} -
new file mode 100644 --- /dev/null +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java @@ -0,0 +1,17 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. + */ + +package nl.cwi.monetdb.jdbc; + +/** + * a wrapper class for old programs who still depend on + * class nl.cwi.monetdb.jdbc.MonetDriver to work. + * This class is deprecated since nov 2020 and will be removed in a future release. + */ +public final class MonetDriver extends org.monetdb.jdbc.MonetDriver { +}
--- a/src/main/java/nl/cwi/monetdb/jdbc/types/INET.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/types/INET.java @@ -8,155 +8,10 @@ package nl.cwi.monetdb.jdbc.types; -import java.net.InetAddress; -import java.sql.SQLDataException; -import java.sql.SQLException; - /** - * The INET class represents the INET datatype in MonetDB. - * It represents a IPv4 address with a certain mask applied. - * Currently, IPv6 is not supported. - * - * The input format for INET is x.x.x.x/y where x.x.x.x is an IP address - * and y is the number of bits in the netmask. If the /y part is left - * off, then the netmask is 32, and the value represents just a single - * host. On display, the /y portion is suppressed if the netmask is 32. - * - * This class allows to retrieve the value of this INET as InetAddress. - * This is probably meaningful only and only if the netmask is 32. - * The getNetmaskBits() method can be used to retrieve the subnet bits. + * a wrapper class for old programs who still depend on + * class nl.cwi.monetdb.jdbc.types.INET to work. + * This class is deprecated since nov 2020 and will be removed in a future release. */ -public final class INET implements java.sql.SQLData { - private String inet; - - @Override - public String getSQLTypeName() { - return "inet"; - } - - @Override - public void readSQL(final java.sql.SQLInput stream, final String typeName) throws SQLException { - if (!"inet".equals(typeName)) - throw new SQLException("can only use this class with 'inet' type", "M1M05"); - inet = stream.readString(); - } - - @Override - public void writeSQL(final java.sql.SQLOutput stream) throws SQLException { - stream.writeString(inet); - } - - @Override - public String toString() { - return inet; - } - - public void fromString(final String newinet) throws SQLException { - if (newinet == null) { - inet = newinet; - return; - } - - String tinet = newinet; - final int slash = newinet.indexOf('/'); - if (slash != -1) { - final int netmask; - // ok, see if it is a valid netmask - try { - netmask = Integer.parseInt(newinet.substring(slash + 1)); - } catch (NumberFormatException nfe) { - throw new SQLDataException("cannot parse netmask bits: " + - newinet.substring(slash + 1), "22M29"); - } - if (netmask <= 0 || netmask > 32) - throw new SQLDataException("netmask must be >0 and <32", "22M29"); - tinet = newinet.substring(0, slash); - } - // check dotted quad - final String quads[] = tinet.split("\\."); - if (quads.length != 4) - throw new SQLDataException("expected dotted quad (xxx.xxx.xxx.xxx)", "22M29"); - for (int i = 0; i < 4; i++) { - final int quadv; - try { - quadv = Integer.parseInt(quads[i]); - } catch (NumberFormatException nfe) { - throw new SQLDataException("cannot parse number: " + quads[i], "22M29"); - } - if (quadv < 0 || quadv > 255) - throw new SQLDataException("value must be between 0 and 255: " + quads[i], "22M29"); - } - // everything is fine - inet = newinet; - } - - public String getAddress() { - if (inet == null) - return null; - - // inet optionally has a /y part, if y < 32, chop it off - final int slash = inet.indexOf('/'); - if (slash != -1) - return inet.substring(0, slash); - return inet; - } - - public void setAddress(final String newinet) throws Exception { - if (newinet == null) { - inet = newinet; - return; - } - if (newinet.indexOf('/') != -1) - throw new Exception("IPv4 address cannot contain '/' " + - "(use fromString() instead)"); - fromString(newinet); - } - - public int getNetmaskBits() throws SQLException { - if (inet == null) - return 0; - - // if netmask is 32, it is omitted in the output - int slash = inet.indexOf('/'); - if (slash == -1) - return 32; - try { - return Integer.parseInt(inet.substring(slash + 1)); - } catch (NumberFormatException nfe) { - throw new SQLDataException("cannot parse netmask bits: " + - inet.substring(slash + 1), "22M29"); - } - } - - public void setNetmaskBits(final int bits) throws Exception { - String newinet = inet; - if (newinet == null) { - newinet = "0.0.0.0/" + bits; - } else { - final int slash = newinet.indexOf('/'); - if (slash != -1) { - newinet = newinet.substring(0, slash + 1) + bits; - } else { - newinet = newinet + "/" + bits; - } - } - fromString(newinet); - } - - public InetAddress getInetAddress() throws SQLException { - if (inet == null) - return null; - - try { - return InetAddress.getByName(getAddress()); - } catch (java.net.UnknownHostException uhe) { - throw new SQLDataException("could not resolve IP address", "22M29"); - } - } - - public void setInetAddress(final InetAddress iaddr) throws Exception { - if (!(iaddr instanceof java.net.Inet4Address)) - throw new Exception("only IPv4 are supported currently"); - fromString(iaddr.getHostAddress()); - } +public final class INET extends org.monetdb.jdbc.types.INET { }
--- a/src/main/java/nl/cwi/monetdb/jdbc/types/URL.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/types/URL.java @@ -8,61 +8,10 @@ package nl.cwi.monetdb.jdbc.types; -import java.sql.SQLException; - /** - * The URL class represents the URL datatype in MonetDB. - * It represents an URL, that is, a well-formed string conforming to RFC2396. + * a wrapper class for old programs who still depend on + * class nl.cwi.monetdb.jdbc.types.URL to work. + * This class is deprecated since nov 2020 and will be removed in a future release. */ -public final class URL implements java.sql.SQLData { - private String url; - - @Override - public String getSQLTypeName() { - return "url"; - } - - @Override - public void readSQL(final java.sql.SQLInput stream, final String typeName) throws SQLException { - if (!"url".equals(typeName)) - throw new SQLException("can only use this class with 'url' type", "M1M05"); - url = stream.readString(); - } - - @Override - public void writeSQL(final java.sql.SQLOutput stream) throws SQLException { - stream.writeString(url); - } - - @Override - public String toString() { - return url; - } - - public void fromString(final String newurl) throws Exception { - if (newurl == null) { - url = newurl; - return; - } - - // parse the newurl on validity - new java.net.URL(newurl); - // if above doesn't fail (throws an Exception), it is fine - url = newurl; - } - - public java.net.URL getURL() throws SQLException { - if (url == null) - return null; - - try { - return new java.net.URL(url); - } catch (java.net.MalformedURLException mue) { - throw new java.sql.SQLDataException("data is not a valid URL: " + mue.getMessage(), "22M30"); - } - } - - public void setURL(final java.net.URL nurl) throws Exception { - url = nurl.toString(); - } +public final class URL extends org.monetdb.jdbc.types.URL { }
--- a/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java +++ b/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java @@ -8,1083 +8,16 @@ package nl.cwi.monetdb.mcl.net; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.FileWriter; -import java.io.FilterInputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; -import java.io.Writer; -import java.net.Socket; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.net.URI; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import nl.cwi.monetdb.mcl.MCLException; -import nl.cwi.monetdb.mcl.io.BufferedMCLReader; -import nl.cwi.monetdb.mcl.io.BufferedMCLWriter; -import nl.cwi.monetdb.mcl.parser.MCLParseException; - /** - * A Socket for communicating with the MonetDB database in MAPI block - * mode. - * - * The MapiSocket implements the protocol specifics of the MAPI block - * mode protocol, and interfaces it as a socket that delivers a - * BufferedReader and a BufferedWriter. Because logging in is an - * integral part of the MAPI protocol, the MapiSocket performs the login - * procedure. Like the Socket class, various options can be set before - * calling the connect() method to influence the login process. Only - * after a successful call to connect() the BufferedReader and - * BufferedWriter can be retrieved. - * - * For each line read, it is determined what type of line it is - * according to the MonetDB MAPI protocol. This results in a line to be - * PROMPT, HEADER, RESULT, ERROR or UNKNOWN. Use the getLineType() - * method on the BufferedMCLReader to retrieve the type of the last - * line read. - * - * For debugging purposes a socket level debugging is implemented where - * each and every interaction to and from the MonetDB server is logged - * to a file on disk. - * Incoming messages are prefixed by "RX" (received by the driver), - * outgoing messages by "TX" (transmitted by the driver). Special - * decoded non-human readable messages are prefixed with "RD" and "TD" - * instead. Following this two char prefix, a timestamp follows as the - * number of milliseconds since the UNIX epoch. The rest of the line is - * a String representation of the data sent or received. - * - * The general use of this Socket must be seen only in the full context - * of a MAPI connection to a server. It has the same ingredients as a - * normal Socket, allowing for seamless plugging. - * <pre> - * Socket \ / InputStream ----> (BufferedMCL)Reader - * > o < - * MapiSocket / \ OutputStream ----> (BufferedMCL)Writer - * </pre> - * The MapiSocket allows to retrieve Streams for communicating. They - * are interfaced, so they can be chained in any way. While the Socket - * transparently deals with how data is sent over the wire, the actual - * data read needs to be interpreted, for which a Reader/Writer - * interface is most sufficient. In particular the BufferedMCL* - * implementations of those interfaces supply some extra functionality - * geared towards the format of the data. - * - * @author Fabian Groffen - * @version 4.1 - * @see nl.cwi.monetdb.mcl.io.BufferedMCLReader - * @see nl.cwi.monetdb.mcl.io.BufferedMCLWriter + * a wrapper class for old programs who still depend on + * class nl.cwi.monetdb.mcl.net.MapiSocket to work. + * This class is deprecated since nov 2020 and will be removed in a future release. */ -public final class MapiSocket { - /** The TCP Socket to mserver */ - private Socket con; - /** The TCP Socket timeout in milliseconds. Default is 0 meaning the timeout is disabled (i.e., timeout of infinity) */ - private int soTimeout = 0; - /** Stream from the Socket for reading */ - private InputStream fromMonet; - /** Stream from the Socket for writing */ - private OutputStream toMonet; - /** MCLReader on the InputStream */ - private BufferedMCLReader reader; - /** MCLWriter on the OutputStream */ - private BufferedMCLWriter writer; - /** protocol version of the connection */ - private int version; - - /** The database to connect to */ - private String database = null; - /** The language to connect with */ - private String language = "sql"; - /** The hash methods to use (null = default) */ - private String hash = null; - - /** Whether we should follow redirects */ - private boolean followRedirects = true; - /** How many redirections do we follow until we're fed up with it? */ - private int ttl = 10; - - /** Whether we are debugging or not */ - private boolean debug = false; - /** The Writer for the debug log-file */ - private Writer log; - - /** The blocksize (hardcoded in compliance with MonetDB common/stream/stream.h) */ - public final static int BLOCK = 8 * 1024 - 2; - - /** A short in two bytes for holding the block size in bytes */ - private final byte[] blklen = new byte[2]; - +public final class MapiSocket extends org.monetdb.mcl.net.MapiSocket { /** * Constructs a new MapiSocket. */ public MapiSocket() { - con = null; - } - - /** - * Sets the database to connect to. If database is null, a - * connection is made to the default database of the server. This - * is also the default. - * - * @param db the database - */ - public void setDatabase(final String db) { - this.database = db; - } - - /** - * Sets the language to use for this connection. - * - * @param lang the language - */ - public void setLanguage(final String lang) { - this.language = lang; - } - - /** - * Sets the hash method to use. Note that this method is intended - * for debugging purposes. Setting a hash method can yield in - * connection failures. Multiple hash methods can be given by - * separating the hashes by commas. - * DON'T USE THIS METHOD if you don't know what you're doing. - * - * @param hash the hash method to use - */ - public void setHash(final String hash) { - this.hash = hash; - } - - /** - * Sets whether MCL redirections should be followed or not. If set - * to false, an MCLException will be thrown when a redirect is - * encountered during connect. The default bahaviour is to - * automatically follow redirects. - * - * @param r whether to follow redirects (true) or not (false) - */ - public void setFollowRedirects(final boolean r) { - this.followRedirects = r; - } - - /** - * Sets the number of redirects that are followed when - * followRedirects is true. In order to avoid going into an endless - * loop due to some evil server, or another error, a maximum number - * of redirects that may be followed can be set here. Note that to - * disable the following of redirects you should use - * setFollowRedirects. - * - * @see #setFollowRedirects(boolean r) - * @param t the number of redirects before an exception is thrown - */ - public void setTTL(final int t) { - this.ttl = t; - } - - /** - * Set the SO_TIMEOUT on the underlying Socket. When for some - * reason the connection to the database hangs, this setting can be - * useful to break out of this indefinite wait. - * This option must be enabled prior to entering the blocking - * operation to have effect. - * - * @param s The specified timeout, in milliseconds. A timeout - * of zero will disable timeout (i.e., timeout of infinity). - * @throws SocketException Issue with the socket - */ - public void setSoTimeout(final int s) throws SocketException { - if (s < 0) { - throw new IllegalArgumentException("timeout can't be negative"); - } - this.soTimeout = s; - // limit time to wait on blocking operations - if (con != null) { - con.setSoTimeout(s); - } - } - - /** - * Gets the SO_TIMEOUT from the underlying Socket. - * - * @return the currently in use timeout in milliseconds - * @throws SocketException Issue with the socket - */ - public int getSoTimeout() throws SocketException { - if (con != null) { - this.soTimeout = con.getSoTimeout(); - } - return this.soTimeout; - } - - /** - * Enables/disables debug mode with logging to file - * - * @param debug Value to set - */ - public void setDebug(final boolean debug) { - this.debug = debug; - } - - /** - * Connects to the given host and port, logging in as the given - * user. If followRedirect is false, a RedirectionException is - * thrown when a redirect is encountered. - * - * @param host the hostname, or null for the loopback address - * @param port the port number (must be between 0 and 65535, inclusive) - * @param user the username - * @param pass the password - * @return A List with informational (warning) messages. If this - * list is empty; then there are no warnings. - * @throws IOException if an I/O error occurs when creating the socket - * @throws SocketException - if there is an error in the underlying protocol, such as a TCP error. - * @throws UnknownHostException if the IP address of the host could not be determined - * @throws MCLParseException if bogus data is received - * @throws MCLException if an MCL related error occurs - */ - public List<String> connect(final String host, final int port, final String user, final String pass) - throws IOException, SocketException, UnknownHostException, MCLParseException, MCLException - { - // Wrap around the internal connect that needs to know if it - // should really make a TCP connection or not. - return connect(host, port, user, pass, true); - } - - private List<String> connect(final String host, final int port, final String user, final String pass, final boolean makeConnection) - throws IOException, SocketException, UnknownHostException, MCLParseException, MCLException - { - if (ttl-- <= 0) - throw new MCLException("Maximum number of redirects reached, aborting connection attempt."); - - if (makeConnection) { - con = new Socket(host, port); - con.setSoTimeout(this.soTimeout); - // set nodelay, as it greatly speeds up small messages (like we often do) - con.setTcpNoDelay(true); - con.setKeepAlive(true); - - fromMonet = new BlockInputStream(con.getInputStream()); - toMonet = new BlockOutputStream(con.getOutputStream()); - try { - reader = new BufferedMCLReader(fromMonet, "UTF-8"); - writer = new BufferedMCLWriter(toMonet, "UTF-8"); - writer.registerReader(reader); - } catch (UnsupportedEncodingException e) { - throw new MCLException(e.toString()); - } - } - - final String c = reader.readLine(); - reader.waitForPrompt(); - writer.writeLine(getChallengeResponse(c, user, pass, language, database, hash)); - - // read monetdb mserver response till prompt - final ArrayList<String> redirects = new ArrayList<String>(); - final List<String> warns = new ArrayList<String>(); - String err = "", tmp; - int lineType; - do { - tmp = reader.readLine(); - if (tmp == null) - throw new IOException("Read from " + - con.getInetAddress().getHostName() + ":" + - con.getPort() + ": End of stream reached"); - lineType = reader.getLineType(); - if (lineType == BufferedMCLReader.ERROR) { - err += "\n" + tmp.substring(7); - } else if (lineType == BufferedMCLReader.INFO) { - warns.add(tmp.substring(1)); - } else if (lineType == BufferedMCLReader.REDIRECT) { - redirects.add(tmp.substring(1)); - } - } while (lineType != BufferedMCLReader.PROMPT); - - if (err.length() > 0) { - close(); - throw new MCLException(err); - } - - if (!redirects.isEmpty()) { - if (followRedirects) { - // Ok, server wants us to go somewhere else. The list - // might have multiple clues on where to go. For now we - // don't support anything intelligent but trying the - // first one. URI should be in form of: - // "mapi:monetdb://host:port/database?arg=value&..." - // or - // "mapi:merovingian://proxy?arg=value&..." - // note that the extra arguments must be obeyed in both - // cases - final String suri = redirects.get(0).toString(); - if (!suri.startsWith("mapi:")) - throw new MCLException("unsupported redirect: " + suri); - - final URI u; - try { - u = new URI(suri.substring(5)); - } catch (java.net.URISyntaxException e) { - throw new MCLParseException(e.toString()); - } - - tmp = u.getQuery(); - if (tmp != null) { - final String args[] = tmp.split("&"); - for (int i = 0; i < args.length; i++) { - int pos = args[i].indexOf("="); - if (pos > 0) { - tmp = args[i].substring(0, pos); - if (tmp.equals("database")) { - tmp = args[i].substring(pos + 1); - if (!tmp.equals(database)) { - warns.add("redirect points to different database: " + tmp); - setDatabase(tmp); - } - } else if (tmp.equals("language")) { - tmp = args[i].substring(pos + 1); - warns.add("redirect specifies use of different language: " + tmp); - setLanguage(tmp); - } else if (tmp.equals("user")) { - tmp = args[i].substring(pos + 1); - if (!tmp.equals(user)) - warns.add("ignoring different username '" + tmp + "' set by " + - "redirect, what are the security implications?"); - } else if (tmp.equals("password")) { - warns.add("ignoring different password set by redirect, " + - "what are the security implications?"); - } else { - warns.add("ignoring unknown argument '" + tmp + "' from redirect"); - } - } else { - warns.add("ignoring illegal argument from redirect: " + args[i]); - } - } - } - - if (u.getScheme().equals("monetdb")) { - // this is a redirect to another (monetdb) server, - // which means a full reconnect - // avoid the debug log being closed - if (debug) { - debug = false; - close(); - debug = true; - } else { - close(); - } - tmp = u.getPath(); - if (tmp != null && tmp.length() > 0) { - tmp = tmp.substring(1).trim(); - if (!tmp.isEmpty() && !tmp.equals(database)) { - warns.add("redirect points to different database: " + tmp); - setDatabase(tmp); - } - } - final int p = u.getPort(); - warns.addAll(connect(u.getHost(), p == -1 ? port : p, user, pass, true)); - warns.add("Redirect by " + host + ":" + port + " to " + suri); - } else if (u.getScheme().equals("merovingian")) { - // reuse this connection to inline connect to the - // right database that Merovingian proxies for us - warns.addAll(connect(host, port, user, pass, false)); - } else { - throw new MCLException("unsupported scheme in redirect: " + suri); - } - } else { - final StringBuilder msg = new StringBuilder("The server sent a redirect for this connection:"); - for (String it : redirects) { - msg.append(" [" + it + "]"); - } - throw new MCLException(msg.toString()); - } - } - return warns; - } - - /** - * A little helper function that processes a challenge string, and - * returns a response string for the server. If the challenge - * string is null, a challengeless response is returned. - * - * @param chalstr the challenge string - * for example: H8sRMhtevGd:mserver:9:PROT10,RIPEMD160,SHA256,SHA1,COMPRESSION_SNAPPY,COMPRESSION_LZ4:LIT:SHA512: - * @param username the username to use - * @param password the password to use - * @param language the language to use - * @param database the database to connect to - * @param hash the hash method(s) to use, or NULL for all supported hashes - */ - private String getChallengeResponse( - final String chalstr, - String username, - String password, - final String language, - final String database, - final String hash - ) throws MCLParseException, MCLException, IOException { - // parse the challenge string, split it on ':' - final String[] chaltok = chalstr.split(":"); - if (chaltok.length <= 5) - throw new MCLParseException("Server challenge string unusable! It contains too few (" + chaltok.length + ") tokens: " + chalstr); - - try { - version = Integer.parseInt(chaltok[2]); // protocol version - } catch (NumberFormatException e) { - throw new MCLParseException("Protocol version (" + chaltok[2] + ") unparseable as integer."); - } - - // handle the challenge according to the version it is - switch (version) { - case 9: - // proto 9 is like 8, but uses a hash instead of the plain password - // the server tells us (in 6th token) which hash in the - // challenge after the byte-order token - - String algo; - String pwhash = chaltok[5]; - /* NOTE: Java doesn't support RIPEMD160 :( */ - /* see: https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#MessageDigest */ - if (pwhash.equals("SHA512")) { - algo = "SHA-512"; - } else if (pwhash.equals("SHA384")) { - algo = "SHA-384"; - } else if (pwhash.equals("SHA256")) { - algo = "SHA-256"; - /* NOTE: Java 7 doesn't support SHA-224. Java 8 does but we have not tested it. It is also not requested yet. */ - } else if (pwhash.equals("SHA1")) { - algo = "SHA-1"; - } else { - /* Note: MD5 has been deprecated by security experts and support is removed from Oct 2020 release */ - throw new MCLException("Unsupported password hash: " + pwhash); - } - try { - final MessageDigest md = MessageDigest.getInstance(algo); - md.update(password.getBytes("UTF-8")); - password = toHex(md.digest()); - } catch (NoSuchAlgorithmException e) { - throw new MCLException("This JVM does not support password hash: " + pwhash + "\n" + e.toString()); - } catch (UnsupportedEncodingException e) { - throw new MCLException("This JVM does not support UTF-8 encoding\n" + e.toString()); - } - - // proto 7 (finally) used the challenge and works with a - // password hash. The supported implementations come - // from the server challenge. We chose the best hash - // we can find, in the order SHA512, SHA1, MD5, plain. - // Also the byte-order is reported in the challenge string, - // which makes sense, since only blockmode is supported. - // proto 8 made this obsolete, but retained the - // byte-order report for future "binary" transports. - // In proto 8, the byte-order of the blocks is always little - // endian because most machines today are. - final String hashes = (hash == null || hash.isEmpty()) ? chaltok[3] : hash; - final HashSet<String> hashesSet = new HashSet<String>(java.util.Arrays.asList(hashes.toUpperCase().split("[, ]"))); // split on comma or space - - // if we deal with merovingian, mask our credentials - if (chaltok[1].equals("merovingian") && !language.equals("control")) { - username = "merovingian"; - password = "merovingian"; - } - - // reuse variables algo and pwhash - algo = null; - pwhash = null; - if (hashesSet.contains("SHA512")) { - algo = "SHA-512"; - pwhash = "{SHA512}"; - } else if (hashesSet.contains("SHA384")) { - algo = "SHA-384"; - pwhash = "{SHA384}"; - } else if (hashesSet.contains("SHA256")) { - algo = "SHA-256"; - pwhash = "{SHA256}"; - } else if (hashesSet.contains("SHA1")) { - algo = "SHA-1"; - pwhash = "{SHA1}"; - } else { - /* Note: MD5 has been deprecated by security experts and support is removed from Oct 2020 release */ - throw new MCLException("no supported hash algorithms found in " + hashes); - } - try { - final MessageDigest md = MessageDigest.getInstance(algo); - md.update(password.getBytes("UTF-8")); - md.update(chaltok[0].getBytes("UTF-8")); // salt/key - pwhash += toHex(md.digest()); - } catch (NoSuchAlgorithmException e) { - throw new MCLException("This JVM does not support password hash: " + pwhash + "\n" + e.toString()); - } catch (UnsupportedEncodingException e) { - throw new MCLException("This JVM does not support UTF-8 encoding\n" + e.toString()); - } - - // TODO: some day when we need this, we should store this - if (chaltok[4].equals("BIG")) { - // byte-order of server is big-endian - } else if (chaltok[4].equals("LIT")) { - // byte-order of server is little-endian - } else { - throw new MCLParseException("Invalid byte-order: " + chaltok[4]); - } - - // compose and return response - return "BIG:" // JVM byte-order is big-endian - + username + ":" - + pwhash + ":" - + language + ":" - + (database == null ? "" : database) + ":"; - default: - throw new MCLException("Unsupported protocol version: " + version); - } - } - - /** - * Small helper method to convert a byte string to a hexadecimal - * string representation. - * - * @param digest the byte array to convert - * @return the byte array as hexadecimal string - */ - private final static String toHex(final byte[] digest) { - final char[] result = new char[digest.length * 2]; - int pos = 0; - for (int i = 0; i < digest.length; i++) { - result[pos++] = hexChar((digest[i] & 0xf0) >> 4); - result[pos++] = hexChar(digest[i] & 0x0f); - } - return new String(result); - } - - private final static char hexChar(final int n) { - return (n > 9) - ? (char) ('a' + (n - 10)) - : (char) ('0' + n); - } - - - /** - * Returns an InputStream that reads from this open connection on - * the MapiSocket. - * - * @return an input stream that reads from this open connection - */ - public InputStream getInputStream() { - return fromMonet; - } - - /** - * Returns an output stream for this MapiSocket. - * - * @return an output stream for writing bytes to this MapiSocket - */ - public OutputStream getOutputStream() { - return toMonet; - } - - /** - * Returns a Reader for this MapiSocket. The Reader is a - * BufferedMCLReader which does protocol interpretation of the - * BlockInputStream produced by this MapiSocket. - * - * @return a BufferedMCLReader connected to this MapiSocket - */ - public BufferedMCLReader getReader() { - return reader; - } - - /** - * Returns a Writer for this MapiSocket. The Writer is a - * BufferedMCLWriter which produces protocol compatible data blocks - * that the BlockOutputStream can properly translate into blocks. - * - * @return a BufferedMCLWriter connected to this MapiSocket - */ - public BufferedMCLWriter getWriter() { - return writer; - } - - /** - * Returns the mapi protocol version used by this socket. The - * protocol version depends on the server being used. Users of the - * MapiSocket should check this version to act appropriately. - * - * @return the mapi protocol version - */ - public int getProtocolVersion() { - return version; - } - - /** - * Enables logging to a file what is read and written from and to - * the server. Logging can be enabled at any time. However, it is - * encouraged to start debugging before actually connecting the - * socket. - * - * @param filename the name of the file to write to - * @throws IOException if the file could not be opened for writing - */ - public void debug(final String filename) throws IOException { - debug(new FileWriter(filename)); - } - - /** - * Enables logging to a stream what is read and written from and to - * the server. Logging can be enabled at any time. However, it is - * encouraged to start debugging before actually connecting the - * socket. - * - * @param out to write the log to a print stream - * @throws IOException if the file could not be opened for writing - */ -// disabled as it is not used by JDBC driver code -// public void debug(PrintStream out) throws IOException { -// debug(new PrintWriter(out)); -// } - - /** - * Enables logging to a stream what is read and written from and to - * the server. Logging can be enabled at any time. However, it is - * encouraged to start debugging before actually connecting the - * socket. - * - * @param out to write the log to - */ - public void debug(final Writer out) { - log = out; - debug = true; - } - - /** - * Get the log Writer. - * - * @return the log writer - */ - public Writer getLogWriter() { - return log; - } - - /** - * Writes a logline tagged with a timestamp using the given type and message - * and optionally flushes afterwards. - * - * Used for debugging purposes only and represents a message data that is - * connected to reading (RD or RX) or writing (TD or TX) to the socket. - * R=Receive, T=Transmit, D=Data, X=?? - * - * @param type message type: either RD, RX, TD or TX - * @param message the message to log - * @param flush whether we need to flush buffered data to the logfile. - * @throws IOException if an IO error occurs while writing to the logfile - */ - private final void log(final String type, final String message, final boolean flush) throws IOException { - log.write(type + System.currentTimeMillis() + ": " + message + "\n"); - if (flush) - log.flush(); - } - - /** - * Inner class that is used to write data on a normal stream as a - * blocked stream. A call to the flush() method will write a - * "final" block to the underlying stream. Non-final blocks are - * written as soon as one or more bytes would not fit in the - * current block any more. This allows to write to a block to it's - * full size, and then flush it explicitly to have a final block - * being written to the stream. - */ - final class BlockOutputStream extends FilterOutputStream { - private int writePos = 0; - private int blocksize = 0; - private final byte[] block = new byte[BLOCK]; - - /** - * Constructs this BlockOutputStream, backed by the given - * OutputStream. A BufferedOutputStream is internally used. - */ - public BlockOutputStream(final OutputStream out) { - // always use a buffered stream, even though we know how - // much bytes to write/read, since this is just faster for - // some reason - super(new BufferedOutputStream(out)); - } - - @Override - public void flush() throws IOException { - // write the block (as final) then flush. - writeBlock(true); - out.flush(); - - // it's a bit nasty if an exception is thrown from the log, - // but ignoring it can be nasty as well, so it is decided to - // let it go so there is feedback about something going wrong - // it's a bit nasty if an exception is thrown from the log, - // but ignoring it can be nasty as well, so it is decided to - // let it go so there is feedback about something going wrong - if (debug) { - log.flush(); - } - } - - /** - * writeBlock puts the data in the block on the stream. The - * boolean last controls whether the block is sent with an - * indicator to note it is the last block of a sequence or not. - * - * @param last whether this is the last block - * @throws IOException if writing to the stream failed - */ - public void writeBlock(final boolean last) throws IOException { - if (last) { - // always fits, because of BLOCK's size - blocksize = (short)writePos; - // this is the last block, so encode least - // significant bit in the first byte (little-endian) - blklen[0] = (byte)(blocksize << 1 & 0xFF | 1); - blklen[1] = (byte)(blocksize >> 7); - } else { - // always fits, because of BLOCK's size - blocksize = (short)BLOCK; - // another block will follow, encode least - // significant bit in the first byte (little-endian) - blklen[0] = (byte)(blocksize << 1 & 0xFF); - blklen[1] = (byte)(blocksize >> 7); - } - - out.write(blklen); - // write the actual block - out.write(block, 0, writePos); - - if (debug) { - if (last) { - log("TD ", "write final block: " + writePos + " bytes", false); - } else { - log("TD ", "write block: " + writePos + " bytes", false); - } - log("TX ", new String(block, 0, writePos, "UTF-8"), true); - } - - writePos = 0; - } - - @Override - public void write(final int b) throws IOException { - if (writePos == BLOCK) { - writeBlock(false); - } - block[writePos++] = (byte)b; - } - - @Override - public void write(final byte[] b) throws IOException { - write(b, 0, b.length); - } - - @Override - public void write(final byte[] b, int off, int len) throws IOException { - int t = 0; - while (len > 0) { - t = BLOCK - writePos; - if (len > t) { - System.arraycopy(b, off, block, writePos, t); - off += t; - len -= t; - writePos += t; - writeBlock(false); - } else { - System.arraycopy(b, off, block, writePos, len); - writePos += len; - break; - } - } - } - - @Override - public void close() throws IOException { - // we don't want the flush() method to be called (default of - // the FilterOutputStream), so we close manually here - out.close(); - } - } - - - /** - * Inner class that is used to make the data on the blocked stream - * available as a normal stream. - */ - final class BlockInputStream extends FilterInputStream { - private int readPos = 0; - private int blockLen = 0; - private final byte[] block = new byte[BLOCK + 3]; // \n.\n - - /** - * Constructs this BlockInputStream, backed by the given - * InputStream. A BufferedInputStream is internally used. - */ - public BlockInputStream(final InputStream in) { - // always use a buffered stream, even though we know how - // much bytes to write/read, since this is just faster for - // some reason - super(new BufferedInputStream(in)); - } - - @Override - public int available() { - return blockLen - readPos; - } - - @Override - public boolean markSupported() { - return false; - } - - @Override - public void mark(final int readlimit) { - throw new AssertionError("Not implemented!"); - } - - @Override - public void reset() { - throw new AssertionError("Not implemented!"); - } - - /** - * Small wrapper to get a blocking variant of the read() method - * on the BufferedInputStream. We want to benefit from the - * Buffered pre-fetching, but not dealing with half blocks. - * Changing this class to be able to use the partially received - * data will greatly complicate matters, while a performance - * improvement is debatable given the relatively small size of - * our blocks. Maybe it does speed up on slower links, then - * consider this method a quick bug fix/workaround. - * - * @return false if reading the block failed due to EOF - */ - private boolean _read(final byte[] b, int len) throws IOException { - int s; - int off = 0; - while (len > 0) { - s = in.read(b, off, len); - if (s == -1) { - // if we have read something before, we should have been - // able to read the whole, so make this fatal - if (off > 0) { - if (debug) { - log("RD ", "the following incomplete block was received:", false); - log("RX ", new String(b, 0, off, "UTF-8"), true); - } - throw new IOException("Read from " + - con.getInetAddress().getHostName() + ":" + - con.getPort() + ": Incomplete block read from stream"); - } - if (debug) - log("RD ", "server closed the connection (EOF)", true); - return false; - } - len -= s; - off += s; - } - - return true; - } - - /** - * Reads the next block on the stream into the internal buffer, - * or writes the prompt in the buffer. - * - * The blocked stream protocol consists of first a two byte - * integer indicating the length of the block, then the - * block, followed by another length + block. The end of - * such sequence is put in the last bit of the length, and - * hence this length should be shifted to the right to - * obtain the real length value first. We simply fetch - * blocks here as soon as they are needed for the stream's - * read methods. - * - * The user-flush, which is an implicit effect of the end of - * a block sequence, is communicated beyond the stream by - * inserting a prompt sequence on the stream after the last - * block. This method makes sure that a final block ends with a - * newline, if it doesn't already, in order to facilitate a - * Reader that is possibly chained to this InputStream. - * - * If the stream is not positioned correctly, hell will break - * loose. - */ - private int readBlock() throws IOException { - // read next two bytes (short) - if (!_read(blklen, 2)) - return(-1); - - // Get the short-value and store its value in blockLen. - blockLen = (short)( - (blklen[0] & 0xFF) >> 1 | - (blklen[1] & 0xFF) << 7 - ); - readPos = 0; - - if (debug) { - if ((blklen[0] & 0x1) == 1) { - log("RD ", "read final block: " + blockLen + " bytes", false); - } else { - log("RD ", "read new block: " + blockLen + " bytes", false); - } - } - - // sanity check to avoid bad servers make us do an ugly - // stack trace - if (blockLen > block.length) - throw new IOException("Server sent a block larger than BLOCKsize: " + - blockLen + " > " + block.length); - if (!_read(block, blockLen)) - return -1; - - if (debug) - log("RX ", new String(block, 0, blockLen, "UTF-8"), true); - - // if this is the last block, make it end with a newline and prompt - if ((blklen[0] & 0x1) == 1) { - if (blockLen > 0 && block[blockLen - 1] != '\n') { - // to terminate the block in a Reader - block[blockLen++] = '\n'; - } - // insert 'fake' flush - block[blockLen++] = BufferedMCLReader.PROMPT; - block[blockLen++] = '\n'; - if (debug) - log("RD ", "inserting prompt", true); - } - - return blockLen; - } - - @Override - public int read() throws IOException { - if (available() == 0) { - if (readBlock() == -1) - return -1; - } - - if (debug) - log("RX ", new String(block, readPos, 1, "UTF-8"), true); - - return (int)block[readPos++]; - } - - @Override - public int read(final byte[] b) throws IOException { - return read(b, 0, b.length); - } - - @Override - public int read(final byte[] b, int off, int len) throws IOException { - int t; - int size = 0; - while (size < len) { - t = available(); - if (t == 0) { - if (size != 0) - break; - if (readBlock() == -1) { - if (size == 0) - size = -1; - break; - } - t = available(); - } - if (len > t) { - System.arraycopy(block, readPos, b, off, t); - off += t; - len -= t; - readPos += t; - size += t; - } else { - System.arraycopy(block, readPos, b, off, len); - readPos += len; - size += len; - break; - } - } - return size; - } - - @Override - public long skip(final long n) throws IOException { - long skip = n; - int t = 0; - while (skip > 0) { - t = available(); - if (skip > t) { - skip -= t; - readPos += t; - readBlock(); - } else { - readPos += skip; - break; - } - } - return n; - } - } - - /** - * Closes the streams and socket connected to the server if possible. - * If an error occurs at closing a resource, it is ignored so as many - * resources as possible are closed. - */ - public synchronized void close() { - if (writer != null) { - try { - writer.close(); - writer = null; - } catch (IOException e) { /* ignore it */ } - } - if (reader != null) { - try { - reader.close(); - reader = null; - } catch (IOException e) { /* ignore it */ } - } - if (toMonet != null) { - try { - toMonet.close(); - toMonet = null; - } catch (IOException e) { /* ignore it */ } - } - if (fromMonet != null) { - try { - fromMonet.close(); - fromMonet = null; - } catch (IOException e) { /* ignore it */ } - } - if (con != null) { - try { - con.close(); // close the socket - con = null; - } catch (IOException e) { /* ignore it */ } - } - if (debug && log != null && log instanceof FileWriter) { - try { - log.close(); - log = null; - } catch (IOException e) { /* ignore it */ } - } - } - - /** - * Destructor called by garbage collector before destroying this - * object tries to disconnect the MonetDB connection if it has not - * been disconnected already. - * - * @deprecated (since="9") - */ - @Override - @Deprecated - protected void finalize() throws Throwable { - close(); - super.finalize(); + super(); } }
rename from src/main/java/nl/cwi/monetdb/client/JMonetDB.java rename to src/main/java/org/monetdb/client/JMonetDB.java --- a/src/main/java/nl/cwi/monetdb/client/JMonetDB.java +++ b/src/main/java/org/monetdb/client/JMonetDB.java @@ -6,13 +6,13 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.client; +package org.monetdb.client; -import nl.cwi.monetdb.merovingian.Control; -import nl.cwi.monetdb.merovingian.SabaothDB; +import org.monetdb.merovingian.Control; +import org.monetdb.merovingian.SabaothDB; -import nl.cwi.monetdb.util.CmdLineOpts; -import nl.cwi.monetdb.util.OptionsException; +import org.monetdb.util.CmdLineOpts; +import org.monetdb.util.OptionsException; import java.io.PrintWriter; import java.util.ArrayList;
copy from src/main/java/nl/cwi/monetdb/client/JdbcClient.java copy to src/main/java/org/monetdb/client/JdbcClient.java --- a/src/main/java/nl/cwi/monetdb/client/JdbcClient.java +++ b/src/main/java/org/monetdb/client/JdbcClient.java @@ -6,14 +6,14 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.client; +package org.monetdb.client; -import nl.cwi.monetdb.util.CmdLineOpts; -import nl.cwi.monetdb.util.Exporter; -import nl.cwi.monetdb.util.MDBvalidator; -import nl.cwi.monetdb.util.OptionsException; -import nl.cwi.monetdb.util.SQLExporter; -import nl.cwi.monetdb.util.XMLExporter; +import org.monetdb.util.CmdLineOpts; +import org.monetdb.util.Exporter; +import org.monetdb.util.MDBvalidator; +import org.monetdb.util.OptionsException; +import org.monetdb.util.SQLExporter; +import org.monetdb.util.XMLExporter; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -25,7 +25,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.sql.Connection; import java.sql.DatabaseMetaData; -import java.sql.DriverManager; // import is required as it will load the nl.cwi.monetdb.jdbc.MonetDriver class +import java.sql.DriverManager; // this import is required as it will trigger loading the org.monetdb.jdbc.MonetDriver class import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; @@ -48,7 +48,7 @@ import java.util.List; * @version 1.6 */ -public final class JdbcClient { +public class JdbcClient { /* cannot (yet) be final as nl.cwi.monetdb.client.JdbcClient extends this class */ private static Connection con; private static DatabaseMetaData dbmd; @@ -246,7 +246,7 @@ public final class JdbcClient { // We cannot use the DatabaseMetaData here, because we // cannot get a Connection. So instead, we just get the // values we want out of the Driver directly. - System.out.println("JDBC Driver: v" + nl.cwi.monetdb.jdbc.MonetDriver.getDriverVersion()); + System.out.println("JDBC Driver: v" + org.monetdb.jdbc.MonetDriver.getDriverVersion()); System.exit(0); } @@ -275,7 +275,7 @@ public final class JdbcClient { } // make sure the driver is loaded - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers + // Class.forName("org.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers // build the extra arguments of the JDBC connect string String attr = "?"; @@ -690,8 +690,8 @@ public final class JdbcClient { out.println("\\l<uri> executes the contents of the given file or URL"); out.println("\\i<uri> batch executes the inserts from the given file or URL"); out.println("\\vsci validate sql system catalog integrity"); - // out.println("\\vsni validate sql system netcdf tables integrity"); // depends on availability of netcdf library on server - // out.println("\\vsgi validate sql system geom tables integrity"); // depends on availability of geom library on server + // out.println("\\vsni validate sql system netcdf tables integrity"); // do not list as it depends on availability of netcdf library on server + // out.println("\\vsgi validate sql system geom tables integrity"); // do not list as it depends on availability of geom library on server out.println("\\vsi <schema> validate integrity of data in the given schema"); out.println("\\vdbi validate integrity of data in all user schemas in the database"); out.println("\\? or \\h this help screen");
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java rename to src/main/java/org/monetdb/jdbc/MonetBlob.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java +++ b/src/main/java/org/monetdb/jdbc/MonetBlob.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.io.ByteArrayInputStream; import java.io.InputStream;
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetCallableStatement.java rename to src/main/java/org/monetdb/jdbc/MonetCallableStatement.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetCallableStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetCallableStatement.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.io.InputStream; import java.io.Reader;
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java rename to src/main/java/org/monetdb/jdbc/MonetClob.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java +++ b/src/main/java/org/monetdb/jdbc/MonetClob.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.io.InputStream; import java.io.Reader;
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java rename to src/main/java/org/monetdb/jdbc/MonetConnection.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.io.File; import java.io.IOException; @@ -33,12 +33,12 @@ import java.util.Properties; import java.util.WeakHashMap; import java.util.concurrent.Executor; -import nl.cwi.monetdb.mcl.io.BufferedMCLReader; -import nl.cwi.monetdb.mcl.io.BufferedMCLWriter; -import nl.cwi.monetdb.mcl.net.MapiSocket; -import nl.cwi.monetdb.mcl.parser.HeaderLineParser; -import nl.cwi.monetdb.mcl.parser.MCLParseException; -import nl.cwi.monetdb.mcl.parser.StartOfHeaderParser; +import org.monetdb.mcl.io.BufferedMCLReader; +import org.monetdb.mcl.io.BufferedMCLWriter; +import org.monetdb.mcl.net.MapiSocket; +import org.monetdb.mcl.parser.HeaderLineParser; +import org.monetdb.mcl.parser.MCLParseException; +import org.monetdb.mcl.parser.StartOfHeaderParser; /** * A {@link Connection} suitable for the MonetDB database. @@ -107,8 +107,8 @@ public class MonetConnection private Map<String,Class<?>> typeMap = new HashMap<String,Class<?>>() { private static final long serialVersionUID = 1L; { - put("inet", nl.cwi.monetdb.jdbc.types.INET.class); - put("url", nl.cwi.monetdb.jdbc.types.URL.class); + put("inet", org.monetdb.jdbc.types.INET.class); + put("url", org.monetdb.jdbc.types.URL.class); } }; @@ -301,7 +301,7 @@ public class MonetConnection throw new SQLNonTransientConnectionException("Unable to connect (" + hostname + ":" + port + "): " + e.getMessage(), "08006"); } catch (MCLParseException e) { throw new SQLNonTransientConnectionException(e.getMessage(), "08001"); - } catch (nl.cwi.monetdb.mcl.MCLException e) { + } catch (org.monetdb.mcl.MCLException e) { final String[] connex = e.getMessage().split("\n"); final SQLException sqle = new SQLNonTransientConnectionException(connex[0], "08001", e); for (int i = 1; i < connex.length; i++) {
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.java rename to src/main/java/org/monetdb/jdbc/MonetDataSource.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.java +++ b/src/main/java/org/monetdb/jdbc/MonetDataSource.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.io.PrintWriter; import java.sql.Connection;
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java rename to src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -3235,9 +3235,9 @@ public class MonetDatabaseMetaData "t.\"sqlname\" AS \"TYPE_NAME\", " + "CASE t.\"sqlname\"" + // next 4 UDTs are standard - " WHEN 'inet' THEN 'nl.cwi.monetdb.jdbc.types.INET'" + + " WHEN 'inet' THEN 'org.monetdb.jdbc.types.INET'" + " WHEN 'json' THEN 'java.lang.String'" + - " WHEN 'url' THEN 'nl.cwi.monetdb.jdbc.types.URL'" + + " WHEN 'url' THEN 'org.monetdb.jdbc.types.URL'" + " WHEN 'uuid' THEN 'java.lang.String'" + " ELSE 'java.lang.Object' END AS \"CLASS_NAME\", " + "cast(CASE WHEN t.\"sqlname\" IN ('inet', 'json', 'url', 'uuid') THEN ").append(Types.JAVA_OBJECT)
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in rename to src/main/java/org/monetdb/jdbc/MonetDriver.java.in --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in +++ b/src/main/java/org/monetdb/jdbc/MonetDriver.java.in @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.net.URI; import java.sql.Connection; @@ -38,7 +38,7 @@ import java.util.Properties; * @author Fabian Groffen * @version @JDBC_MAJOR@.@JDBC_MINOR@ (@JDBC_VER_SUFFIX@) based on MCL v@MCL_MAJOR@.@MCL_MINOR@" */ -final public class MonetDriver implements Driver { +public class MonetDriver implements Driver { /* cannot (yet) be final as nl.cwi.monetdb.jdbc.MonetDriver extends this class */ // the url kind will be jdbc:monetdb://<host>[:<port>]/<database> // Chapter 9.2.1 from Sun JDBC 3.0 specification /** The prefix of a MonetDB url */ @@ -314,7 +314,7 @@ final public class MonetDriver implement /** * Returns a touched up identifying version string of this driver. - * It is made public as it is called from nl/cwi/monetdb/client/JdbcClient.java + * It is made public as it is called from org/monetdb/client/JdbcClient.java * @return the version string */ public static final String getDriverVersion() {
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java rename to src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.io.InputStream; import java.io.IOException; @@ -2243,7 +2243,7 @@ public class MonetPreparedStatement try { // check if x represents a valid inet string to prevent // failing exec #(..., ...) calls which destroy the prepared statement, see bug 6351 - nl.cwi.monetdb.jdbc.types.INET inet_obj = new nl.cwi.monetdb.jdbc.types.INET(); + org.monetdb.jdbc.types.INET inet_obj = new org.monetdb.jdbc.types.INET(); inet_obj.fromString(x); } catch (SQLException se) { throw new SQLDataException("Conversion of string: " + x + " to parameter data type " + paramMonetdbType + " failed. " + se.getMessage(), "22M29");
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java rename to src/main/java/org/monetdb/jdbc/MonetResultSet.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java +++ b/src/main/java/org/monetdb/jdbc/MonetResultSet.java @@ -6,10 +6,10 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; - -import nl.cwi.monetdb.mcl.parser.MCLParseException; -import nl.cwi.monetdb.mcl.parser.TupleLineParser; +package org.monetdb.jdbc; + +import org.monetdb.mcl.parser.MCLParseException; +import org.monetdb.mcl.parser.TupleLineParser; import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; @@ -439,7 +439,7 @@ public class MonetResultSet throw newSQLInvalidColumnIndexException(columnIndex); } } - + /** * Retrieves the value of the designated column in the current row * of this ResultSet object as a stream of uninterpreted bytes. The @@ -1420,7 +1420,7 @@ public class MonetResultSet checkColumnIndexValidity(column); return false; } - + /** * Indicates whether values in the designated column are signed * numbers. @@ -1954,7 +1954,7 @@ public class MonetResultSet case 3: if ("url".equals(MonetDBType)) { try { - final nl.cwi.monetdb.jdbc.types.URL url_obj = new nl.cwi.monetdb.jdbc.types.URL(); + final org.monetdb.jdbc.types.URL url_obj = new org.monetdb.jdbc.types.URL(); url_obj.fromString(val); return url_obj; } catch (Exception exc) { @@ -1966,7 +1966,7 @@ public class MonetResultSet case 4: if ("inet".equals(MonetDBType)) { try { - final nl.cwi.monetdb.jdbc.types.INET inet_obj = new nl.cwi.monetdb.jdbc.types.INET(); + final org.monetdb.jdbc.types.INET inet_obj = new org.monetdb.jdbc.types.INET(); inet_obj.fromString(val); return inet_obj; } catch (Exception exc) {
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetSavepoint.java rename to src/main/java/org/monetdb/jdbc/MonetSavepoint.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetSavepoint.java +++ b/src/main/java/org/monetdb/jdbc/MonetSavepoint.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.sql.SQLException; import java.util.concurrent.atomic.AtomicInteger;
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java rename to src/main/java/org/monetdb/jdbc/MonetStatement.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetStatement.java @@ -6,9 +6,9 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; -import nl.cwi.monetdb.mcl.net.MapiSocket; +import org.monetdb.mcl.net.MapiSocket; import java.sql.BatchUpdateException; import java.sql.Connection; import java.sql.Statement;
rename from src/main/java/nl/cwi/monetdb/jdbc/MonetWrapper.java rename to src/main/java/org/monetdb/jdbc/MonetWrapper.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetWrapper.java +++ b/src/main/java/org/monetdb/jdbc/MonetWrapper.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc; +package org.monetdb.jdbc; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException;
copy from src/main/java/nl/cwi/monetdb/jdbc/types/INET.java copy to src/main/java/org/monetdb/jdbc/types/INET.java --- a/src/main/java/nl/cwi/monetdb/jdbc/types/INET.java +++ b/src/main/java/org/monetdb/jdbc/types/INET.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc.types; +package org.monetdb.jdbc.types; import java.net.InetAddress; import java.sql.SQLDataException; @@ -26,7 +26,7 @@ import java.sql.SQLException; * This is probably meaningful only and only if the netmask is 32. * The getNetmaskBits() method can be used to retrieve the subnet bits. */ -public final class INET implements java.sql.SQLData { +public class INET implements java.sql.SQLData { /* cannot (yet) be final as nl.cwi.monetdb.jdbc.types.INET extends this class */ private String inet; @Override
copy from src/main/java/nl/cwi/monetdb/jdbc/types/URL.java copy to src/main/java/org/monetdb/jdbc/types/URL.java --- a/src/main/java/nl/cwi/monetdb/jdbc/types/URL.java +++ b/src/main/java/org/monetdb/jdbc/types/URL.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.jdbc.types; +package org.monetdb.jdbc.types; import java.sql.SQLException; @@ -14,7 +14,7 @@ import java.sql.SQLException; * The URL class represents the URL datatype in MonetDB. * It represents an URL, that is, a well-formed string conforming to RFC2396. */ -public final class URL implements java.sql.SQLData { +public class URL implements java.sql.SQLData { /* cannot (yet) be final as nl.cwi.monetdb.jdbc.types.URL extends this class */ private String url; @Override
rename from src/main/java/nl/cwi/monetdb/mcl/MCLException.java rename to src/main/java/org/monetdb/mcl/MCLException.java --- a/src/main/java/nl/cwi/monetdb/mcl/MCLException.java +++ b/src/main/java/org/monetdb/mcl/MCLException.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl; +package org.monetdb.mcl; /** * A general purpose Exception class for MCL related problems. This
rename from src/main/java/nl/cwi/monetdb/mcl/io/BufferedMCLReader.java rename to src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java --- a/src/main/java/nl/cwi/monetdb/mcl/io/BufferedMCLReader.java +++ b/src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.io; +package org.monetdb.mcl.io; import java.io.BufferedReader; import java.io.IOException; @@ -31,14 +31,14 @@ import java.io.UnsupportedEncodingExcept * data from the stream in a linewise fashion, whereby each line is * identified as a certain type, consumers can easily decide how to * parse each retrieved line. The line parsers from - * nl.cwi.monetdb.mcl.parser are well suited to work with the lines + * org.monetdb.mcl.parser are well suited to work with the lines * outputted by the BufferedMCLReader. * This class is client-oriented, as it doesn't take into account the * messages as the server receives them. * * @author Fabian Groffen - * @see nl.cwi.monetdb.mcl.net.MapiSocket - * @see nl.cwi.monetdb.mcl.io.BufferedMCLWriter + * @see org.monetdb.mcl.net.MapiSocket + * @see org.monetdb.mcl.io.BufferedMCLWriter */ public final class BufferedMCLReader extends BufferedReader { /** "there is currently no line", or the the type is unknown is represented by UNKNOWN */ @@ -112,7 +112,7 @@ public final class BufferedMCLReader ext } return r; } - + /** * Sets the linetype to the type of the string given. If the string * is null, lineType is set to UNKNOWN.
rename from src/main/java/nl/cwi/monetdb/mcl/io/BufferedMCLWriter.java rename to src/main/java/org/monetdb/mcl/io/BufferedMCLWriter.java --- a/src/main/java/nl/cwi/monetdb/mcl/io/BufferedMCLWriter.java +++ b/src/main/java/org/monetdb/mcl/io/BufferedMCLWriter.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.io; +package org.monetdb.mcl.io; import java.io.BufferedWriter; import java.io.IOException; @@ -32,8 +32,8 @@ import java.io.Writer; * class client-oriented when a reader is registered. * * @author Fabian Groffen - * @see nl.cwi.monetdb.mcl.net.MapiSocket - * @see nl.cwi.monetdb.mcl.io.BufferedMCLReader + * @see org.monetdb.mcl.net.MapiSocket + * @see org.monetdb.mcl.io.BufferedMCLReader */ public final class BufferedMCLWriter extends BufferedWriter { private BufferedMCLReader reader;
copy from src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java copy to src/main/java/org/monetdb/mcl/net/MapiSocket.java --- a/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java +++ b/src/main/java/org/monetdb/mcl/net/MapiSocket.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.net; +package org.monetdb.mcl.net; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -28,10 +28,10 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import nl.cwi.monetdb.mcl.MCLException; -import nl.cwi.monetdb.mcl.io.BufferedMCLReader; -import nl.cwi.monetdb.mcl.io.BufferedMCLWriter; -import nl.cwi.monetdb.mcl.parser.MCLParseException; +import org.monetdb.mcl.MCLException; +import org.monetdb.mcl.io.BufferedMCLReader; +import org.monetdb.mcl.io.BufferedMCLWriter; +import org.monetdb.mcl.parser.MCLParseException; /** * A Socket for communicating with the MonetDB database in MAPI block @@ -80,10 +80,10 @@ import nl.cwi.monetdb.mcl.parser.MCLPars * * @author Fabian Groffen * @version 4.1 - * @see nl.cwi.monetdb.mcl.io.BufferedMCLReader - * @see nl.cwi.monetdb.mcl.io.BufferedMCLWriter + * @see org.monetdb.mcl.io.BufferedMCLReader + * @see org.monetdb.mcl.io.BufferedMCLWriter */ -public final class MapiSocket { +public class MapiSocket { /* cannot (yet) be final as nl.cwi.monetdb.mcl.net.MapiSocket extends this class */ /** The TCP Socket to mserver */ private Socket con; /** The TCP Socket timeout in milliseconds. Default is 0 meaning the timeout is disabled (i.e., timeout of infinity) */
rename from src/main/java/nl/cwi/monetdb/mcl/parser/HeaderLineParser.java rename to src/main/java/org/monetdb/mcl/parser/HeaderLineParser.java --- a/src/main/java/nl/cwi/monetdb/mcl/parser/HeaderLineParser.java +++ b/src/main/java/org/monetdb/mcl/parser/HeaderLineParser.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.parser; +package org.monetdb.mcl.parser; /**
rename from src/main/java/nl/cwi/monetdb/mcl/parser/MCLParseException.java rename to src/main/java/org/monetdb/mcl/parser/MCLParseException.java --- a/src/main/java/nl/cwi/monetdb/mcl/parser/MCLParseException.java +++ b/src/main/java/org/monetdb/mcl/parser/MCLParseException.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.parser; +package org.monetdb.mcl.parser; /** * When an MCLParseException is thrown, the MCL protocol is violated by
rename from src/main/java/nl/cwi/monetdb/mcl/parser/MCLParser.java rename to src/main/java/org/monetdb/mcl/parser/MCLParser.java --- a/src/main/java/nl/cwi/monetdb/mcl/parser/MCLParser.java +++ b/src/main/java/org/monetdb/mcl/parser/MCLParser.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.parser; +package org.monetdb.mcl.parser; /** @@ -15,7 +15,7 @@ package nl.cwi.monetdb.mcl.parser; * the same type of work. While this is a very unnatural solution in * the Java language, it prevents many object creations on a low level * of the protocol. This favours performance. - * + * * A typical parser has a method parse() which takes a String, and the * methods hasNext() and next() to retrieve the values that were * extracted by the parser. Parser specific methods may be available to
rename from src/main/java/nl/cwi/monetdb/mcl/parser/StartOfHeaderParser.java rename to src/main/java/org/monetdb/mcl/parser/StartOfHeaderParser.java --- a/src/main/java/nl/cwi/monetdb/mcl/parser/StartOfHeaderParser.java +++ b/src/main/java/org/monetdb/mcl/parser/StartOfHeaderParser.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.parser; +package org.monetdb.mcl.parser; import java.nio.CharBuffer;
rename from src/main/java/nl/cwi/monetdb/mcl/parser/TupleLineParser.java rename to src/main/java/org/monetdb/mcl/parser/TupleLineParser.java --- a/src/main/java/nl/cwi/monetdb/mcl/parser/TupleLineParser.java +++ b/src/main/java/org/monetdb/mcl/parser/TupleLineParser.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.mcl.parser; +package org.monetdb.mcl.parser; /** * The TupleLineParser extracts the values from a given tuple.
rename from src/main/java/nl/cwi/monetdb/merovingian/Control.java rename to src/main/java/org/monetdb/merovingian/Control.java --- a/src/main/java/nl/cwi/monetdb/merovingian/Control.java +++ b/src/main/java/org/monetdb/merovingian/Control.java @@ -6,12 +6,12 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.merovingian; +package org.monetdb.merovingian; -import nl.cwi.monetdb.mcl.net.MapiSocket; -import nl.cwi.monetdb.mcl.io.*; -import nl.cwi.monetdb.mcl.MCLException; -import nl.cwi.monetdb.mcl.parser.MCLParseException; +import org.monetdb.mcl.net.MapiSocket; +import org.monetdb.mcl.io.*; +import org.monetdb.mcl.MCLException; +import org.monetdb.mcl.parser.MCLParseException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -27,7 +27,7 @@ import java.util.Properties; /** * A Control class to perform operations on a remote merovingian * instance, using the TCP control protocol. - * + * * This class implements the protocol specific bits to perform all * possible actions against a merovingian server that has remote control * facilities enabled. @@ -109,7 +109,7 @@ public class Control { return(Long.toString(h)); } - + final static private String RESPONSE_OK = "OK"; private List<String> sendCommand( @@ -133,7 +133,7 @@ public class Control { throw new MerovingianException(e.getMessage()); } catch (AssertionError e) { // mcl panics ms.close(); - + // Try old protocol instead Socket s; PrintStream out; @@ -238,8 +238,8 @@ public class Control { } public void stop(String database) - throws MerovingianException, IOException - { + throws MerovingianException, IOException + { sendCommand(database, "stop", false); } @@ -342,10 +342,10 @@ public class Control { throw new MerovingianException("communication error"); return new SabaothDB(response.get(0)); } - + /** - * Test whether a specific database exists. - * + * Test whether a specific database exists. + * * @param database name of database * @return true, iff database already exists. * @throws MerovingianException if performing the command failed at
rename from src/main/java/nl/cwi/monetdb/merovingian/MerovingianException.java rename to src/main/java/org/monetdb/merovingian/MerovingianException.java --- a/src/main/java/nl/cwi/monetdb/merovingian/MerovingianException.java +++ b/src/main/java/org/monetdb/merovingian/MerovingianException.java @@ -6,11 +6,11 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.merovingian; +package org.monetdb.merovingian; /** * An Exception raised when monetdbd specific problems occur. - * + * * This class is a shallow wrapper around Exception to identify an * exception as one originating from the monetdbd instance being * communicated with, instead of a locally generated one.
rename from src/main/java/nl/cwi/monetdb/merovingian/SabaothDB.java rename to src/main/java/org/monetdb/merovingian/SabaothDB.java --- a/src/main/java/nl/cwi/monetdb/merovingian/SabaothDB.java +++ b/src/main/java/org/monetdb/merovingian/SabaothDB.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.merovingian; +package org.monetdb.merovingian; import java.util.Date;
rename from src/main/java/nl/cwi/monetdb/util/CmdLineOpts.java rename to src/main/java/org/monetdb/util/CmdLineOpts.java --- a/src/main/java/nl/cwi/monetdb/util/CmdLineOpts.java +++ b/src/main/java/org/monetdb/util/CmdLineOpts.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; import java.util.ArrayList; import java.util.HashMap;
rename from src/main/java/nl/cwi/monetdb/util/Exporter.java rename to src/main/java/org/monetdb/util/Exporter.java --- a/src/main/java/nl/cwi/monetdb/util/Exporter.java +++ b/src/main/java/org/monetdb/util/Exporter.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; import java.io.PrintWriter; import java.sql.ResultSet;
rename from src/main/java/nl/cwi/monetdb/util/Extract.java rename to src/main/java/org/monetdb/util/Extract.java --- a/src/main/java/nl/cwi/monetdb/util/Extract.java +++ b/src/main/java/org/monetdb/util/Extract.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; import java.io.BufferedReader; import java.io.FileNotFoundException;
rename from src/main/java/nl/cwi/monetdb/util/MDBvalidator.java rename to src/main/java/org/monetdb/util/MDBvalidator.java --- a/src/main/java/nl/cwi/monetdb/util/MDBvalidator.java +++ b/src/main/java/org/monetdb/util/MDBvalidator.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -998,6 +998,7 @@ public final class MDBvalidator { {"queue WHERE tag > cast(0 as oid) AND ", "tag", "tag", "queue", null}, {"queue WHERE tag > cast(0 as oid) AND ", "tag", "cast(tag as oid)", "queue", null}, {"queue", "tag", "cast(tag as oid)", "queue", null}, +// not a fk: {"queue", "\"username\"", "name", "users", null}, // as queue contains a historical list, the user may have been removed in the meantime, so not a real persistent fk {"sessions", "\"username\"", "name", "users", null}, {"statistics", "column_id", "id", "(SELECT id FROM sys._columns UNION ALL SELECT id FROM tmp._columns) as c", null}, {"statistics", "type", "sqlname", "types", null},
rename from src/main/java/nl/cwi/monetdb/util/OptionsException.java rename to src/main/java/org/monetdb/util/OptionsException.java --- a/src/main/java/nl/cwi/monetdb/util/OptionsException.java +++ b/src/main/java/org/monetdb/util/OptionsException.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; public final class OptionsException extends Exception { static final long serialVersionUID = 42L; // needed to prevent: warning: [serial] serializable class OptionsException has no definition of serialVersionUID
rename from src/main/java/nl/cwi/monetdb/util/SQLExporter.java rename to src/main/java/org/monetdb/util/SQLExporter.java --- a/src/main/java/nl/cwi/monetdb/util/SQLExporter.java +++ b/src/main/java/org/monetdb/util/SQLExporter.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; import java.sql.DatabaseMetaData; import java.sql.ResultSet;
rename from src/main/java/nl/cwi/monetdb/util/SQLRestore.java rename to src/main/java/org/monetdb/util/SQLRestore.java --- a/src/main/java/nl/cwi/monetdb/util/SQLRestore.java +++ b/src/main/java/org/monetdb/util/SQLRestore.java @@ -6,16 +6,16 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; -import nl.cwi.monetdb.mcl.io.BufferedMCLReader; -import nl.cwi.monetdb.mcl.io.BufferedMCLWriter; -import nl.cwi.monetdb.mcl.net.MapiSocket; +import org.monetdb.mcl.io.BufferedMCLReader; +import org.monetdb.mcl.io.BufferedMCLWriter; +import org.monetdb.mcl.net.MapiSocket; /** * Use this class to restore an SQL dump file. @@ -142,9 +142,9 @@ public final class SQLRestore { throw new IOException(srr.getErrorMessage()); } } - } catch (nl.cwi.monetdb.mcl.MCLException e) { + } catch (org.monetdb.mcl.MCLException e) { throw new IOException(e.getMessage()); - } catch (nl.cwi.monetdb.mcl.parser.MCLParseException e) { + } catch (org.monetdb.mcl.parser.MCLParseException e) { throw new IOException(e.getMessage()); } finally { ms.close();
rename from src/main/java/nl/cwi/monetdb/util/XMLExporter.java rename to src/main/java/org/monetdb/util/XMLExporter.java --- a/src/main/java/nl/cwi/monetdb/util/XMLExporter.java +++ b/src/main/java/org/monetdb/util/XMLExporter.java @@ -6,7 +6,7 @@ * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. */ -package nl.cwi.monetdb.util; +package org.monetdb.util; import java.sql.ResultSet; import java.sql.SQLException;
--- a/tests/BugConcurrent_clients_SF_1504657.java +++ b/tests/BugConcurrent_clients_SF_1504657.java @@ -13,7 +13,6 @@ public class BugConcurrent_clients_SF_15 Connection con1 = null, con2 = null, con3 = null; Statement stmt1 = null, stmt2 = null, stmt3 = null; ResultSet rs1 = null, rs2= null, rs3 = null; - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers con1 = DriverManager.getConnection(args[0]); con2 = DriverManager.getConnection(args[0]); con3 = DriverManager.getConnection(args[0]);
--- a/tests/BugConcurrent_sequences.java +++ b/tests/BugConcurrent_sequences.java @@ -13,7 +13,6 @@ public class BugConcurrent_sequences { Connection con1 = null, con2 = null; Statement stmt1 = null, stmt2 = null; ResultSet rs1 = null, rs2 = null; - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers con1 = DriverManager.getConnection(args[0]); con2 = DriverManager.getConnection(args[0]); stmt1 = con1.createStatement();
--- a/tests/BugDatabaseMetaData_Bug_3356.java +++ b/tests/BugDatabaseMetaData_Bug_3356.java @@ -10,7 +10,6 @@ import java.sql.*; public class BugDatabaseMetaData_Bug_3356 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); DatabaseMetaData dbmd = con.getMetaData(); ResultSet rs = dbmd.getColumns("", "sys", "_tables", "id");
--- a/tests/BugDecimalRound_Bug_3561.java +++ b/tests/BugDecimalRound_Bug_3561.java @@ -11,7 +11,6 @@ import java.math.BigDecimal; public class BugDecimalRound_Bug_3561 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt1 = con.createStatement();
--- a/tests/BugExecuteUpdate_Bug_3350.java +++ b/tests/BugExecuteUpdate_Bug_3350.java @@ -10,7 +10,6 @@ import java.sql.*; public class BugExecuteUpdate_Bug_3350 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers final Connection con = DriverManager.getConnection(args[0]); con.setAutoCommit(false); // disable auto commit, so we can roll back the transaction
--- a/tests/BugResultSetMetaData_Bug_6183.java +++ b/tests/BugResultSetMetaData_Bug_6183.java @@ -14,7 +14,6 @@ public class BugResultSetMetaData_Bug_61 , "\"my ,tab_comma\"", "\"my, comma_tab\"", "\"my\"\"double_doublequote\"", "\"Abc\"", "\" \"", "\"123\"" }; public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = null;
--- a/tests/BugSetQueryTimeout_Bug_3357.java +++ b/tests/BugSetQueryTimeout_Bug_3357.java @@ -10,7 +10,6 @@ import java.sql.*; public class BugSetQueryTimeout_Bug_3357 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement st = con.createStatement(); try {
--- a/tests/Bug_Connect_as_voc_getMetaData_Failure_Bug_6388.java +++ b/tests/Bug_Connect_as_voc_getMetaData_Failure_Bug_6388.java @@ -14,7 +14,6 @@ public class Bug_Connect_as_voc_getMetaD Connection con1 = null; Statement stmt1 = null; - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers con1 = DriverManager.getConnection(args[0]); stmt1 = con1.createStatement();
--- a/tests/Bug_IsValid_Timeout_Bug_6782.java +++ b/tests/Bug_IsValid_Timeout_Bug_6782.java @@ -10,7 +10,6 @@ import java.sql.*; public class Bug_IsValid_Timeout_Bug_6782 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement st = null;
--- a/tests/Bug_PrepStmtSetObject_CLOB_6349.java +++ b/tests/Bug_PrepStmtSetObject_CLOB_6349.java @@ -10,7 +10,6 @@ import java.sql.*; public class Bug_PrepStmtSetObject_CLOB_6349 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt = null;
--- a/tests/Bug_PrepStmtSetString_6382.java +++ b/tests/Bug_PrepStmtSetString_6382.java @@ -7,12 +7,11 @@ */ import java.sql.*; -import nl.cwi.monetdb.jdbc.types.INET; -import nl.cwi.monetdb.jdbc.types.URL; +import org.monetdb.jdbc.types.INET; +import org.monetdb.jdbc.types.URL; public class Bug_PrepStmtSetString_6382 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = null; Statement stmt = null; PreparedStatement pstmt = null;
--- a/tests/Bug_PrepStmt_With_Errors_Jira292.java +++ b/tests/Bug_PrepStmt_With_Errors_Jira292.java @@ -10,7 +10,6 @@ import java.sql.*; public class Bug_PrepStmt_With_Errors_Jira292 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = null; Statement stmt = null; PreparedStatement pstmt = null;
--- a/tests/SQLcopyinto.java +++ b/tests/SQLcopyinto.java @@ -9,7 +9,9 @@ import java.sql.*; import java.io.*; import java.util.*; -import nl.cwi.monetdb.mcl.net.MapiSocket; +import org.monetdb.mcl.net.MapiSocket; +import org.monetdb.mcl.io.BufferedMCLReader; +import org.monetdb.mcl.io.BufferedMCLWriter; /** * This program demonstrates how the MonetDB JDBC driver can facilitate @@ -97,8 +99,8 @@ public class SQLcopyinto { } System.out.println("Connected to MonetDB server via MapiSocket"); - nl.cwi.monetdb.mcl.io.BufferedMCLReader mclIn = server.getReader(); - nl.cwi.monetdb.mcl.io.BufferedMCLWriter mclOut = server.getWriter(); + BufferedMCLReader mclIn = server.getReader(); + BufferedMCLWriter mclOut = server.getWriter(); String error = mclIn.waitForPrompt(); if (error != null)
--- a/tests/Test_Cautocommit.java +++ b/tests/Test_Cautocommit.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_Cautocommit { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con1 = DriverManager.getConnection(args[0]); Connection con2 = DriverManager.getConnection(args[0]); Statement stmt1 = con1.createStatement();
--- a/tests/Test_Cforkbomb.java +++ b/tests/Test_Cforkbomb.java @@ -47,7 +47,6 @@ public class Test_Cforkbomb { public static void main(String[] args) throws Exception { Test_Cforkbomb.args = args; - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers // just DoS the server full throttle :) int i;
--- a/tests/Test_CisValid.java +++ b/tests/Test_CisValid.java @@ -14,7 +14,6 @@ public class Test_CisValid { * The function Connection.isValid() should only return TRUE or FALSE. It * shall never alter the state of this connection */ public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection conn = DriverManager.getConnection(args[0]); Statement stmt = conn.createStatement();
--- a/tests/Test_Clargequery.java +++ b/tests/Test_Clargequery.java @@ -10,11 +10,9 @@ import java.sql.*; public class Test_Clargequery { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con1 = DriverManager.getConnection(args[0]); Statement stmt1 = con1.createStatement(); ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); // >> true: auto commit should be on by default System.out.println("0. true\t" + con1.getAutoCommit());
--- a/tests/Test_Cmanycon.java +++ b/tests/Test_Cmanycon.java @@ -11,7 +11,6 @@ import java.util.*; public class Test_Cmanycon { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers List<Connection> cons = new ArrayList<Connection>(100); // Connections go in here try {
--- a/tests/Test_Creplysize.java +++ b/tests/Test_Creplysize.java @@ -10,11 +10,9 @@ import java.sql.*; public class Test_Creplysize { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con1 = DriverManager.getConnection(args[0]); Statement stmt1 = con1.createStatement(); ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); con1.setAutoCommit(false); // >> true: auto commit should be off by now
--- a/tests/Test_Csavepoints.java +++ b/tests/Test_Csavepoints.java @@ -10,11 +10,9 @@ import java.sql.*; public class Test_Csavepoints { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); // >> true: auto commit should be on by default System.out.println("0. true\t" + con.getAutoCommit());
--- a/tests/Test_Csendthread.java +++ b/tests/Test_Csendthread.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_Csendthread { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers System.out.println("0. active threads: " + Thread.activeCount()); StringBuilder sb = new StringBuilder();
--- a/tests/Test_Ctransaction.java +++ b/tests/Test_Ctransaction.java @@ -10,10 +10,8 @@ import java.sql.*; public class Test_Ctransaction { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con1 = DriverManager.getConnection(args[0]); Statement stmt1 = con1.createStatement(); - //DatabaseMetaData dbmd = con.getMetaData(); // >> true: auto commit should be on by default System.out.println("0. true\t" + con1.getAutoCommit());
--- a/tests/Test_Dobjects.java +++ b/tests/Test_Dobjects.java @@ -27,7 +27,6 @@ public class Test_Dobjects { } public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); DatabaseMetaData dbmd = con.getMetaData(); try {
--- a/tests/Test_FetchSize.java +++ b/tests/Test_FetchSize.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_FetchSize { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM _tables");
--- a/tests/Test_Int128.java +++ b/tests/Test_Int128.java @@ -18,7 +18,6 @@ import java.sql.Statement; /* Test whether we can represent a full-size int128 as JDBC results */ public class Test_Int128 { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); BigInteger bi = new BigInteger( "123456789012345678909876543210987654321");
--- a/tests/Test_PSgeneratedkeys.java +++ b/tests/Test_PSgeneratedkeys.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_PSgeneratedkeys { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); con.setAutoCommit(false); // >> false: auto commit was just switched off
--- a/tests/Test_PSgetObject.java +++ b/tests/Test_PSgetObject.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_PSgetObject { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers final Connection con = DriverManager.getConnection(args[0]); con.setAutoCommit(false); // >> false: auto commit was just switched off
--- a/tests/Test_PSlargeamount.java +++ b/tests/Test_PSlargeamount.java @@ -7,14 +7,12 @@ */ import java.sql.*; -import java.util.*; /* Create a lot of PreparedStatements, to emulate webloads such as those * from Hibernate. */ public class Test_PSlargeamount { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt; @@ -40,6 +38,7 @@ public class Test_PSlargeamount { System.out.println("ABORTING TEST!!!"); } + stmt.close(); con.close(); } }
--- a/tests/Test_PSlargebatchval.java +++ b/tests/Test_PSlargebatchval.java @@ -8,12 +8,10 @@ import java.sql.*; import java.io.StringReader; -import java.util.*; import java.nio.charset.Charset; public class Test_PSlargebatchval { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt;
--- a/tests/Test_PSlargeresponse.java +++ b/tests/Test_PSlargeresponse.java @@ -7,11 +7,9 @@ */ import java.sql.*; -import java.util.*; public class Test_PSlargeresponse { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt;
--- a/tests/Test_PSmanycon.java +++ b/tests/Test_PSmanycon.java @@ -11,7 +11,6 @@ import java.util.*; public class Test_PSmanycon { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers List<PreparedStatement> pss = new ArrayList<PreparedStatement>(100); // PreparedStatements go in here try {
--- a/tests/Test_PSmetadata.java +++ b/tests/Test_PSmetadata.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_PSmetadata { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0] + "&treat_clob_as_varchar=false"); Statement stmt = con.createStatement(); PreparedStatement pstmt;
--- a/tests/Test_PSsomeamount.java +++ b/tests/Test_PSsomeamount.java @@ -7,14 +7,12 @@ */ import java.sql.*; -import java.util.*; /* Create a lot of PreparedStatements, to emulate webloads such as those * from Hibernate. */ public class Test_PSsomeamount { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt; @@ -40,6 +38,7 @@ public class Test_PSsomeamount { System.out.println("ABORTING TEST!!!"); } + stmt.close(); con.close(); } }
--- a/tests/Test_PSsqldata.java +++ b/tests/Test_PSsqldata.java @@ -7,11 +7,11 @@ */ import java.sql.*; -import nl.cwi.monetdb.jdbc.types.*; +import org.monetdb.jdbc.types.INET; +import org.monetdb.jdbc.types.URL; public class Test_PSsqldata { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt;
--- a/tests/Test_PStimedate.java +++ b/tests/Test_PStimedate.java @@ -10,12 +10,10 @@ import java.sql.*; public class Test_PStimedate { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt; ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); con.setAutoCommit(false); // >> false: auto commit was just switched off @@ -23,6 +21,7 @@ public class Test_PStimedate { try { stmt.executeUpdate("CREATE TABLE table_Test_PStimedate (t time, ts timestamp, d date)"); + stmt.close(); } catch (SQLException e) { System.out.println(e); System.out.println("Creation of test table failed! :(");
--- a/tests/Test_PStimezone.java +++ b/tests/Test_PStimezone.java @@ -18,12 +18,10 @@ public class Test_PStimezone { // savings corrections TimeZone.setDefault(TimeZone.getTimeZone("UTC")); - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt; ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); con.setAutoCommit(false); // >> false: auto commit was just switched off @@ -31,6 +29,7 @@ public class Test_PStimezone { try { stmt.executeUpdate("CREATE TABLE table_Test_PStimezone (ts timestamp, tsz timestamp with time zone, t time, tz time with time zone)"); + stmt.close(); } catch (SQLException e) { System.out.println(e); System.out.println("Creation of test table failed! :(");
--- a/tests/Test_PStypes.java +++ b/tests/Test_PStypes.java @@ -10,12 +10,9 @@ import java.sql.*; public class Test_PStypes { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); PreparedStatement pstmt; - //ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); con.setAutoCommit(false); // >> false: auto commit was just switched off @@ -41,6 +38,7 @@ public class Test_PStypes { ); // index is not used, but the original bug had it too stmt.executeUpdate("CREATE INDEX htmid ON htmtest (htmid)"); + stmt.close(); } catch (SQLException e) { System.out.println(e); System.out.println("Creation of test table failed! :(");
--- a/tests/Test_Rbooleans.java +++ b/tests/Test_Rbooleans.java @@ -10,11 +10,9 @@ import java.sql.*; public class Test_Rbooleans { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); con.setAutoCommit(false); // >> false: auto commit should be off now
--- a/tests/Test_Rmetadata.java +++ b/tests/Test_Rmetadata.java @@ -10,12 +10,10 @@ import java.sql.*; public class Test_Rmetadata { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0] + "&treat_clob_as_varchar=false"); Statement stmt = con.createStatement(); ResultSet rs = null; ResultSetMetaData rsmd = null; - //DatabaseMetaData dbmd = con.getMetaData(); con.setAutoCommit(false); // >> false: auto commit should be off now
--- a/tests/Test_Rpositioning.java +++ b/tests/Test_Rpositioning.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_Rpositioning { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); DatabaseMetaData dbmd = con.getMetaData();
--- a/tests/Test_Rsqldata.java +++ b/tests/Test_Rsqldata.java @@ -7,11 +7,11 @@ */ import java.sql.*; -import nl.cwi.monetdb.jdbc.types.*; +import org.monetdb.jdbc.types.INET; +import org.monetdb.jdbc.types.URL; public class Test_Rsqldata { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = null;
--- a/tests/Test_Rtimedate.java +++ b/tests/Test_Rtimedate.java @@ -10,7 +10,6 @@ import java.sql.*; public class Test_Rtimedate { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = null;
--- a/tests/Test_Sbatching.java +++ b/tests/Test_Sbatching.java @@ -10,11 +10,9 @@ import java.sql.*; public class Test_Sbatching { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); // >> true: auto commit should be on by default System.out.println("0. true\t" + con.getAutoCommit());
--- a/tests/Test_Smoreresults.java +++ b/tests/Test_Smoreresults.java @@ -10,11 +10,9 @@ import java.sql.*; public class Test_Smoreresults { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers Connection con = DriverManager.getConnection(args[0]); Statement stmt = con.createStatement(); ResultSet rs = null; - //DatabaseMetaData dbmd = con.getMetaData(); // >> true: auto commit should be on by default System.out.println("0. true\t" + con.getAutoCommit());
--- a/tests/Test_Wrapper.java +++ b/tests/Test_Wrapper.java @@ -10,13 +10,12 @@ import java.sql.*; public class Test_Wrapper { public static void main(String[] args) throws Exception { - // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers final Connection con = DriverManager.getConnection(args[0]); System.out.println("Connected. Auto commit is: " + con.getAutoCommit()); try { final String jdbc_pkg = "java.sql."; - final String monetdb_jdbc_pkg = "nl.cwi.monetdb.jdbc."; + final String monetdb_jdbc_pkg = "org.monetdb.jdbc."; checkIsWrapperFor("Connection", con, jdbc_pkg, "Connection"); checkIsWrapperFor("Connection", con, monetdb_jdbc_pkg, "MonetConnection");