Package javax.sql.rowset.serial

Examples of javax.sql.rowset.serial.SerialBlob


      fs.close();
   
      if (fs.bytesWritten()) {
        return new BlobType(new BlobImpl(result));
      }
      return new BlobType(new SerialBlob(Arrays.copyOf(fs.getBuffer(), fs.getCount())));
    } catch (IOException e) {
      throw new TeiidProcessingException(e);
    catch (SQLException e) {
      throw new TeiidProcessingException(e);
    }
View Full Code Here


     */
    public long position(byte[] pattern, long start) throws SQLException {
      if (pattern == null) {
        return -1;
      }
        return position(new SerialBlob(pattern), start);
    }
View Full Code Here

public class TestBlobValue extends TestCase {

    public void testBlobValue() throws Exception {
        String testString = "this is test blob"; //$NON-NLS-1$
        SerialBlob blob = new SerialBlob(testString.getBytes());
       
        BlobType bv = new BlobType(blob);
        assertEquals(testString, new String(bv.getBytes(1L, (int)bv.length())));
    }
View Full Code Here

        assertEquals(testString, new String(bv.getBytes(1L, (int)bv.length())));
    }

    public void testBlobValuePersistence() throws Exception {
        String testString = "this is test clob"; //$NON-NLS-1$
        SerialBlob blob = new SerialBlob(testString.getBytes());
       
        BlobType bv = new BlobType(blob);
        String key = bv.getReferenceStreamId();
       
        // now force to serialize
View Full Code Here

  public static SerialBlob createBlob(byte[] bytes) {
    if (bytes == null) {
      return null;
    }
    try {
      return new SerialBlob(bytes);
    } catch (SQLException e) {
      throw new TeiidRuntimeException(e);
    }
  }
View Full Code Here

    }
   
    @Test public void testRuntimeTypeConversion() throws Exception {
      assertNull(DataTypeManager.convertToRuntimeType(null));
     
      assertTrue(DataTypeManager.convertToRuntimeType(new SerialBlob(new byte[0])) instanceof BlobType);
   
      //unknown type should return as same
      Object foo = new Object();
      assertEquals(foo, DataTypeManager.convertToRuntimeType(foo));
   
View Full Code Here

        String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
        assertEquals("<!--comment-->", xml);
    }
 
  @Test public void testToChars() throws Exception {
    Clob result = (Clob)helpInvokeMethod("to_chars", new Class<?>[] {DefaultDataClasses.BLOB, DefaultDataClasses.STRING}, new Object[] { new BlobType(new SerialBlob("hello world".getBytes("ASCII"))), "ASCII" }, null); //$NON-NLS-1$
    String string = result.getSubString(1, (int)result.length());
    assertEquals("hello world", string);
  }
View Full Code Here

    Blob result = (Blob)helpInvokeMethod("to_bytes", new Class<?>[] {DefaultDataClasses.CLOB, DefaultDataClasses.STRING}, new Object[] { new ClobType(new SerialClob("hello world".toCharArray())), "UTF32" }, null); //$NON-NLS-1$
    assertEquals(44, result.length()); //4 bytes / char
  }
 
  @Test public void testToChars1() throws Exception {
    Clob result = (Clob)helpInvokeMethod("to_chars", new Class<?>[] {DefaultDataClasses.BLOB, DefaultDataClasses.STRING}, new Object[] { new BlobType(new SerialBlob("hello world".getBytes("ASCII"))), "BASE64" }, null); //$NON-NLS-1$
    String string = result.getSubString(1, (int)result.length());
    assertEquals("hello world", new String(Base64.decode(string), "ASCII"));
  }
View Full Code Here

    String string = result.getSubString(1, (int)result.length());
    assertEquals("hello world", new String(Base64.decode(string), "ASCII"));
  }
 
  @Test public void testToChars2() throws Exception {
    Clob result = (Clob)helpInvokeMethod("to_chars", new Class<?>[] {DefaultDataClasses.BLOB, DefaultDataClasses.STRING}, new Object[] { new BlobType(new SerialBlob("hello world".getBytes("ASCII"))), "HEX" }, null); //$NON-NLS-1$
    String string = result.getSubString(1, (int)result.length());
    assertEquals("68656C6C6F20776F726C64", string);
  }
View Full Code Here

     * <p>Sets parameter number parameterIndex to x[], a Java array of bytes.
     * @param parameterIndex of the parameter whose value is to be set
     * @param bytes array to which the parameter value is to be set.
     */
    public void setBytes(int parameterIndex, byte bytes[]) throws SQLException {
      setObject(parameterIndex, new SerialBlob(bytes));
    }
View Full Code Here

TOP

Related Classes of javax.sql.rowset.serial.SerialBlob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.