那我随便说说吧.
我在mysql里建了个表,有个字段是blod型的,
我向它插入图片文件,
可是就弹出了java.sql.SQLException: Error reading from InputStream java.io.IOException
这样的错误请问向数据库插入大文件要注意点什么呢?一下为我插入数据的注意代码:sql:
create table student (
//....
img blob)java:
String imgPath=path; //path为传入的参数
//...
File file = new File(imgPath);
int length = (int) file.length();
InputStream fin = new FileInputStream(file);//...
ps.setBlob(7, fin); // 这句和下面的都试过了.
//ps.setBinaryStream(7, fin, length); // 这句和上面的也试过了. 结果都是不行,都在这里抛出了异常
请大家帮忙看看,
还有,上面那里也不知道是用
ps.setBlob(7, fin);还是用ps.setBinaryStream(7, fin, length);比较好..?
我在mysql里建了个表,有个字段是blod型的,
我向它插入图片文件,
可是就弹出了java.sql.SQLException: Error reading from InputStream java.io.IOException
这样的错误请问向数据库插入大文件要注意点什么呢?一下为我插入数据的注意代码:sql:
create table student (
//....
img blob)java:
String imgPath=path; //path为传入的参数
//...
File file = new File(imgPath);
int length = (int) file.length();
InputStream fin = new FileInputStream(file);//...
ps.setBlob(7, fin); // 这句和下面的都试过了.
//ps.setBinaryStream(7, fin, length); // 这句和上面的也试过了. 结果都是不行,都在这里抛出了异常
请大家帮忙看看,
还有,上面那里也不知道是用
ps.setBlob(7, fin);还是用ps.setBinaryStream(7, fin, length);比较好..?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货