简体   繁体   中英

Loading file to database from java code

st4.executeUpdate("insert into model (category,subcategory,modelname,taxid,image,filename)
values ('"+forCat+"','"+sel+"','"+model+"','"+taxid+"',load_file('"+f.getAbsolutPath()+"'),'"+f.getName()+"')");

Query runs but file is not uploaded

Also tried

GRANT FILE ON *.* TO 'root'@'localhost';

Here f is a file object getting from file chooser.

Query runs on console without any error but file is not uploaded and image field is null.

insert into model (category,subcategory,modelname,taxid,image,filename) values ('NEW','NEWSUB','CRAZY TEST2','5',load_file('D:\Users\sams\Desktop\image006.jpg'),'image006.jpg');
insert into model 
   (category,subcategory,modelname,taxid,image,filename) 
values
  ('SSAS','SSAS SUB','CRAZY 10','5',load_file('D:\\Users\\sams\\Desktop\\image006.jpg'),'image006.jpg');

It works well..

I ran into the same issue with java code and I removed the load_file and that fixed the issue

INSERT INTO IMAGES_CONTENT(file_name, extension, type, content, version) VALUES ('ICN-C0419','PNG','figure', 'C:\workspace\ICN1.svg', 1.00);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM