Changeset: 51e886d7f3b4 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=51e886d7f3b4
Modified Files:
        ChangeLog
        example/MJDBCTest.java
        example/PreparedExample.java
        example/SQLImport.java
        example/SQLcopyinto.java
        release.txt
        src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
        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/MonetPreparedStatement.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
        src/main/java/nl/cwi/monetdb/mcl/responses/ResultSetResponse.java
Branch: embedded
Log Message:

Merge with default


diffs (truncated from 2241 to 300 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,61 +1,28 @@
 # ChangeLog file for monetdb-java
 # This file is updated with Maddlog
 
-* Mon Oct 23 2017 Sjoerd Mullender <sjo...@acm.org>
-- Compiled and released new jars: monetdb-jdbc-2.27.jar, monetdb-mcl-1.16.jar
-  and updated jdbcclient.jar
-
-* Thu Oct  5 2017 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
-- Corrected method Connection.prepareCall(). It used to return null.
-  Now it throws an SQLFeatureNotSupportedException to comply with the
-  JDBC specification.
+* Thu Apr 26 2018 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- 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 28 2017 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
-- Added possibility to let the JDBC driver return columnType value
-  Types.VARCHAR instead of Types.CLOB in case the result column of a
-  ResultSet or parameter in a PreparedStatement is of data type 'clob'.
-  To enable this behavior provide it as JDBC connection URL property:
-     treat_clob_as_varchar=true
-  For example: jdbc:monetdb://localhost:50000/demo?treat_clob_as_varchar=true
-  See also:
-  https://www.monetdb.org/Documentation/Manuals/SQLreference/Programming/JDBC
-  This custom clob mapping informs generic JDBC programs to fetch clob
-  column values via method ResultSet.getString() instead of getClob()
-  and Clob.getCharacterStream() and next fetching from the stream.
-  As MonetDB server MAPI communication protocol does not support
-  streaming of parts of a CLOB value, the current implementation is to
-  send over the whole CLOB value as a string. Therefore there is no
-  performance gain when fetching those Clob values via getClob() and
-  getCharacterStream(). In fact it creates a lot of overhead (additional
-  objects and method calls) and triples the amount of needed Java Heap memory
-  for each Clob value!
-  With this connection property set, you can reduce this overhead when
-  working with clob column data from generic JDBC programs.
+* Thu Apr 19 2018 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- 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 Sep  7 2017 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
-- Implemented PreparedStatement methods setNCharacterStream(int, Reader)
-  and setNCharacterStream(int, Reader, long).
-
-* Thu Aug 31 2017 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
-- Corrected PreparedStatement methods setString(int, String)
-  and setObject(int, Object, ...) in case the target parameter
-  data type was json or inet or url or uuid.  See also
-  https://www.monetdb.org/bugzilla/show_bug.cgi?id=6382
-
-* Thu Aug 24 2017 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
-- Implemented PreparedStatement method setURL(int, URL).
-- Implemented PreparedStatement method setNString(int, String).
-- The MonetDB JDBC driver code and jdbcclient program are now compiled
-  without debug info and with optimise flag enabled.
-  The new jar files are now some 20% smaller in size.
-
-* Thu Aug 17 2017 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
-- Implemented ResultSet method getNCharacterStream().
-- In class MonetClob implemented methods getCharacterStream()
-  and getCharacterStream(long pos, long length).  Method
-  getCharacterStream() is called by DBeaver to fetch the Clob value.
-  It used to throw a SQLFeatureNotSupportedException with message:
-   "Operation getCharacterStream() currently not supported". This caused
-  DBeaver to log the exception and show NULL as the value on screen,
-  which is incorrect.  This has been fixed.
-
diff --git a/example/MJDBCTest.java b/example/MJDBCTest.java
--- a/example/MJDBCTest.java
+++ b/example/MJDBCTest.java
@@ -17,14 +17,24 @@ import java.sql.*;
  */
 public class MJDBCTest {
        public static void main(String[] args) throws Exception {
-               //Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
-               // turn on debugging (disabled)
-               //nl.cwi.monetdb.jdbc.MonetConnection.setDebug(true);
-               Connection con = 
DriverManager.getConnection("jdbc:monetdb://localhost/notused", "monetdb", 
"monetdb");
+               String MonetDB_JDBC_URL = 
"jdbc:monetdb://localhost:50000/demo";        // change host, port and 
databasename
+               Connection con;
+               try {
+                       con = DriverManager.getConnection(MonetDB_JDBC_URL, 
"monetdb", "monetdb");
+               } catch (SQLException e) {
+                       System.err.println("Failed to connect to MonetDB 
server! Message: " + e.getMessage());
+               }
+
+               if (con == null) {
+                       System.err.println("Failed to create a connection 
object!");
+                       return;
+               }
+
                Statement st = con.createStatement();
                ResultSet rs;
 
-               rs = st.executeQuery("SELECT a.var1, COUNT(b.id) as total FROM 
a, b WHERE a.var1 = b.id AND a.var1 = 'andb' GROUP BY a.var1 ORDER BY a.var1, 
total;");
+               String sql = "SELECT a.var1, COUNT(b.id) as total FROM a, b 
WHERE a.var1 = b.id AND a.var1 = 'andb' GROUP BY a.var1 ORDER BY a.var1, 
total;";
+               rs = st.executeQuery(sql);
                // get meta data and print columns with their type
                ResultSetMetaData md = rs.getMetaData();
                for (int i = 1; i <= md.getColumnCount(); i++) {
@@ -48,39 +58,51 @@ public class MJDBCTest {
                // we ask the database for 22 rows, while we set the JDBC 
driver to
                // 5 rows, this shouldn't be a problem at all...
                rs = st.executeQuery("select * from a limit 22");
+               int var1_cnr = rs.findColumn("var1");
+               int var2_cnr = rs.findColumn("var2");
+               int var3_cnr = rs.findColumn("var3");
+               int var4_cnr = rs.findColumn("var4");
                // read till the driver says there are no rows left
                for (int i = 0; rs.next(); i++) {
-                       System.out.print("[" + rs.getString("var1") + "]");
-                       System.out.print("[" + rs.getString("var2") + "]");
-                       System.out.print("[" + rs.getInt("var3") + "]");
-                       System.out.println("[" + rs.getString("var4") + "]");
+                       System.out.println(
+                               "[" + rs.getString(var1_cnr) + "]" +
+                               "[" + rs.getString(var2_cnr) + "]" +
+                               "[" + rs.getInt(var3_cnr) + "]" +
+                               "[" + rs.getString(var4_cnr) + "]" );
                }
-               
-               // this close is not needed, should be done by next 
execute(Query) call
+
+               // this rs.close is not needed, should be done by next 
execute(Query) call
                // however if there can be some time between this point and the 
next
                // execute call, it is from a resource perspective better to 
close it.
-               //rs.close();
+               rs.close();
                
                // unset the row limit; 0 means as much as the database sends us
                st.setMaxRows(0);
                // we only ask 10 rows
                rs = st.executeQuery("select * from b limit 10;");
+               int rowid_cnr = rs.findColumn("rowid");
+               int id_cnr = rs.findColumn("id");
+               var1_cnr = rs.findColumn("var1");
+               var2_cnr = rs.findColumn("var2");
+               var3_cnr = rs.findColumn("var3");
+               var4_cnr = rs.findColumn("var4");
                // and simply print them
                while (rs.next()) {
-                       System.out.print(rs.getInt("rowid") + ", ");
-                       System.out.print(rs.getString("id") + ", ");
-                       System.out.print(rs.getInt("var1") + ", ");
-                       System.out.print(rs.getInt("var2") + ", ");
-                       System.out.print(rs.getString("var3") + ", ");
-                       System.out.println(rs.getString("var4"));
+                       System.out.println(
+                               rs.getInt(rowid_cnr) + ", " +
+                               rs.getString(id_cnr) + ", " +
+                               rs.getInt(var1_cnr) + ", " +
+                               rs.getInt(var2_cnr) + ", " +
+                               rs.getString(var3_cnr) + ", " +
+                               rs.getString(var4_cnr) );
                }
                
-               // this close is not needed, as the Statement will close the 
last
+               // this close is not required, as the Statement will close the 
last
                // ResultSet around when it's closed
                // again, if that can take some time, it's nicer to close 
immediately
                // the reason why these closes are commented out here, is to 
test if
                // the driver really cleans up it's mess like it should
-               //rs.close();
+               rs.close();
 
                // perform a ResultSet-less query (with no trailing ; since 
that should
                // be possible as well and is JDBC standard)
@@ -89,12 +111,12 @@ public class MJDBCTest {
                // support returning the affected rows.
                st.executeUpdate("delete from a where var1 = 'zzzz'");
 
-               // closing the connection should take care of closing all 
generated
-               // statements from it...
                // Don't forget to do it yourself if the connection is reused 
or much
                // longer alive, since the Statement object contains a lot of 
things
                // you probably want to reclaim if you don't need them anymore.
-               //st.close();
+               st.close();
+               // closing the connection should take care of closing all 
generated
+               // statements from it...
                con.close();
        }
 }
diff --git a/example/PreparedExample.java b/example/PreparedExample.java
--- a/example/PreparedExample.java
+++ b/example/PreparedExample.java
@@ -15,7 +15,6 @@ import java.sql.*;
  */
 public class PreparedExample {
        public static void main(String[] args) throws Exception {
-               //Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
                Connection con = 
DriverManager.getConnection("jdbc:monetdb://localhost/notused", "monetdb", 
"monetdb");
                PreparedStatement st = con.prepareStatement("SELECT ? AS a1, ? 
AS a2");
                ResultSet rs;
diff --git a/example/SQLImport.java b/example/SQLImport.java
--- a/example/SQLImport.java
+++ b/example/SQLImport.java
@@ -37,7 +37,6 @@ public class SQLImport {
                // open the file
                BufferedReader fr = new BufferedReader(new FileReader(args[0]));
 
-               // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
                // 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.
diff --git a/example/SQLcopyinto.java b/example/SQLcopyinto.java
--- a/example/SQLcopyinto.java
+++ b/example/SQLcopyinto.java
@@ -23,9 +23,10 @@ import nl.cwi.monetdb.mcl.protocol.Abstr
 
 public class SQLcopyinto {
        public static void main(String[] args) throws Exception {
-               // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
-               // 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
+               // 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
diff --git a/release.txt b/release.txt
--- a/release.txt
+++ b/release.txt
@@ -44,7 +44,7 @@ implementation is rich enough to be suit
 application settings.
 
 Below a list of (un)supported features can be found.
-Please read this list if you intend to use this driver.
+Please read this list if you intend to use this JDBC driver.
 
 If you feel some features are missing or have encountered an issue/bug,
 please let us know at our bugtracker:
@@ -59,19 +59,20 @@ Currently implemented JDBC 4.1 interface
     - createArrayOf, createNClob, createStruct, createSQLXML
     - createStatement with result set holdability
     - prepareCall (CallableStatement is not supported)
+       see also: https://www.monetdb.org/bugzilla/show_bug.cgi?id=6402
     - prepareStatement with array of column indices or column names
-    - setHoldability (close/hold cursors over commit is not
-      configurable)
-  NOTE: be sure to check for warnings after setting concurrencies or
-        isolation levels; MonetDB currently does not support anything
-        else but "fully serializable" transactions.
+    - setHoldability (close/hold cursors over commit is not configurable)
+
+    NOTE: be sure to check for warnings after setting concurrencies or
+          isolation levels; MonetDB currently does not support anything
+          else but "fully serializable" transactions.
 
   * java.sql.DatabaseMetaData
 
   * java.sql.Statement
     The next features/methods are NOT implemented:
     - cancel (query execution cannot be terminated, once started)
-      see also: https://www.monetdb.org/bugzilla/show_bug.cgi?id=6222
+       see also: https://www.monetdb.org/bugzilla/show_bug.cgi?id=6222
     - execute with column indices or names
     - executeUpdate with column indices or names
     - setMaxFieldSize
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
@@ -18,16 +18,18 @@ import java.sql.SQLFeatureNotSupportedEx
 import java.util.Arrays;
 
 /**
- * The MonetBlob class implements the {@link java.sql.Blob} interface.  Because
- * MonetDB/SQL currently has no support for streams, this class is a
+ * The MonetBlob class implements the {@link java.sql.Blob} interface.
+ *
+ * Because MonetDB/SQL currently has no support for streams, this class is a
  * shallow wrapper of a byte[].  It is more or less supplied to
  * enable an application that depends on it to run.  It may be obvious
  * that it is a real resource expensive workaround that contradicts the
  * benefits for a Blob: avoidance of huge resource consumption.
+ * <b>Use of this class is highly discouraged.</b>
  *
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to