gpt4 book ai didi

java - 尝试使用Netbeans将Image添加到Mysql

转载 作者:行者123 更新时间:2023-11-29 19:13:47 25 4
gpt4 key购买 nike

我正在尝试使用 netbeans 将图像添加到数据库,但它对我不起作用这是我的代码当我转到 mysql 时,我看到那里的图像,但只是八位字节大小(BLOB - 50 o)

    String code=jTextField1.getText();
String reference=jTextField2.getText();
String nom=jTextField3.getText();
String marque=jTextField4.getText();
String dimention=jTextField5.getText();
String quantite=jTextField6.getText();
String discription=jTextPane1.getText();
String famille =jTextField7.getText();
String code_famille =jTextField10.getText();
String sousfamille=jTextField8.getText();

String requete="insert into piece (Code_Piece,Reference,Nom_P,Mark_P,Dimention,Quantite,Categorie,Type,Discription,Image) VALUES('"+
code+"','"+reference+"','"+nom+"','"+marque+"','"+dimention+"','"+quantite+"','"+Cate+"','"+Type+"','"+discription+"','"+imgPath+"')";

最佳答案

我的类(class)里也有这段代码

JFileChooser file = new JFileChooser();
file.setCurrentDirectory(new File(System.getProperty("user.home")));
FileNameExtensionFilter filter = new
FileNameExtensionFilter("*.images","jpeg","jpg","png","bmp");
file. addChoosableFileFilter(filter);
int result = file.showSaveDialog(null);
if (result == JFileChooser.APPROVE_OPTION)
{
File selectedFile = file.getSelectedFile();
String path = selectedFile.getAbsolutePath();
lbl_image.setIcon(ResizeImage(path, null));
imgPath = path;
}

else if (result == JFileChooser.CANCEL_OPTION){
System.out.println("No Fille Selected");
}

关于java - 尝试使用Netbeans将Image添加到Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42876963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com