Guest User

Untitled

a guest
Dec 14th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. java.sql.Connection conexion=DriverManager.getConnection("jdbc:mysql://localhost/bdpro","root" ,"");
  2. java.sql.Statement comando=conexion.createStatement();
  3. ResultSet registro = comando.executeQuery("select nombre,precio,fecha,foto from tablapro where id="+textField.getText());
  4. if (registro.next()==true) {
  5.  
  6. textField_1.setText(registro.getString("nombre"));
  7. textField_2.setText(registro.getString("precio"));
  8. Date Estado = registro.getDate("fecha");
  9. dateChooser.setDate(Estado);
  10.  
  11.  
  12. Blob Blob = (Blob) registro.getBlob(4);
  13. byte[] imageByte = Blob.getBytes(1, (int) Blob.length());
  14. InputStream is=new ByteArrayInputStream(imageByte);
  15. BufferedImage imag=ImageIO.read(is);
  16. Image image=Toolkit.getDefaultToolkit().createImage(imageByte);
  17.  
  18.  
  19. ImageIcon icono = new ImageIcon(image);
  20. lblFoto.setIcon(TamañoImg(null,icono));
  21.  
  22.  
  23. }
  24.  
  25.  
  26. conexion.close();
  27. } catch(SQLException | IOException ex){
  28. JOptionPane.showMessageDialog(null, ex.getMessage());
  29. }
Add Comment
Please, Sign In to add comment