String sql ="insert into c_db (f_name,access_time,photo) values (?,?,?)";
PreparedStatement statement = conn.prepareStatement(sql);
InputStream inputStream = new FileInputStream(fblob);
Path path = Paths.get("C:/Users/Administrator/Desktop/photo/K-001.png");
BasicFileAttributes attr = Files.readAttributes(path,BasicFileAttributes.class,NOFOLLOW_LINKS);
statement.setString(1,fblob.getName());
statement.setFileTime(2,attr.lastAccessTime());
statement.setBlob(3,inputStream);
我想使用MySQL數據庫在插入鏡像文件數據(文件名,accesstime)。Java的MySQL的使用BasicFileAttributes插入鏡像文件最後訪問時間
,這是CREATETABLE
create table C_db(
image_id int(11) auto_increment,
f_name varchar(45) default null,
access_time datetime default null,
photo mediumblob,
primary key (image_id)
);
但錯誤是
"Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method setFileTime(int, FileTime) is undefined for the type PreparedStatement at jdbcExample.main(jdbcExample.java:55)"
如何解決這個問題呢? 請幫我
PreparedStatement接口沒有任何方法名爲'setFileTime();' – zombie