Toujour le fameux mesg d'erreur:Exception in

Fermé
manel - 28 juin 2010 à 17:25
Bonjour,



dsl jé fait une erreur ma calsse main elle contien:
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.io.IOException;

public class Esa {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Comm bdd= new Comm();
//Programme p =new Programme();
//p.affichage();
Lot l= new Lot();
String lop="lotttttttttt";
l.ajout(lop);

}

}
et la classe conexion contient
import java.sql.*;
public class Comm {

static Connection c;
static Statement stat;

Comm() {



try{
Class.forName("org.postgresql.Driver");
}catch(ClassNotFoundException e){System.err.print(e);}

try{
c = DriverManager.getConnection("jdbc:postgresql://localhost/tpp","postgres","amina");
stat = c.createStatement();

}catch(SQLException sqles){}




}


} et pour la methode:

public class Lot {
static String nom ;
static String localisation ;



static String affi(){
try {
String requete ="select * from lot";
//ResultSet resultat = ConnecxionBdd.stat.executeQuery(requete);
ResultSet resultat = Comm.stat.executeQuery(requete);
}catch (SQLException sqles){System.err.print(sqles);}
return nom;
}



}
je travail aussi avec le postgresql. et l'erreur est Exception in thread "main" java.lang.NullPointerException
at Lot.affi(Lot.java:27)
at Esa.main(Esa.java:21)