Bonjour,

Dans le but de familiariser en java web, je me suis confronté à des problèmes qui m'ont empêché d'avancer. je veux connecter mon application avec la base postgresql je trouve quelques exceptions que j'ai cherché partout sur le net mais je n'ai pas trouvé une solution, c'est pour quoi je me suis retourné vers vous pour trouver une solution si possible.

alors pour mieux voir le problème, je vais poster les classes et les diffrentes configurations que je fais:

l'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
java.lang.ClassNotFoundException: org.postgresql.Driver
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.ifi.p22.Dao.SingletonConnection.<clinit>(SingletonConnection.java:11)
	at com.ifi.p22.Dao.LivreDaoImpl.AjoutLivre(LivreDaoImpl.java:24)
	at com.ifi.p22.Dao.TestMetier.main(TestMetier.java:11)
Exception in thread "main" java.lang.NullPointerException
	at com.ifi.p22.Dao.LivreDaoImpl.AjoutLivre(LivreDaoImpl.java:26)
	at com.ifi.p22.Dao.TestMetier.main(TestMetier.java:11)
Nom : tablelivre.png
Affichages : 1094
Taille : 55,1 Ko


la classe "Livre"
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
package com.ifi.p22.Dao;
 
import java.io.Serializable;
 
public class Livre implements Serializable {
 
	private String idLivre;
	private String titre;
	private String isbn;
	private String dateEdit;
	private String nomAut;
	public Livre(String idLivre, String titre, String isbn, String dateEdit, String nomAut) {
		super();
		this.idLivre = idLivre;
		this.titre = titre;
		this.isbn = isbn;
		this.dateEdit = dateEdit;
		this.nomAut = nomAut;
	}
	public Livre() {
		super();
		// TODO Auto-generated constructor stub
	}
	public String getIdLivre() {
		return idLivre;
	}
	public void setIdLivre(String idLivre) {
		this.idLivre = idLivre;
	}
	public String getTitre() {
		return titre;
	}
	public void setTitre(String titre) {
		this.titre = titre;
	}
	public String getIsbn() {
		return isbn;
	}
	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}
	public String getDateEdit() {
		return dateEdit;
	}
	public void setDateEdit(String dateEdit) {
		this.dateEdit = dateEdit;
	}
	public String getNomAut() {
		return nomAut;
	}
	public void setNomAut(String nomAut) {
		this.nomAut = nomAut;
	}
 
 
}
la classe connection
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
 
package com.ifi.p22.Dao;
 
import java.sql.Connection;
import java.sql.DriverManager;
 
public class SingletonConnection {
	private static Connection connection;
	static{
 
		try {
			Class.forName("org.postgresql.Driver");
			connection=DriverManager.getConnection
					("jdbc:postgresql://localhost:5432/catProduit","postgres","HbEr9785");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 
	public static Connection getConnection() {
		return connection;
	}
 
}
la classe test

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
 
package com.ifi.p22.Dao;
 
import com.ifi.p22.Metier.ILivreMetier;
import com.ifi.p22.Metier.LivreMetierImpl;
 
public class TestMetier {
 
	public static void main(String[] args) {
		ILivreDao metier =new LivreDaoImpl();
		//metier.addproduit(new Produit("REF05","AA",878,9));
	metier.AjoutLivre(new Livre("REF05","AA","ISBN1","12/02/2014","Vin"));
	metier.AjoutLivre(new Livre("REF06","BB","ISBN2","12/02/1814","Buo"));
 
	}
 
}
si nécessaire les interfaces, après avoir demander.

voilà un peu mon problème.

NB: j'utilise spring

Merci d'avance

cordialement