A voir également:
- Erreur ODBC en java
- Erreur 0x80070643 - Accueil - Windows
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel football - Télécharger - Jeux vidéo
- Java apk - Télécharger - Langages
- Iptv erreur de lecture - Forum TV & Vidéo
9 réponses
Salut,
ça veut dire que ta fermé ton resultset avec la fin des traitements...
exemple de code qui marche :
String requete = "Select * from "+$CLIENT+" order by client;";
Connection c = getConnection();
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery(requete);
while(rs.next()) {
String cl = rs.getString("client");
String adr = rs.getString("adresse");
}
rs.close();
stmt.close();
closeConnection(c);
}
catch (SQLException e){
System.out.println("Ici");
System.out.println(e);
}
ça veut dire que ta fermé ton resultset avec la fin des traitements...
exemple de code qui marche :
String requete = "Select * from "+$CLIENT+" order by client;";
Connection c = getConnection();
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery(requete);
while(rs.next()) {
String cl = rs.getString("client");
String adr = rs.getString("adresse");
}
rs.close();
stmt.close();
closeConnection(c);
}
catch (SQLException e){
System.out.println("Ici");
System.out.println(e);
}
jé tt fé , mé toujours la mém erreur
voici la partie de géstion de BD dans ma classe, si tu peu mcorrigé jtenseré reconnaison:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:Techno";
Connection conn = DriverManager.getConnection(url,"","");
Statement stat = conn.createStatement();
ResultSet result= stat.executeQuery("select Nom from Emplacement where Nom='"+d+"'");
if(!result.next()){
JOptionPane.showMessageDialog(null, "Emplacement non existant!","",JOptionPane.WARNING_MESSAGE);
}
else{
ResultSet r= stat.executeQuery("select * from Emplacement ");
while(r.next()){
ResultSet rest= stat.executeQuery("select user from e"+r.getString(2)+" where id_prod='"+c+"'");
if(rest.next()){
JOptionPane.showMessageDialog(null, "Cet identifiant existe déjà, veuillez le changer","",JOptionPane.WARNING_MESSAGE);
}
rest.close();
}
stat.execute("insert into e"+d+" values ('"+c+"','"+b+"','"+a+"')");
JOptionPane.showMessageDialog(null, "Ajout réussit!","",JOptionPane.WARNING_MESSAGE);
dispose();
new Menu().setVisible(true);
r.close();
}
result.close();
stat.close();
conn.close();
}
voici la partie de géstion de BD dans ma classe, si tu peu mcorrigé jtenseré reconnaison:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:Techno";
Connection conn = DriverManager.getConnection(url,"","");
Statement stat = conn.createStatement();
ResultSet result= stat.executeQuery("select Nom from Emplacement where Nom='"+d+"'");
if(!result.next()){
JOptionPane.showMessageDialog(null, "Emplacement non existant!","",JOptionPane.WARNING_MESSAGE);
}
else{
ResultSet r= stat.executeQuery("select * from Emplacement ");
while(r.next()){
ResultSet rest= stat.executeQuery("select user from e"+r.getString(2)+" where id_prod='"+c+"'");
if(rest.next()){
JOptionPane.showMessageDialog(null, "Cet identifiant existe déjà, veuillez le changer","",JOptionPane.WARNING_MESSAGE);
}
rest.close();
}
stat.execute("insert into e"+d+" values ('"+c+"','"+b+"','"+a+"')");
JOptionPane.showMessageDialog(null, "Ajout réussit!","",JOptionPane.WARNING_MESSAGE);
dispose();
new Menu().setVisible(true);
r.close();
}
result.close();
stat.close();
conn.close();
}
La doc java dit ça a propos de l'interface Statement :
By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.
By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:Techno";
Connection conn = DriverManager.getConnection(url,"","");
Statement stat = conn.createStatement();
ResultSet result= stat.executeQuery("select Nom from Emplacement where Nom='"+d+"'");
if(!result.next()){
JOptionPane.showMessageDialog(null, "Emplacement non existant!","",JOptionPane.WARNING_MESSAGE);
}
else{
Statement stat2 = conn.createStatement();
ResultSet r= stat2.executeQuery("select * from Emplacement ");
while(r.next()){
Statement stat3 = conn.createStatement();
ResultSet rest= stat3.executeQuery("select user from e"+r.getString(2)+" where id_prod='"+c+"'");
if(rest.next()){
JOptionPane.showMessageDialog(null, "Cet identifiant existe déjà, veuillez le changer","",JOptionPane.WARNING_MESSAGE);
}
rest.close();
stat3.close();
}
stat.execute("insert into e"+d+" values ('"+c+"','"+b+"','"+a+"')");
JOptionPane.showMessageDialog(null, "Ajout réussit!","",JOptionPane.WARNING_MESSAGE);
dispose();
new Menu().setVisible(true);
r.close();
stat2.close();
}
result.close();
stat.close();
conn.close();
String url="jdbc:odbc:Techno";
Connection conn = DriverManager.getConnection(url,"","");
Statement stat = conn.createStatement();
ResultSet result= stat.executeQuery("select Nom from Emplacement where Nom='"+d+"'");
if(!result.next()){
JOptionPane.showMessageDialog(null, "Emplacement non existant!","",JOptionPane.WARNING_MESSAGE);
}
else{
Statement stat2 = conn.createStatement();
ResultSet r= stat2.executeQuery("select * from Emplacement ");
while(r.next()){
Statement stat3 = conn.createStatement();
ResultSet rest= stat3.executeQuery("select user from e"+r.getString(2)+" where id_prod='"+c+"'");
if(rest.next()){
JOptionPane.showMessageDialog(null, "Cet identifiant existe déjà, veuillez le changer","",JOptionPane.WARNING_MESSAGE);
}
rest.close();
stat3.close();
}
stat.execute("insert into e"+d+" values ('"+c+"','"+b+"','"+a+"')");
JOptionPane.showMessageDialog(null, "Ajout réussit!","",JOptionPane.WARNING_MESSAGE);
dispose();
new Menu().setVisible(true);
r.close();
stat2.close();
}
result.close();
stat.close();
conn.close();