RETREIVING BLOBS FROM MYSQL using JDBC
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, November 11, 2002 04:46 PM

Can someone please help me..I am able to store Images in the mysql database, but I can not retrieve them Attached is my code thanks..T <%@page import="javax.swing.ImageIcon"%> <% Class.forName("org.gjt.mm.mysql.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/cordi?user=abc&password=*****"); Statement stmt = conn.createStatement(); ResultSet rsPic = stmt.executeQuery("SELECT pic FROM tbl_page_pictures WHERE page_id = 1;"); rsPic.first(); byte[] imageBytes = (byte[])rsPic.getObject("pic"); rsPic.c   More>>

Can someone please help me..I am able to store Images in

the mysql database, but I can not retrieve them

Attached is my code

thanks..T


<%@page import="javax.swing.ImageIcon"%>

<%

Class.forName("org.gjt.mm.mysql.Driver").newInstance();

Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/cordi?user=abc&password=*****");

Statement stmt = conn.createStatement();

ResultSet rsPic = stmt.executeQuery("SELECT pic FROM tbl_page_pictures WHERE page_id = 1;");

rsPic.first();


byte[] imageBytes = (byte[])rsPic.getObject("pic");

rsPic.close();


ImageIcon myimage = new ImageIcon(imageBytes);

%>







<%=myimage%>">
   <<Less

Re: RETREIVING BLOBS FROM MYSQL using JDBC

Posted By:   Richard_Rodger  
Posted On:   Tuesday, November 12, 2002 05:42 AM

Hi -

please post the Exception that occurs when you try to create
the ImageIcon object. Also, have you checked that the
byte array returned is equal to the byte array inserted?

regards,
richard


-- Jostraca: Generative Programming --
About | Sitemap | Contact