0
我试图插入一个图像(.jpg格式)和音频文件(.mp3格式)到MySQL数据库。我失败了。存储图像,音频文件到Java数据库与Java
我已经使用MEDIUMBLOB
作为两个列的数据类型。任何人都可以帮忙
String INSERT_PICTURE = "INSERT INTO pictures(idpictures,photo) VALUES (?,?)";
File file = new File("c:/new/1.jpg");
fis = new FileInputStream(file);
pst = conn.prepareStatement(INSERT_PICTURE);
pst.setInt(1, 67);
pst.setBinaryStream(2, fis, (int) file.length());
pst.executeUpdate();
conn.commit();
MEDIUMBLOB用于图像和音频文件。 image_id或audio_id保持为int。我在FileInputStream出现错误,但我提到了FileNotFoundException。它不起作用。我无法将图像插入数据库。如何将图像或音频文件插入数据库。 – MBK 2012-03-07 22:47:36