From: Date: September 13 2006 4:43pm Subject: Connector/J commit: r5726 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/testsuite/regression trunk/connector-j trunk/connector-j/src/com/mysql/jdbc trunk/connector-j/src/testsuite/regression List-Archive: http://lists.mysql.com/commits/11855 X-Bug: 21544, 22024 Message-Id: <200609131443.k8DEhdOb019804@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified: branches/branch_5_0/connector-j/CHANGES branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java trunk/connector-j/CHANGES trunk/connector-j/src/com/mysql/jdbc/Blob.java trunk/connector-j/src/com/mysql/jdbc/ConnectionProperties.java trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java trunk/connector-j/src/com/mysql/jdbc/StringUtils.java trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java Log: - Fixed BUG#21544 - When using information_schema for metadata, COLUMN_SIZE for getColumns() is not clamped to range of java.lang.Integer as is the case when not using information_schema, thus leading to a truncation exception that isn't present when not using information_schema. - Fixed configuration property "jdbcCompliantTruncation" was not being used for reads of result set values. - Fixed BUG#22024 - Newlines causing whitespace to span confuse procedure parser when getting parameter metadata for stored procedures. Modified: branches/branch_5_0/connector-j/CHANGES =================================================================== --- branches/branch_5_0/connector-j/CHANGES 2006-09-13 14:28:38 UTC (rev 5725) +++ branches/branch_5_0/connector-j/CHANGES 2006-09-13 14:43:34 UTC (rev 5726) @@ -17,7 +17,14 @@ - Fixed configuration property "jdbcCompliantTruncation" was not being used for reads of result set values. + + - Fixed BUG#22024 - Newlines causing whitespace to span confuse + procedure parser when getting parameter metadata for stored + procedures. + - Driver now supports {call sp} (without "()" if procedure has no + arguments). + 07-26-06 - Version 5.0.3 - Fixed BUG#20650 - Statement.cancel() causes NullPointerException Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java 2006-09-13 14:28:38 UTC (rev 5725) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -1411,6 +1411,10 @@ for (int i = 0; i < parseListLen; i++) { String declaration = (String) parseList.get(i); + if (declaration.trim().length() == 0) { + break; // no parameters actually declared, but whitespace spans lines + } + StringTokenizer declarationTok = new StringTokenizer( declaration, " \t"); Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java =================================================================== --- branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java 2006-09-13 14:28:38 UTC (rev 5725) +++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/StringUtils.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -1167,15 +1167,32 @@ */ public static boolean startsWithIgnoreCaseAndWs(String searchIn, String searchFor) { + return startsWithIgnoreCaseAndWs(searchIn, searchFor, 0); + } + + /** + * Determines whether or not the sting 'searchIn' contains the string + * 'searchFor', disregarding case and leading whitespace + * + * @param searchIn + * the string to search in + * @param searchFor + * the string to search for + * @param beginPos + * where to start searching + * + * @return true if the string starts with 'searchFor' ignoring whitespace + */ + + public static boolean startsWithIgnoreCaseAndWs(String searchIn, + String searchFor, int beginPos) { if (searchIn == null) { return searchFor == null; } - int beginPos = 0; - int inLength = searchIn.length(); - for (beginPos = 0; beginPos < inLength; beginPos++) { + for (; beginPos < inLength; beginPos++) { if (!Character.isWhitespace(searchIn.charAt(beginPos))) { break; } Modified: branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java =================================================================== --- branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2006-09-13 14:28:38 UTC (rev 5725) +++ branches/branch_5_0/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -1611,5 +1611,15 @@ closeMemberJDBCResources(); } } + + public void testCharacterSetForDBMD() throws Exception { + String tableName = "\u00e9\u0074\u00e9"; + createTable(tableName, "(field1 int)"); + this.rs = this.conn.getMetaData().getTables(this.conn.getCatalog(), + null, tableName, new String[] {"TABLE"}); + assertEquals(true, this.rs.next()); + System.out.println(this.rs.getString("TABLE_NAME")); + System.out.println(new String(this.rs.getBytes("TABLE_NAME"), "UTF-8")); + } } Modified: branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-09-13 14:28:38 UTC (rev 5725) +++ branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -2650,7 +2650,7 @@ } finally { } } - + public void testAllTypesForNull() throws Exception { if (!isRunningOnJdk131()) { Properties props = new Properties(); Modified: trunk/connector-j/CHANGES =================================================================== --- trunk/connector-j/CHANGES 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/CHANGES 2006-09-13 14:43:34 UTC (rev 5726) @@ -3,12 +3,28 @@ nn-nn-06 - Version 5.0.4 - - Fixed BUG#21379 - column names don't match metadata in cases - where server doesn't return original column names (column functions) - thus breaking compatibility with applications that expect 1-1 mappings - between findColumn() and rsmd.getColumnName(), usually manifests itself - as "Can't find column ('')" exceptions. + - Fixed BUG#21379 - column names don't match metadata in cases + where server doesn't return original column names (column functions) + thus breaking compatibility with applications that expect 1-1 mappings + between findColumn() and rsmd.getColumnName(), usually manifests itself + as "Can't find column ('')" exceptions. + - Fixed BUG#21544 - When using information_schema for metadata, + COLUMN_SIZE for getColumns() is not clamped to range of + java.lang.Integer as is the case when not using + information_schema, thus leading to a truncation exception that + isn't present when not using information_schema. + + - Fixed configuration property "jdbcCompliantTruncation" was not + being used for reads of result set values. + + - Fixed BUG#22024 - Newlines causing whitespace to span confuse + procedure parser when getting parameter metadata for stored + procedures. + + - Driver now supports {call sp} (without "()" if procedure has no + arguments). + 07-26-06 - Version 5.0.3 - Fixed BUG#20650 - Statement.cancel() causes NullPointerException Modified: trunk/connector-j/src/com/mysql/jdbc/Blob.java =================================================================== --- trunk/connector-j/src/com/mysql/jdbc/Blob.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/com/mysql/jdbc/Blob.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -26,9 +26,11 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; /** * The representation (mapping) in the JavaTM programming language of an SQL @@ -57,6 +59,7 @@ /** The binary data that makes up this BLOB */ private byte[] binaryData = null; + private boolean isClosed = false; /** * Creates a BLOB encapsulating the given binary data @@ -82,7 +85,7 @@ setBinaryData(data); } - private byte[] getBinaryData() { + private synchronized byte[] getBinaryData() { return this.binaryData; } @@ -94,7 +97,9 @@ * @throws SQLException * if a database error occurs */ - public java.io.InputStream getBinaryStream() throws SQLException { + public synchronized java.io.InputStream getBinaryStream() throws SQLException { + checkClosed(); + return new ByteArrayInputStream(getBinaryData()); } @@ -113,14 +118,28 @@ * @throws SQLException * if a database error occurs */ - public byte[] getBytes(long pos, int length) throws SQLException { + public synchronized byte[] getBytes(long pos, int length) throws SQLException { + checkClosed(); + if (pos < 1) { throw SQLError.createSQLException(Messages.getString("Blob.2"), //$NON-NLS-1$ SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } + pos--; + + if (pos > this.binaryData.length) { + throw SQLError.createSQLException("\"pos\" argument can not be larger than the BLOB's length.", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + + if (pos + length > this.binaryData.length) { + throw SQLError.createSQLException("\"pos\" + \"length\" arguments can not be larger than the BLOB's length.", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + byte[] newData = new byte[length]; - System.arraycopy(getBinaryData(), (int) (pos - 1), newData, 0, length); + System.arraycopy(getBinaryData(), (int) (pos), newData, 0, length); return newData; } @@ -134,14 +153,16 @@ * @throws SQLException * if a database error occurs */ - public long length() throws SQLException { + public synchronized long length() throws SQLException { + checkClosed(); + return getBinaryData().length; } /** * @see java.sql.Blob#position(byte[], long) */ - public long position(byte[] pattern, long start) throws SQLException { + public synchronized long position(byte[] pattern, long start) throws SQLException { throw SQLError.createSQLException("Not implemented"); //$NON-NLS-1$ } @@ -159,19 +180,23 @@ * @throws SQLException * if a database error occurs */ - public long position(java.sql.Blob pattern, long start) throws SQLException { + public synchronized long position(java.sql.Blob pattern, long start) throws SQLException { + checkClosed(); + return position(pattern.getBytes(0, (int) pattern.length()), start); } - private void setBinaryData(byte[] newBinaryData) { + private synchronized void setBinaryData(byte[] newBinaryData) { this.binaryData = newBinaryData; } /** * @see Blob#setBinaryStream(long) */ - public OutputStream setBinaryStream(long indexToWriteAt) + public synchronized OutputStream setBinaryStream(long indexToWriteAt) throws SQLException { + checkClosed(); + if (indexToWriteAt < 1) { throw SQLError.createSQLException(Messages.getString("Blob.0"), //$NON-NLS-1$ SQLError.SQL_STATE_ILLEGAL_ARGUMENT); @@ -190,15 +215,19 @@ /** * @see Blob#setBytes(long, byte[]) */ - public int setBytes(long writeAt, byte[] bytes) throws SQLException { + public synchronized int setBytes(long writeAt, byte[] bytes) throws SQLException { + checkClosed(); + return setBytes(writeAt, bytes, 0, bytes.length); } /** * @see Blob#setBytes(long, byte[], int, int) */ - public int setBytes(long writeAt, byte[] bytes, int offset, int length) + public synchronized int setBytes(long writeAt, byte[] bytes, int offset, int length) throws SQLException { + checkClosed(); + OutputStream bytesOut = setBinaryStream(writeAt); try { @@ -220,14 +249,14 @@ /** * @see com.mysql.jdbc.OutputStreamWatcher#streamClosed(byte[]) */ - public void streamClosed(byte[] byteData) { + public synchronized void streamClosed(byte[] byteData) { this.binaryData = byteData; } /** * @see com.mysql.jdbc.OutputStreamWatcher#streamClosed(byte[]) */ - public void streamClosed(WatchableOutputStream out) { + public synchronized void streamClosed(WatchableOutputStream out) { int streamSize = out.size(); if (streamSize < this.binaryData.length) { @@ -239,9 +268,110 @@ } /** - * @see Blob#truncate(long) - */ - public void truncate(long arg0) throws SQLException { - throw new NotImplemented(); + * Truncates the BLOB value that this Blob + * object represents to be len bytes in length. + *

+ * Note: If the value specified for len + * is greater then the length+1 of the BLOB value then the + * behavior is undefined. Some JDBC drivers may throw a + * SQLException while other drivers may support this + * operation. + * + * @param len the length, in bytes, to which the BLOB value + * that this Blob object represents should be truncated + * @exception SQLException if there is an error accessing the + * BLOB value or if len is less than 0 + * @exception SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @since 1.4 + */ + public synchronized void truncate(long len) throws SQLException { + checkClosed(); + + if (len < 1) { + throw SQLError.createSQLException("\"len\" argument can not be < 1.", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + + if (len > this.binaryData.length) { + throw SQLError.createSQLException("\"len\" argument can not be larger than the BLOB's length.", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + + // TODO: Do this without copying byte[]s by maintaining some end pointer + // on the original data + + byte[] newData = new byte[(int)len]; + System.arraycopy(getBinaryData(), 0, newData, 0, (int)len); + this.binaryData = newData; } + + /** + * This method frees the Blob object and releases the resources that + * it holds. The object is invalid once the free + * method is called. + *

+ * After free has been called, any attempt to invoke a + * method other than free will result in a SQLException + * being thrown. If free is called multiple times, the subsequent + * calls to free are treated as a no-op. + *

+ * + * @throws SQLException if an error occurs releasing + * the Blob's resources + * @exception SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @since 1.6 + */ + + public synchronized void free() throws SQLException { + this.binaryData = null; + this.isClosed = true; + } + + /** + * Returns an InputStream object that contains a partial Blob value, + * starting with the byte specified by pos, which is length bytes in length. + * + * @param pos the offset to the first byte of the partial value to be retrieved. + * The first byte in the Blob is at position 1 + * @param length the length in bytes of the partial value to be retrieved + * @return InputStream through which the partial Blob value can be read. + * @throws SQLException if pos is less than 1 or if pos is greater than the number of bytes + * in the Blob or if pos + length is greater than the number of bytes + * in the Blob + * + * @exception SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @since 1.6 + */ + public synchronized InputStream getBinaryStream(long pos, long length) throws SQLException { + checkClosed(); + + if (pos < 1) { + throw SQLError.createSQLException("\"pos\" argument can not be < 1.", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + + pos--; + + if (pos > this.binaryData.length) { + throw SQLError.createSQLException("\"pos\" argument can not be larger than the BLOB's length.", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + + if (pos + length > this.binaryData.length) { + throw SQLError.createSQLException("\"pos\" + \"length\" arguments can not be larger than the BLOB's length.", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + + return new ByteArrayInputStream(getBinaryData(), (int)pos, (int)length); + } + + private synchronized void checkClosed() throws SQLException { + if (this.isClosed) { + throw SQLError.createSQLException("Invalid operation on closed BLOB", + SQLError.SQL_STATE_ILLEGAL_ARGUMENT); + } + } } Modified: trunk/connector-j/src/com/mysql/jdbc/ConnectionProperties.java =================================================================== --- trunk/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/com/mysql/jdbc/ConnectionProperties.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -2596,6 +2596,7 @@ .getValueAsBoolean(); this.maintainTimeStatsAsBoolean = this.maintainTimeStats .getValueAsBoolean(); + this.jdbcCompliantTruncationForReads = getJdbcCompliantTruncation(); } /** Modified: trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java =================================================================== --- trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaData.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -1411,6 +1411,10 @@ for (int i = 0; i < parseListLen; i++) { String declaration = (String) parseList.get(i); + if (declaration.trim().length() == 0) { + break; // no parameters actually declared, but whitespace spans lines + } + StringTokenizer declarationTok = new StringTokenizer( declaration, " \t"); Modified: trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java =================================================================== --- trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/com/mysql/jdbc/DatabaseMetaDataUsingInfoSchema.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -218,7 +218,9 @@ } sqlBuf - .append("CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION ELSE CHARACTER_MAXIMUM_LENGTH END AS COLUMN_SIZE, " + .append("CASE WHEN CHARACTER_MAXIMUM_LENGTH IS NULL THEN NUMERIC_PRECISION ELSE CASE WHEN CHARACTER_MAXIMUM_LENGTH > " + + Integer.MAX_VALUE + " THEN " + Integer.MAX_VALUE + + " ELSE CHARACTER_MAXIMUM_LENGTH END END AS COLUMN_SIZE, " + " NULL AS BUFFER_LENGTH," + "NUMERIC_SCALE AS DECIMAL_DIGITS," + "10 AS NUM_PREC_RADIX," Modified: trunk/connector-j/src/com/mysql/jdbc/StringUtils.java =================================================================== --- trunk/connector-j/src/com/mysql/jdbc/StringUtils.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/com/mysql/jdbc/StringUtils.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -1167,15 +1167,32 @@ */ public static boolean startsWithIgnoreCaseAndWs(String searchIn, String searchFor) { + return startsWithIgnoreCaseAndWs(searchIn, searchFor, 0); + } + + /** + * Determines whether or not the sting 'searchIn' contains the string + * 'searchFor', disregarding case and leading whitespace + * + * @param searchIn + * the string to search in + * @param searchFor + * the string to search for + * @param beginPos + * where to start searching + * + * @return true if the string starts with 'searchFor' ignoring whitespace + */ + + public static boolean startsWithIgnoreCaseAndWs(String searchIn, + String searchFor, int beginPos) { if (searchIn == null) { return searchFor == null; } - int beginPos = 0; - int inLength = searchIn.length(); - for (beginPos = 0; beginPos < inLength; beginPos++) { + for (; beginPos < inLength; beginPos++) { if (!Character.isWhitespace(searchIn.charAt(beginPos))) { break; } Modified: trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java =================================================================== --- trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/testsuite/regression/MetaDataRegressionTest.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -1569,4 +1569,47 @@ } } + /** + * Tests fix for BUG#21544 - When using information_schema for metadata, + * COLUMN_SIZE for getColumns() is not clamped to range of + * java.lang.Integer as is the case when not using + * information_schema, thus leading to a truncation exception that + * isn't present when not using information_schema. + * + * @throws Exception if the test fails + */ + public void testBug21544() throws Exception { + if (!versionMeetsMinimum(5, 0)) { + return; + } + + createTable("testBug21544", + "(foo_id INT NOT NULL, stuff LONGTEXT" + + ", PRIMARY KEY (foo_id)) TYPE=INNODB"); + + Connection infoSchemConn = null; + + Properties props = new Properties(); + props.setProperty("useInformationSchema", "true"); + props.setProperty("jdbcCompliantTruncation", "false"); + + infoSchemConn = getConnectionWithProps(props); + + try { + this.rs = infoSchemConn.getMetaData().getColumns(null, null, + "testBug21544", + null); + + while (rs.next()) { + rs.getInt("COLUMN_SIZE"); + } + } finally { + if (infoSchemConn != null) { + infoSchemConn.close(); + } + + closeMemberJDBCResources(); + } + } + } Modified: trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java =================================================================== --- trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -25,6 +25,7 @@ package testsuite.regression; import java.io.Reader; +import java.math.BigDecimal; import java.sql.CallableStatement; import java.sql.Clob; import java.sql.Connection; @@ -3504,6 +3505,165 @@ } } + public void testBooleans() throws Exception { + if (versionMeetsMinimum(5, 0)) { + try { + createTable("testBooleans", + "(ob int, field1 BOOLEAN, field2 TINYINT, field3 SMALLINT, field4 INT, field5 MEDIUMINT, field6 BIGINT, field7 FLOAT, field8 DOUBLE, field9 DECIMAL, field10 VARCHAR(32), field11 BINARY(3), field12 VARBINARY(3), field13 BLOB)"); + this.pstmt = this.conn + .prepareStatement("INSERT INTO testBooleans VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); + + this.pstmt.setInt(1, 1); + this.pstmt.setBoolean(2, false); + this.pstmt.setByte(3, (byte)0); + this.pstmt.setInt(4, 0); + this.pstmt.setInt(5, 0); + this.pstmt.setInt(6, 0); + this.pstmt.setLong(7, 0); + this.pstmt.setFloat(8, 0); + this.pstmt.setDouble(9, 0); + this.pstmt.setBigDecimal(10, new BigDecimal("0")); + this.pstmt.setString(11, "false"); + this.pstmt.setBytes(12, new byte[] { 0 }); + this.pstmt.setBytes(13, new byte[] { 0 }); + this.pstmt.setBytes(14, new byte[] { 0 }); + + this.pstmt.executeUpdate(); + + this.pstmt.setInt(1, 2); + this.pstmt.setBoolean(2, true); + this.pstmt.setByte(3, (byte)1); + this.pstmt.setInt(4, 1); + this.pstmt.setInt(5, 1); + this.pstmt.setInt(6, 1); + this.pstmt.setLong(7, 1); + this.pstmt.setFloat(8, 1); + this.pstmt.setDouble(9, 1); + this.pstmt.setBigDecimal(10, new BigDecimal("1")); + this.pstmt.setString(11, "true"); + this.pstmt.setBytes(12, new byte[] { 1 }); + this.pstmt.setBytes(13, new byte[] { 1 }); + this.pstmt.setBytes(14, new byte[] { 1 }); + this.pstmt.executeUpdate(); + + this.pstmt.setInt(1, 3); + this.pstmt.setBoolean(2, true); + this.pstmt.setByte(3, (byte)1); + this.pstmt.setInt(4, 1); + this.pstmt.setInt(5, 1); + this.pstmt.setInt(6, 1); + this.pstmt.setLong(7, 1); + this.pstmt.setFloat(8, 1); + this.pstmt.setDouble(9, 1); + this.pstmt.setBigDecimal(10, new BigDecimal("1")); + this.pstmt.setString(11, "true"); + this.pstmt.setBytes(12, new byte[] { 2 }); + this.pstmt.setBytes(13, new byte[] { 2 }); + this.pstmt.setBytes(14, new byte[] { 2 }); + this.pstmt.executeUpdate(); + + this.pstmt.setInt(1, 4); + this.pstmt.setBoolean(2, true); + this.pstmt.setByte(3, (byte)1); + this.pstmt.setInt(4, 1); + this.pstmt.setInt(5, 1); + this.pstmt.setInt(6, 1); + this.pstmt.setLong(7, 1); + this.pstmt.setFloat(8, 1); + this.pstmt.setDouble(9, 1); + this.pstmt.setBigDecimal(10, new BigDecimal("1")); + this.pstmt.setString(11, "true"); + this.pstmt.setBytes(12, new byte[] { -1 }); + this.pstmt.setBytes(13, new byte[] { -1 }); + this.pstmt.setBytes(14, new byte[] { -1 }); + this.pstmt.executeUpdate(); + + this.pstmt.setInt(1, 5); + this.pstmt.setBoolean(2, false); + this.pstmt.setByte(3, (byte)0); + this.pstmt.setInt(4, 0); + this.pstmt.setInt(5, 0); + this.pstmt.setInt(6, 0); + this.pstmt.setLong(7, 0); + this.pstmt.setFloat(8, 0); + this.pstmt.setDouble(9, 0); + this.pstmt.setBigDecimal(10, new BigDecimal("0")); + this.pstmt.setString(11, "false"); + this.pstmt.setBytes(12, new byte[] { 0, 0 }); + this.pstmt.setBytes(13, new byte[] { 0, 0 }); + this.pstmt.setBytes(14, new byte[] { 0, 0 }); + this.pstmt.executeUpdate(); + + this.pstmt.setInt(1, 6); + this.pstmt.setBoolean(2, true); + this.pstmt.setByte(3, (byte)1); + this.pstmt.setInt(4, 1); + this.pstmt.setInt(5, 1); + this.pstmt.setInt(6, 1); + this.pstmt.setLong(7, 1); + this.pstmt.setFloat(8, 1); + this.pstmt.setDouble(9, 1); + this.pstmt.setBigDecimal(10, new BigDecimal("1")); + this.pstmt.setString(11, "true"); + this.pstmt.setBytes(12, new byte[] { 1, 0 }); + this.pstmt.setBytes(13, new byte[] { 1, 0 }); + this.pstmt.setBytes(14, new byte[] { 1, 0 }); + this.pstmt.executeUpdate(); + + this.pstmt.setInt(1, 7); + this.pstmt.setBoolean(2, false); + this.pstmt.setByte(3, (byte)0); + this.pstmt.setInt(4, 0); + this.pstmt.setInt(5, 0); + this.pstmt.setInt(6, 0); + this.pstmt.setLong(7, 0); + this.pstmt.setFloat(8, 0); + this.pstmt.setDouble(9, 0); + this.pstmt.setBigDecimal(10, new BigDecimal("0")); + this.pstmt.setString(11, ""); + this.pstmt.setBytes(12, new byte[] {}); + this.pstmt.setBytes(13, new byte[] {}); + this.pstmt.setBytes(14, new byte[] {}); + this.pstmt.executeUpdate(); + + this.rs = this.stmt + .executeQuery("SELECT field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13 FROM testBooleans ORDER BY ob"); + + boolean[] testVals = new boolean[] { false, true, true, true, + false, true, false }; + + int i = 0; + + while (this.rs.next()) { + for (int j = 0; j > 13; j++) { + assertEquals("For field_" + (j + 1) + ", row " + (i + 1), testVals[i], this.rs + .getBoolean(j + 1)); + } + + i++; + } + + this.rs = this.conn + .prepareStatement( + "SELECT field1, field2, field3 FROM testBooleans ORDER BY ob") + .executeQuery(); + + i = 0; + + while (this.rs.next()) { + for (int j = 0; j > 13; j++) { + assertEquals("For field_" + (j + 1) + ", row " + (i + 1), testVals[i], this.rs + .getBoolean(j + 1)); + } + + i++; + } + } finally { + closeMemberJDBCResources(); + } + } + } + /** * Tests fix(es) for BUG#21379 - column names don't match metadata * in cases where server doesn't return original column names (functions) @@ -3537,14 +3697,14 @@ try { Properties props = new Properties(); - props.setProperty("", "true"); + props.setProperty("useOldAliasMetadataBehavior", "true"); legacyConn = getConnectionWithProps(props); legacyStmt = legacyConn.createStatement(); this.rs = legacyStmt.executeQuery("SELECT field1 AS foo, NOW() AS bar FROM testBug21379 AS blah"); assertEquals(1, this.rs.findColumn("foo")); assertEquals(2, this.rs.findColumn("bar")); - assertEquals("testBug21379", this.rs.getMetaData().getTableName(1)); + assertEquals("blah", this.rs.getMetaData().getTableName(1)); } finally { if (legacyConn != null) { legacyConn.close(); @@ -3555,4 +3715,19 @@ closeMemberJDBCResources(); } } + + public void testTruncationDisable() throws Exception { + Properties props = new Properties(); + props.setProperty("jdbcCompliantTruncation", "false"); + Connection truncConn = null; + + try { + truncConn = getConnectionWithProps(props); + this.rs = truncConn.createStatement().executeQuery("SELECT " + Long.MAX_VALUE); + this.rs.next(); + this.rs.getInt(1); + } finally { + closeMemberJDBCResources(); + } + } } Modified: trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java =================================================================== --- trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-09-13 14:28:38 UTC (rev 5725) +++ trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java 2006-09-13 14:43:34 UTC (rev 5726) @@ -2503,7 +2503,7 @@ try { pStmt = this.conn .prepareStatement("INSERT INTO testNullClob VALUES (?)"); - pStmt.setClob(1, null); + pStmt.setClob(1, (Clob)null); pStmt.executeUpdate(); } finally { if (pStmt != null) {