Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  2. at tp2.MainPage.jList1ValueChanged(MainPage.java:231)
  3. at tp2.MainPage.access$300(MainPage.java:24)
  4. at tp2.MainPage$4.valueChanged(MainPage.java:106)
  5.  
  6. private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {
  7. String npays = "null",titre= "null",nacteurPrincipal= "null",oscar= "null",realisateur= "null";
  8. try {
  9. String url = "jdbc:mysql://localhost/mycinema";
  10. Class.forName("com.mysql.jdbc.Driver");
  11. Connection connexion = DriverManager.getConnection(url, "root", "");
  12. Statement inst = connexion.createStatement();
  13. titre = jList1.getSelectedValue().toString(); //LINE 231
  14. ResultSet resultat = inst.executeQuery("SELECT * FROM film WHERE titre = '" + titre + "'");
  15. while (resultat.next()) {
  16. npays = resultat.getString("npays");
  17. realisateur = resultat.getString("realisateur");
  18. nacteurPrincipal = resultat.getString("nacteurPrincipal");
  19. oscar = resultat.getString("oscar");
  20. }
  21. resultat = inst.executeQuery("SELECT * FROM pays WHERE npays =" + npays);
  22. while (resultat.next()) {
  23. npays = resultat.getString("nom");
  24. }
  25.  
  26. resultat = inst.executeQuery("SELECT * FROM acteur WHERE nacteur =" + nacteurPrincipal);
  27. while (resultat.next()) {
  28. nacteurPrincipal = resultat.getString("prenom") + resultat.getString("nom");
  29. }
  30.  
  31. jTextArea3.setText(titre + " : un film par " + realisateur + "n" + npays);
  32. } catch (ClassNotFoundException ex) {
  33. Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
  34. } catch (SQLException ex) {
  35. Logger.getLogger(MainPage.class.getName()).log(Level.SEVERE, null, ex);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement