how to convert blob into bytearray so tat i can crate imagicon
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   karthi_keyan
Posted On:   Monday, December 3, 2007 07:48 AM

Here is my code loadset.getString("image"); byte[] bytearray; Blob blobimg=loadset.getBlob("image"); if(blobimg!= null) { BufferedInputStream bis = new BufferedInputStream(blobimg.getBinaryStream()); ByteArrayOutputStream bao = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int length = 0; while ((length = bis.read(buffer)) != -1) { JOptionPane.showMessageDialog (null,"writing image"); bao.write(buffer, 0, length); } bao.close(); bis.close(); bytearray = bao.toByteArray();    More>>


Here is my code



loadset.getString("image");

byte[] bytearray;

Blob blobimg=loadset.getBlob("image");

if(blobimg!= null)

{

BufferedInputStream bis = new BufferedInputStream(blobimg.getBinaryStream());

ByteArrayOutputStream bao = new ByteArrayOutputStream();

byte[] buffer = new byte[4096];

int length = 0;

while ((length = bis.read(buffer)) != -1)

{

JOptionPane.showMessageDialog (null,"writing image");

bao.write(buffer, 0, length);

}

bao.close();

bis.close();

bytearray = bao.toByteArray();

ImageIcon icon=new ImageIcon(bytearray);

imagelabel.setIcon(icon);

}



plz help me on this




i getng the follwing exception




Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException
at sun.jdbc.odbc.JdbcOdbcResultSet.getBlob(JdbcOdbcResultSet.java:4414)
at AdminHome.jPanel2ComponentShown(AdminHome.java:1853)
at AdminHome.access$100(AdminHome.java:11)
at AdminHome$2.componentShown(AdminHome.java:393)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:121)
at java.awt.AWTEventMulticaster.componentShown(AWTEventMulticaster.java:121)
at java.awt.Component.processComponentEvent(Component.java:5333)
at java.awt.Component.processEvent(Component.java:5281)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3968)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

   <<Less

Re: how to convert blob into bytearray so tat i can crate imagicon

Posted By:   Christopher_Koenigsberg  
Posted On:   Sunday, December 16, 2007 11:53 AM

Looks like the JDBC driver implementation you're using does not support 'getBlob'.
About | Sitemap | Contact