Changeset: 96057ee68017 for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=96057ee68017 Added Files: tests/SQLcopyinto.java Removed Files: example/SQLcopyinto.java Modified Files: ChangeLog src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java tests/BugSetQueryTimeout_Bug_3357.java tests/build.xml Branch: embedded Log Message:
Merge with default. diffs (truncated from 781 to 300 lines): diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,39 +1,12 @@ # ChangeLog file for monetdb-java # This file is updated with Maddlog -* Wed May 23 2018 Sjoerd Mullender <[email protected]> -- Compiled and released new jars: monetdb-jdbc-2.28.jar, monetdb-mcl-1.17.jar - and updated jdbcclient.jar - -* Thu Apr 26 2018 Martin van Dinther <[email protected]> -- Corrected and extended output of DatabaseMetaData methods - getTimeDateFunctions() and getSystemFunctions(). The Date/Time functions - (curdate, current_date, current_time, current_timestamp, curtime, - local_timezone, localtime, localtimestamp) were returned by - getSystemFunctions() but are now returned by getTimeDateFunctions(). - getTimeDateFunctions() now also lists functions: date_to_str, extract, now, - str_to_date, str_to_time, str_to_timestamp, time_to_str and timestamp_to_str. -- Improved DatabaseMetaData methods getTablePrivileges() and - getColumnPrivileges() by returning also any combination of privileges - for the table or column in the PRIVILEGE result column. Previously only - single privileges (SELECT or UPDATE or INSERT or DELETE or EXECUTE or - GRANT) would be returned. +* Thu Sep 20 2018 Martin van Dinther <[email protected]> +- Improved example program SQLcopyinto.java and moved it to tests directory + for automatic testing. -* Thu Apr 19 2018 Martin van Dinther <[email protected]> -- Corrected method DatabaseMetaData.getFunctions() for result column - FUNCTION_TYPE. It used to return DatabaseMetaData.functionResultUnknown - value for Analytic (functions.type 6) and Loader function (functions type 7). - It now returns DatabaseMetaData.functionNoTable for Analytic functions and - DatabaseMetaData.functionReturnsTable for Loader functions. -- DatabaseMetaData methods getTables(), getColumns(), getProcedures() and - getFunctions() now return the comment in the REMARKS result column when a - comment has been set for the table / view / column / procedure / function - via the SQL command COMMENT ON <db-object type> <qname> IS 'comment-text'. +* Thu Jun 28 2018 Martin van Dinther <[email protected]> +- Corrected return values of DatabaseMetaData methods + allTablesAreSelectable() and allProceduresAreCallable(). + They used to return true but now return false. -* Thu Dec 14 2017 Martin van Dinther <[email protected]> -- Fixed a problem with retrieving Dates and Timestamps which contained a - year value less than 1000. It would throw an SQLDataException with message: - Could not convert value to a Date. Expected JDBC date escape format - yyyy-[m]m-[d]d. - See also: https://www.monetdb.org/bugzilla/show_bug.cgi?id=6468 - diff --git a/example/SQLcopyinto.java b/example/SQLcopyinto.java deleted file mode 100644 --- a/example/SQLcopyinto.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 - 2018 MonetDB B.V. - */ - -import java.sql.*; -import java.io.*; -import java.util.*; - -import nl.cwi.monetdb.mcl.connection.mapi.MapiConnection; -import nl.cwi.monetdb.mcl.protocol.AbstractProtocol; - -/** - * This example demonstrates how the MonetDB JDBC driver can facilitate - * in performing COPY INTO sequences. This is mainly meant to show how - * a quick load can be performed from Java. - * - * @author Fabian Groffen - */ - -public class SQLcopyinto { - public static void main(String[] args) throws Exception { - // request a connection suitable for Monet from the driver manager - // note that the database specifier is currently not implemented, for - // Monet itself can't access multiple databases. - // turn on debugging - Connection con = DriverManager.getConnection("jdbc:monetdb://localhost/database", "monetdb", "monetdb"); - - // get a statement to execute on - Statement stmt = con.createStatement(); - - String query = "CREATE TABLE example (id int, val varchar(24))"; - try { - stmt.execute(query); - } catch (SQLException e) { - System.out.println(query + ": " + e.getMessage()); - System.exit(1); - } - - // now create a connection manually to perform a load, this can - // of course also be done simultaneously with the JDBC - // connection being kept connected - - MapiConnection server = new MapiConnection(null, null, "sql", false, true,"localhost", 50000, "database"); - - try { - List warning = server.connect("monetdb", "monetdb"); - if (warning != null) { - for (Object aWarning : warning) { - System.out.println(aWarning.toString()); - } - } - AbstractProtocol oldmMapiProtocol = server.getProtocol(); - - oldmMapiProtocol.waitUntilPrompt(); - String error = oldmMapiProtocol.getRemainingStringLine(0); - if (error != null) - throw new Exception(error); - - query = "COPY INTO example FROM STDIN USING DELIMITERS ',','\\n';"; - // the leading 's' is essential, since it is a protocol - // marker that should not be omitted, likewise the - // trailing semicolon - oldmMapiProtocol.writeNextQuery("s", query, "\n"); - - for (int i = 0; i < 100; i++) { - oldmMapiProtocol.writeNextQuery(null, "" + i + ",val_" + i, "\n"); - } - oldmMapiProtocol.waitUntilPrompt(); - error = oldmMapiProtocol.getRemainingStringLine(0); - if (error != null) - throw new Exception(error); - // disconnect from server - server.close(); - } catch (IOException e) { - System.err.println("unable to connect: " + e.getMessage()); - System.exit(-1); - } catch (Exception e) { - System.err.println(e.getMessage()); - System.exit(-1); - } - - query = "SELECT COUNT(*) FROM example"; - ResultSet rs = null; - try { - rs = stmt.executeQuery(query); - } catch (SQLException e) { - System.out.println(query + ": " + e.getMessage()); - System.exit(1); - } - if (rs != null && rs.next()) - System.out.println(rs.getString(1)); - - // free resources, close the statement - stmt.close(); - // close the connection with the database - con.close(); - - } -} diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -178,6 +178,8 @@ public abstract class MonetConnection ex private boolean queriedCommentsTable = false; private boolean hasCommentsTable = false; + /** The last set query timeout on the server as used by Statement and PreparedStatement (and CallableStatement in future) */ + protected int lastSetQueryTimeout = 0; // 0 means no timeout, which is the default on the server /** * Gets the initial value for the StringBuilder size. @@ -1026,7 +1028,8 @@ public abstract class MonetConnection ex */ @Override public String toString() { - return "MonetDB Connection (" + this.getJDBCURL() + ") " + (closed ? "disconnected" : "connected"); + return "MonetDB Connection (" + getJDBCURL() + ") " + + (closed ? "disconnected" : "connected"); } /** diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java --- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @@ -107,25 +107,27 @@ public class MonetDatabaseMetaData exten } /** - * Can all the procedures returned by getProcedures be called - * by the current user? + * Retrieves whether the current user can call all the procedures + * returned by the method getProcedures. * - * @return true if so + * @return false because we currently return all procedures from sys.functions + * and do not filter on EXECUTE privilege or procedure ownership. */ @Override public boolean allProceduresAreCallable() { - return true; + return false; } /** - * Can all the tables returned by getTable be SELECTed by - * the current user? + * Retrieves whether the current user can use all the tables + * returned by the method getTables in a SELECT statement. * - * @return true because we only have one user a.t.m. + * @return false because we currently return all tables from sys.tables + * and do not filter on SELECT privilege or table ownership. */ @Override public boolean allTablesAreSelectable() { - return true; + return false; } /** @@ -1698,6 +1700,7 @@ public class MonetDatabaseMetaData exten * "" retrieves those without a schema; * null means that the schema name should not be used to narrow the search * @param procedureNamePattern - a procedure name pattern; must match the procedure name as it is stored in the database + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @return ResultSet - each row is a procedure description * @throws SQLException if a database access error occurs */ @@ -1807,7 +1810,9 @@ public class MonetDatabaseMetaData exten * "" retrieves those without a schema; * null means that the schema name should not be used to narrow the search * @param procedureNamePattern - a procedure name pattern; must match the procedure name as it is stored in the database + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @param columnNamePattern - a column name pattern; must match the column name as it is stored in the database + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @return ResultSet - each row describes a stored procedure parameter or column * @throws SQLException if a database-access error occurs * @see #getSearchStringEscape @@ -1877,7 +1882,7 @@ public class MonetDatabaseMetaData exten /** * Returns a SQL match part string where depending on the input value we - * compose an exact match (use =) or match with wildcards (use LIKE) + * compose an exact match (use =) or match with wildcards (use LIKE) or IS NULL * * @param in the string to match * @return the SQL match part string @@ -1941,6 +1946,7 @@ public class MonetDatabaseMetaData exten * null means that the schema name should not be used to narrow the search * @param tableNamePattern - a table name pattern; must match the table name as it is stored in the database * For all tables this should be "%" + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @param types - a list of table types, which must be from the list of table types returned * from getTableTypes(),to include; null returns all types * @return ResultSet - each row is a table description @@ -2199,7 +2205,9 @@ public class MonetDatabaseMetaData exten * null means that the schema name should not be used to narrow the search * @param tableNamePattern - a table name pattern; must match the table name as it is stored in the database * For all tables this should be "%" + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @param columnNamePattern - a column name pattern; must match the column name as it is stored in the database + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @return ResultSet - each row is a column description * @throws SQLException if a database error occurs * @see #getSearchStringEscape @@ -2295,7 +2303,9 @@ public class MonetDatabaseMetaData exten * @param catalog a catalog name; "" retrieves those without a catalog * @param schemaPattern a schema name; "" retrieves those without a schema * @param tableNamePattern a table name + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @param columnNamePattern a column name pattern + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @return ResultSet each row is a column privilege description * @see #getSearchStringEscape * @throws SQLException if a database error occurs @@ -2394,6 +2404,7 @@ public class MonetDatabaseMetaData exten * @param catalog a catalog name; "" retrieves those without a catalog * @param schemaPattern a schema name pattern; "" retrieves those without a schema * @param tableNamePattern a table name pattern + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @return ResultSet each row is a table privilege description * @see #getSearchStringEscape * @throws SQLException if a database error occurs @@ -2491,6 +2502,7 @@ public class MonetDatabaseMetaData exten * @param catalog a catalog name; "" retrieves those without a catalog * @param schema a schema name; "" retrieves those without a schema * @param table a table name + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @param scope the scope of interest; use same values as SCOPE * @param nullable include columns that are nullable? * @return ResultSet each row is a column description @@ -2577,6 +2589,7 @@ public class MonetDatabaseMetaData exten * @param catalog a catalog name; "" retrieves those without a catalog * @param schema a schema name; "" retrieves those without a schema * @param table a table name + * Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated). * @return ResultSet each row is a column description * @throws SQLException if a database error occurs */ @@ -2617,9 +2630,9 @@ public class MonetDatabaseMetaData exten * </OL> _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
