Guest User

Untitled

a guest
Aug 9th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
  2. int row=jTable1.getSelectedRow();
  3. String id= String.valueOf(model.getValueAt(jTable1.getSelectedRow(), 0));
  4. if(row >= 0){
  5. jTextField1.setText(jTable1.getValueAt(row, 0).toString());
  6. jTextField2.setText(jTable1.getValueAt(row, 1).toString());
  7. jTextField3.setText(jTable1.getValueAt(row, 2).toString());
  8. jTextField6.setText(jTable1.getValueAt(row, 3).toString());
  9.  
  10. Connection conectar=null;
  11. try{
  12. Class.forName("com.mysql.jdbc.Driver");
  13. DriverManager.getConnection("jdbc:mysql://127.0.0.1/proyecto", "root", "");
  14.  
  15. } catch (ClassNotFoundException ex) {
  16. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  17. } catch (SQLException ex) {
  18. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  19. }
  20. try{
  21. Statement s=conectar.createStatement();
  22. ResultSet rs=s.executeQuery("SELECT Nombre,Apellido,Email,Telefono,Compañia,Posicion,Foto,Nota,Ruta FROM datos WHERE id='"+id+"'");
  23. Image i=null;
  24. Blob blob=rs.getBlob("Foto");
  25. i=javax.imageio.ImageIO.read(blob.getBinaryStream());
  26. ImageIcon image = new ImageIcon(i);
  27. jLabel10.setIcon(image);
  28. jTextField10.setText(rs.getString(3));
  29.  
  30.  
  31. } catch (SQLException ex) {
  32. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  33. } catch (IOException ex) {
  34. Logger.getLogger(datos.class.getName()).log(Level.SEVERE, null, ex);
  35. }
  36.  
  37.  
  38.  
  39. }else{
  40. JOptionPane.showMessageDialog(null, "No se selecciono fila");
  41. }
  42. }
Add Comment
Please, Sign In to add comment