@Test public void dataTruncationTranslation() { SQLExceptionTranslator sext = new SQLErrorCodeSQLExceptionTranslator(ERROR_CODES); SQLException dataAccessEx = new SQLException("", "", 5); DataTruncation dataTruncation = new DataTruncation(1, true, true, 1, 1, dataAccessEx); DataAccessResourceFailureException daex = (DataAccessResourceFailureException) sext.translate("task", "SQL", dataTruncation); assertEquals(dataTruncation, daex.getCause()); }
public void setString(String value) throws SQLException { byte[] data = setStringForced(value); if (value == null) return; assert data != null : "Expected non-null data here"; if (data.length > fieldDescriptor.getLength() && !isSystemTable(fieldDescriptor.getOriginalTableName())) { // special handling for the LIKE ? queries with CHAR(1) fields if (!(value.length() <= fieldDescriptor.getLength() + 2 && (value.charAt(0) == '%' || value.charAt(value.length() - 1) == '%'))) throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, data.length, fieldDescriptor.getLength()); } }
public void setString(String value) throws SQLException { byte[] data = setStringForced(value); if (value == null) return; assert data != null : "Expected non-null data here"; if (data.length > fieldDescriptor.getLength() && !isSystemTable(fieldDescriptor.getOriginalTableName())) { // special handling for the LIKE ? queries with CHAR(1) fields if (!(value.length() <= fieldDescriptor.getLength() + 2 && (value.charAt(0) == '%' || value.charAt(value.length() - 1) == '%'))) throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, data.length, fieldDescriptor.getLength()); } }
postWarning(new DataTruncation(parameterIndex, true, true, -1, -1)); postWarning(new DataTruncation(parameterIndex, true, true, actualSize, actualSize - truncated));
postWarning(new DataTruncation(columnIndex, false, true, -1, -1)); postWarning (new DataTruncation (columnIndex, false, true, actualSize, actualSize - truncated));
@Override public void setBytes(byte[] value) throws SQLException { if (value == null) { setNull(); return; } if (value.length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, value.length, fieldDescriptor.getLength()); } setFieldData(value); }
@Override public void setBytes(byte[] value) throws SQLException { if (value == null) { setNull(); return; } if (value.length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, value.length, fieldDescriptor.getLength()); } setFieldData(value); }
@Override public void setBytes(byte[] value) throws SQLException { if (value == null) { setNull(); return; } if (value.length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, value.length, fieldDescriptor.getLength()); } setFieldData(value); }
@Override public void setBytes(byte[] value) throws SQLException { if (value == null) { setNull(); return; } if (value.length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, value.length, fieldDescriptor.getLength()); } setFieldData(value); }
@Override protected void setBinaryStreamInternal(InputStream in, long length) throws SQLException { if (in == null) { setNull(); return; } if (length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, (int) length, fieldDescriptor.getLength()); } try { setBytes(IOUtils.toBytes(in, (int) length)); } catch (IOException ioex) { throw new TypeConversionException(BINARY_STREAM_CONVERSION_ERROR); } }
@Override protected void setBinaryStreamInternal(InputStream in, long length) throws SQLException { if (in == null) { setNull(); return; } if (length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, (int) length, fieldDescriptor.getLength()); } try { setBytes(IOUtils.toBytes(in, (int) length)); } catch (IOException ioex) { throw new TypeConversionException(BINARY_STREAM_CONVERSION_ERROR); } }
@Override protected void setCharacterStreamInternal(Reader in, long length) throws SQLException { if (in == null) { setNull(); return; } if (length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, (int) length, fieldDescriptor.getLength()); } try { setString(IOUtils.toString(in, (int) length)); } catch (IOException ioex) { throw new TypeConversionException(CHARACTER_STREAM_CONVERSION_ERROR); } } }
@Override protected void setCharacterStreamInternal(Reader in, long length) throws SQLException { if (in == null) { setNull(); return; } if (length > fieldDescriptor.getLength()) { throw new DataTruncation(fieldDescriptor.getPosition() + 1, true, false, (int) length, fieldDescriptor.getLength()); } try { setString(IOUtils.toString(in, (int) length)); } catch (IOException ioex) { throw new TypeConversionException(CHARACTER_STREAM_CONVERSION_ERROR); } } }
number == 9502))) { SQLException tmp = e; e = new DataTruncation(-1, false, false, -1, -1);
@Test public void testDataTruncationException() throws Exception { validateErrorInformation( exceptionHandler.handlePersistenceException(getPersistenceException(new DataTruncation(1, true, true, 5, 10)), new MockHttpServletResponse()), HttpStatus.BAD_REQUEST, false); }
DataTruncation dt = new DataTruncation(parameterIndex, isParameter, false,