Netbeans 8 如何从Access数据库检索图像并在Netbeans中的Jlabel上显示
我想从access数据库中检索图像,并在netbeans中的jlabel上显示它。我在Google上搜索了很多,但是我找不到从MS Access检索图像的代码。在这件事上有人能帮我吗?我编写了以下代码,但它不起作用。这给了我错误 未找到记录Netbeans 8 如何从Access数据库检索图像并在Netbeans中的Jlabel上显示,netbeans-8,Netbeans 8,我想从access数据库中检索图像,并在netbeans中的jlabel上显示它。我在Google上搜索了很多,但是我找不到从MS Access检索图像的代码。在这件事上有人能帮我吗?我编写了以下代码,但它不起作用。这给了我错误 未找到记录 DbConn obj=new DbConn(); 字符串PatientID=getPid().getText(); String query=“从PatientRecord中选择[PatientEarImage],其中PatientID=”+PatientI
DbConn obj=new DbConn();
字符串PatientID=getPid().getText();
String query=“从PatientRecord中选择[PatientEarImage],其中PatientID=”+PatientID+”;
ResultSet rs=obj.Search(查询);
尝试
{
while(rs.next())
{
byte[]img=rs.getBytes(“PatientEarImage”);
图像图标immgg;
immgg=新图像图标();
Image im=immgg.getImage();
Image myImg=im.getScaledInstance(getUpload().getWidth(),getUpload().getHeight(),Image.SCALE\u平滑);
ImageIcon newImage=新图像图标(“PatientEarImage.jpg”);
upload.setIcon(newImage);
}
}
捕获(例外情况除外)
{
例如printStackTrace();
showMessageDialog(null,“未找到记录”);
}
试试这些代码。我还使用MS Access数据库作为后端数据库
Blob filenameBlob = rs.getBlob("picture");
byte[] content = filenameBlob.getBytes(1L, (int) filenameBlob.length());
ImageIcon AA = new ImageIcon(content);
Image BB = AA.getImage();
Image CC = BB.getScaledInstance(FRAMEBOXPIC.getWidth(), FRAMEBOXPIC.getHeight(),
java.awt.Image.SCALE_SMOOTH);
AA = new ImageIcon(CC);
FRAMEBOXPIC.setIcon(AA);
你说的“不工作”是什么意思?错误信息,错误结果,什么也没发生?这些图像存储在附件或OLEObject字段中?先生,这给了我错误“记录未找到”,图像存储在OLEObject字段中。这是否有助于我在Netbeans(Java)中工作,因此这可能在我的GUI中不起作用。