Bonsoir,
Voici mon code:
qui me génère ce qui suit:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 public ArrayList<String> getAllAdmins() { ArrayList<String> list = null; query = "SELECT login FROM administrators"; try { resultSet = statement.executeQuery(query); while(resultSet.next()) { list.add(resultSet.getString("login")); } }catch(SQLException e) { e.printStackTrace(); } return list; }
Pour une raison que j'ignore, cette erreur survient donc quand on veut ajouter le string issus du resultSet dans l'ArrayList. Le string est bon car j'avais fais un test en l'affichant sur la sortie standart et j'avais bien ce que je voulais avoir. Il y a 11 rows pour info.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at db.Administrators.getAllAdmins(Administrators.java:56) at graphical.admins.GetUsersList.initialize(GetUsersList.java:104) at graphical.admins.GetUsersList.<init>(GetUsersList.java:85) at graphical.admins.AdminHome$5.actionPerformed(AdminHome.java:169) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.AbstractButton.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Si quelqu'un a une idée pour ce problème je suis preneur.
Bonne soirée
Partager