Marcus Eriksson: Blob Streaming (PBMS) support in drizzle jdbc
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)");
PreparedStateme!
nt 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 chan! ge 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!
URL: http://developian.blogspot.com/2010/08/blob-streaming-pbms-support-in-drizzle.html
_______________________________________________ Mailing list: https://launchpad.net/~drizzle-discuss Post to : [email protected] Unsubscribe : https://launchpad.net/~drizzle-discuss More help : https://help.launchpad.net/ListHelp

