Categorized | Drizzle

Marcus Eriksson: Blob Streaming (PBMS) support in drizzle jdbc

Posted on 11 August 2010 by Abidoon

I just pushed up initial support for PBMS, blob streaming for drizzle jdbc. It is not yet a complete solution for blob streaming, but you can use setBinaryStream and getBinaryStream to stream data to/from Drizzle and MySQL.

To use it, grab a snapshot from hudson (the reason the tests fail is that i have not had time to rewrite INFORMATION_SCHEMA queries to support the new I_S in Drizzle). Then follow this example to get started, important stuff is in bold

Connection connection =     DriverManager.getConnection(           "jdbc:drizzle://localhost:3307/test_units_jdbc?enableBlobStreaming=true");// inserting a blob:Statement stmt = connection.createStatement();stmt.execute("create table bstreaming1 (id int not null primary key auto_increment, test longblob)");PreparedStatement ps = connection.prepareStatement("insert into bstreaming1 values (null, ?)");// fake an inputstream with data:ByteArrayInputStream bais = new ByteArrayInputStream("HEJHEJHEJ".getBytes());ps.setBinaryStream(1, bais);ps.executeUpdate();

stmt = connection.createStatement();ResultSet rs = stmt.executeQuery("select * from bstreaming1");assertEquals(rs.next(), true);byte[] b = new byte[100];int l = rs.getBinaryStream("test").read(b);assertEquals("HEJHEJHEJ",new String(b,0,l));

To get PBMS support in drizzle you need to have a fairly recent build, and start the daemon with –plugin_add=pbms. InnoDB tables are streaming enabled, which means that any LONGBLOB column will be streamed.

Note that in the current version you will get the blob reference and not a String representation of the blob if you do a getString on the column for example, this will change when I get time to do it.

I have not yet tested against MySQL, if you have a PBMS enabled MySQL server, please let me know if it works!

View full post on Planet Drizzle

Tags | , , , , , , ,

Leave a Reply


 

August 2010
M T W T F S S
« Jul   Sep »
 1
2345678
9101112131415
16171819202122
23242526272829
3031