Changeset: d4f2c3e7308a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d4f2c3e7308a Modified Files: java/ChangeLog.Jun2010 java/Makefile.ag java/NT/rules.msc java/build.properties java/release.txt java/src/nl/cwi/monetdb/jdbc/MonetBlob.java java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java Branch: Jun2010 Log Message:
Implement missing Blob support (readonly), since getObject will blindly return a BLOB instance as String, which is causing applications to wrongly believe a BLOB instance is a string. Bump version to 1.17. diffs (truncated from 381 to 300 lines): diff -r 4c412b3a546e -r d4f2c3e7308a java/ChangeLog.Jun2010 --- a/java/ChangeLog.Jun2010 Tue Jul 20 14:48:28 2010 +0200 +++ b/java/ChangeLog.Jun2010 Tue Jul 20 15:14:47 2010 +0200 @@ -1,6 +1,19 @@ # ChangeLog file for java # This file is updated with mchangelog (Gentoo echangelog bastard script) + 20 Jul 2010; Fabian Groffen <[email protected]> Makefile.ag, NT/rules.msc, + build.properties, release.txt, +src/nl/cwi/monetdb/jdbc/MonetBlob.java, + src/nl/cwi/monetdb/jdbc/MonetResultSet.java: + Implement missing Blob support (readonly), since getObject will blindly + return a BLOB instance as String, which is causing applications to wrongly + believe a BLOB instance is a string. Bump version to 1.17. + + 16 Jul 2010; Fabian Groffen <[email protected]> + stc/nl/cwi/monetdb/jdbc/MonetConnection.java: + Fix problem when using the MAL language. Any statement would return + an error with a typo that was not typed in by the user, such as + ioo.printf when io.printf was typed. + 16 Apr 2010; Fabian Groffen <[email protected]> build.xml, configure.ag, Makefile.ag: Enable the merovingian control library for default distribution as it @@ -23,6 +36,3 @@ latter clean from files generated during the build. On Windows, the build directory must be a sibling of ...<package>NT . -* Fri Jul 16 2010 Fabian Groffen <[email protected]> -- Fix problem when using the MAL language. Any statement would return an error with a typo that was not typed in by the user, such as ioo.printf when io.printf was typed. - diff -r 4c412b3a546e -r d4f2c3e7308a java/Makefile.ag --- a/java/Makefile.ag Tue Jul 20 14:48:28 2010 +0200 +++ b/java/Makefile.ag Tue Jul 20 15:14:47 2010 +0200 @@ -30,7 +30,7 @@ ant_distjdbc = { COND = HAVE_JAVAJDBC DIR = datadir/MonetDB/lib - FILES = monetdb-1.6-mcl.jar monetdb-1.16-jdbc.jar jdbcclient.jar + FILES = monetdb-1.6-mcl.jar monetdb-1.17-jdbc.jar jdbcclient.jar } ant_distxrpc = { diff -r 4c412b3a546e -r d4f2c3e7308a java/NT/rules.msc --- a/java/NT/rules.msc Tue Jul 20 14:48:28 2010 +0200 +++ b/java/NT/rules.msc Tue Jul 20 15:14:47 2010 +0200 @@ -28,6 +28,6 @@ !INCLUDE $(RULESMSC) pkg = java -VERSION=20100716 +VERSION=20100720 ODBC_LIBS = odbccp32.lib user32.lib diff -r 4c412b3a546e -r d4f2c3e7308a java/build.properties --- a/java/build.properties Tue Jul 20 14:48:28 2010 +0200 +++ b/java/build.properties Tue Jul 20 15:14:47 2010 +0200 @@ -19,7 +19,7 @@ # major release number JDBC_MAJOR=1 # minor release number -JDBC_MINOR=16 +JDBC_MINOR=17 # an additional identifying string JDBC_VER_SUFFIX=Magnistipula # the default port to connect on, if no port given when using SQL diff -r 4c412b3a546e -r d4f2c3e7308a java/release.txt --- a/java/release.txt Tue Jul 20 14:48:28 2010 +0200 +++ b/java/release.txt Tue Jul 20 15:14:47 2010 +0200 @@ -1,8 +1,8 @@ RELEASE NOTES -MonetDB JDBC driver version 1.16 (Magnistipula/MCL-1.6) +MonetDB JDBC driver version 1.17 (Magnistipula/MCL-1.6) Fabian Groffen <[email protected]> -Release date: 2010-07-16 +Release date: 2010-07-20 This JDBC driver is designed for use with MonetDB, a main-memory @@ -63,7 +63,6 @@ The next features are not implemented: - getArray - getAsciiStream, getBinaryStream, getUnicodeStream, getCharacterStream - - getBlob - getRef, getURL - all methods related to updateable result sets * java.sql.ResultSetMetaData interface diff -r 4c412b3a546e -r d4f2c3e7308a java/src/nl/cwi/monetdb/jdbc/MonetBlob.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java Tue Jul 20 15:14:47 2010 +0200 @@ -0,0 +1,203 @@ +/* + * The contents of this file are subject to the MonetDB Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is the MonetDB Database System. + * + * The Initial Developer of the Original Code is CWI. + * Portions created by CWI are Copyright (C) 1997-July 2008 CWI. + * Copyright August 2008-2010 MonetDB B.V. + * All Rights Reserved. + */ + +package nl.cwi.monetdb.jdbc; + +import java.sql.*; +import java.io.*; + +/** + * The MonetBlob class implements the java.sql.Blob interface. Because + * MonetDB/SQL currently has no support for streams, this class is a + * shallow wrapper of a StringBuffer. 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. + * + * @author Fabian Groffen <[email protected]> + */ +public class MonetBlob implements Blob { + private byte[] buf; + + protected MonetBlob(String in) { + int len = in.length() / 2; + buf = new byte[len]; + for (int i = 0; i < len; i++) + buf[i] = Byte.parseByte(in.substring(2 * i, (2 * i) + 2), 16); + } + + //== begin interface Blob + + public InputStream getBinaryStream() throws SQLException { + return(new ByteArrayInputStream(buf)); + } + + /** + * Retrieves all or part of the BLOB value that this Blob object + * represents, as an array of bytes. This byte array contains up to + * length consecutive bytes starting at position pos. + * + * @param pos the ordinal position of the first byte in the BLOB + * value to be extracted; the first byte is at position 1. + * @param length the number of consecutive bytes to be copied + * @return a byte array containing up to length consecutive bytes + * from the BLOB value designated by this Blob object, + * starting with the byte at position pos. + * @throws SQLException if there is an error accessing the + * BLOB value + */ + public byte[] getBytes(long pos, int length) throws SQLException { + try { + byte[] r = new byte[length]; + for (int i = 0; i < length; i++) + r[i] = buf[(int)pos - 1 + i]; + return(r); + } catch (IndexOutOfBoundsException e) { + throw new SQLException(e.getMessage()); + } + } + + /** + * Returns the number of bytes in the BLOB value designated by this + * Blob object. + * + * @return length of the BLOB in bytes + * @throws SQLException if there is an error accessing the length + * of the BLOB value + */ + public long length() throws SQLException { + return((long)buf.length); + } + + /** + * Retrieves the byte position in the BLOB value designated by this + * Blob object at which pattern begins. The search begins at + * position start. + * + * @param pattern the Blob object designating the BLOB value for + * which to search + * @param start the position in the BLOB value at which to begin + * searching; the first position is 1 + * @return the position at which the pattern begins, else -1 + * @throws SQLException if there is an error accessing the + * BLOB value + */ + public long position(Blob pattern, long start) throws SQLException { + return(position(pattern.getBytes(1L, (int)pattern.length()), start)); + } + + /** + * Retrieves the byte position at which the specified byte array + * pattern begins within the BLOB value that this Blob object + * represents. The search for pattern begins at position start. + * + * @param pattern the byte array for which to search + * @param start the position at which to begin searching; + * the first position is 1 + * @return the position at which the pattern appears, else -1 + * @throws SQLException if there is an error accessing the + * BLOB value + */ + public long position(byte[] pattern, long start) throws SQLException { + try { + for (int i = (int)(start - 1); i < buf.length - pattern.length; i++) { + int j; + for (j = 0; j < pattern.length; j++) { + if (buf[i + j] != pattern[j]) + break; + } + if (j == pattern.length) + return(i); + } + } catch (IndexOutOfBoundsException e) { + throw new SQLException(e.getMessage()); + } + return(-1); + } + + public OutputStream setBinaryStream(long pos) throws SQLException { + throw new SQLException("Operation currently not supported"); + } + + /** + * Writes the given array of bytes to the BLOB value that this Blob + * object represents, starting at position pos, and returns the + * number of bytes written. + * + * @param pos the position in the BLOB object at which to start + * writing + * @param bytes the array of bytes to be written to the BLOB value + * that this Blob object represents + * @return the number of bytes written + * @throws SQLException if there is an error accessing the + * BLOB value + */ + public int setBytes(long pos, byte[] bytes) throws SQLException { + return(setBytes(pos, bytes, 1, bytes.length)); + } + + /** + * Writes all or part of the given byte array to the BLOB value that + * this Blob object represents and returns the number of bytes + * written. Writing starts at position pos in the BLOB value; len + * bytes from the given byte array are written. + * + * @param pos the position in the BLOB object at which to start + * writing + * @param bytes the array of bytes to be written to this BLOB + * object + * @param offset the offset into the array bytes at which to start + * reading the bytes to be set + * @param len the number of bytes to be written to the BLOB value + * from the array of bytes bytes + * @return the number of bytes written + * @throws SQLException if there is an error accessing the + * BLOB value + */ + public int setBytes(long pos, byte[] bytes, int offset, int len) + throws SQLException + { + try { + /* transactions? what are you talking about? */ + for (int i = (int)pos; i < len; i++) + buf[i] = bytes[offset - 1 + i]; + } catch (IndexOutOfBoundsException e) { + throw new SQLException(e.getMessage()); + } + return(len); + } + + /** + * Truncates the BLOB value that this Blob object represents to be + * len bytes in length. + * + * @param len the length, in bytes, to which the BLOB value + * should be truncated + * @throws SQLException if there is an error accessing the + * BLOB value + */ + public void truncate(long len) { + if (buf.length > len) { + byte[] newbuf = new byte[(int)len]; + for (int i = 0; i < len; i++) + newbuf[i] = buf[i]; + buf = newbuf; + } + } +} diff -r 4c412b3a546e -r d4f2c3e7308a java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java --- a/java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java Tue Jul 20 14:48:28 2010 +0200 +++ b/java/src/nl/cwi/monetdb/jdbc/MonetResultSet.java Tue Jul 20 15:14:47 2010 +0200 @@ -291,13 +291,45 @@ public InputStream getBinaryStream(String columnName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); } public InputStream getUnicodeStream(int columnIndex) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); } _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
