Examples of InputStreamWithSize


Examples of fi.evident.dalesbred.lob.InputStreamWithSize

    private static void bindInputStream(@NotNull PreparedStatement ps, int index, @NotNull InputStream stream) throws SQLException {
        // We check whether the InputStream is actually InputStreamWithSize, for two reasons:
        //   1) the database/driver can optimize the call better if it knows the size in advance
        //   2) calls without size were introduced in JDBC4 and not all drivers support them
        if (stream instanceof InputStreamWithSize) {
            InputStreamWithSize streamWithSize = (InputStreamWithSize) stream;
            long size = streamWithSize.getSize();

            // The overload which takes 'long' as parameter was introduced in JDBC4 and is not
            // universally supported so we'll call the 'int' overload if possible.
            if (size <= Integer.MAX_VALUE)
                ps.setBinaryStream(index, streamWithSize, (int) size);
View Full Code Here

Examples of fi.evident.dalesbred.lob.InputStreamWithSize

    public void streamBlobToDatabaseByteArray() throws Exception {
        db.update("drop table if exists blob_test");
        db.update("create temporary table blob_test (id int, blob_data bytea)");

        byte[] originalData = { 25, 35, 3 };
        db.update("insert into blob_test values (1, ?)", new InputStreamWithSize(new ByteArrayInputStream(originalData), originalData.length));

        byte[] data = db.findUnique(byte[].class, "select blob_data from blob_test where id=1");
        assertThat(data, is(originalData));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.