com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError
- From: "pjvleeuwen@xxxxxxxxx" <pjvleeuwen@xxxxxxxxx>
- Date: Tue, 02 Oct 2007 15:25:46 -0000
Hi all,
I'm quite new to all jdbc, but so far working with resultset's over
SQL seemed easy so far, but I'm having some problems writing a blob to
the database.
What I try to do is two steps:
1. read an image from the web and write it to a blob
2. read the blob and display it as an image
I did the same thing before without trying to write to the blob, but I
want to store the images in DB because the only stay on the web for a
couple of weeks.
Googling for UpdatableResultset updateBlob AbstractMethodError gets me
lost. Any help is well appreciated.
By the way: the image is 18257 bytes and max_allowed_packet of MySQL
is 1048576
Anyone? thanx
### stderr output ###
Exception in thread "main" java.lang.AbstractMethodError:
com.mysql.jdbc.UpdatableResultSet.updateBlob(Ljava/lang/String;Ljava/
io/InputStream;)V
at nl.vanleeuwenwilmot.housing.search.woonnet.app.Test.main(Test.java:
52)
######
### java class ###
package nl.vanleeuwenwilmot.housing.search.woonnet.app;
import java.awt.BorderLayout;
import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Test {
/**
* @param args
* @throws IOException
* @throws SQLException
*/
public static void main(String[] args) throws IOException,
SQLException {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///woonnet",
"root",
"<A2Cc|4w");
} catch (InstantiationException e) {
e.printStackTrace();
System.exit(1);
} catch (IllegalAccessException e) {
e.printStackTrace();
System.exit(1);
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.exit(1);
}
Statement updatestmt =
con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
ResultSet resultset = updatestmt
.executeQuery("SELECT * FROM `image` WHERE `house_id`
= 1");
resultset.first();
// fine till here
resultset.updateBlob("image", new URL( // <==== line 52
"http://www.woonnet-haaglanden.nl/library/fotos/
18/12845.jpg")
.openStream());
resultset.updateRow();
resultset.close();
updatestmt.close();
Statement readstmt = null;
readstmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
resultset = readstmt.executeQuery("SELECT * FROM `image` " //
+ "WHERE `house_id` = 1;");
resultset.first();
InputStream theimage =
resultset.getBlob("image").getBinaryStream();
Image image = ImageIO.read(theimage);
// Use a label to display the image
JFrame frame = new JFrame();
JLabel label = new JLabel(new ImageIcon(image));
frame.getContentPane().add(label, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}
######
.
- Follow-Ups:
- Re: com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError
- From: David Harper
- Re: com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError
- From: Dyreatnews
- Re: com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError
- From: Arne Vajhøj
- Re: com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError
- Prev by Date: Re: [Aaron J Tarter] Re: [comp.lang.java.databases] Derby eclipse install
- Next by Date: Re: com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError
- Previous by thread: Re: [Aaron J Tarter] Re: [comp.lang.java.databases] Derby eclipse install
- Next by thread: Re: com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError
- Index(es):