Quelqu'un peut me dire pourquoi ce code ne m'evoi que des "null" ?
Je travaille avec postgres
Alors que celui-ci fonctionne :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 public ArrayList getListeEmploye(){ try { ResultSet result = state.executeQuery("SELECT * FROM employe"); while(result.next()){ Employe emp = new Employe(result.getObject(1).toString(), result.getObject(2).toString(), result.getObject(3).toString(), result.getObject(4).toString(), result.getObject(5).toString(), result.getObject(6).toString(), result.getObject(7).toString()); liste.add(emp) ; System.out.print(emp.getFonction()); //meme ici il affiche null ! } } catch (Exception e) { e.printStackTrace(); } return liste; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 public Employe getEmploye(String num){ Employe emp=new Employe(); try { ResultSet result = state.executeQuery("SELECT * FROM employe WHERE numero='"+num+"'"); while(result.next()){ emp= new emp(result.getObject(1).toString(), result.getObject(2).toString(), result.getObject(3).toString(), result.getObject(4).toString(), result.getObject(5).toString(), result.getObject(6).toString(), result.getObject(7).toString()) ; } } catch (Exception e) { e.printStackTrace(); } return emp; }
Partager