Bonjour,

J'essai de me connecter à Postgresl via java:




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
package JdbcTest; 
 
import javax.sql.*; 
import java.io.FileReader; 
import java.sql.*; 
 
 
public class JdbcTestPostgres 
{ 
 
    public static void main (String args[]) 
        throws Exception 
    { 
   String URL = "jdbc:postgresql://localhost:5432/essai";      
   String driver ="org.postgresql.Driver"; 
   Connection      con = null; 
 
try { 
    Class.forName(driver); //.newInstance(); 
      System.out.println("*** Driver OK ***"); 
    } 
    catch (Exception e) { 
      System.out.println("ERREUR: Chargement impossible.\n" + e); 
    } 
 
    System.out.println("-> Connexion a la base..."); 
    try { 
   con = DriverManager.getConnection(URL,"postgres","70103karate"); 
//Statement      stmt = con.createStatement(); 
      System.out.println("*** Connexion OK ***"); 
   } 
   catch(SQLException e) { 
      System.out.println("ERREUR: Connexion impossible."); 
      while (e != null) { 
        System.out.println("Message: " + e.getMessage()); 
        System.out.println("Etat: " + e.getSQLState()); 
        System.out.println("Code Erreur: " + e.getErrorCode() + "\n"); 
        e = e.getNextException(); 
   } 
    } 
   finally { 
       try { con.close();} catch(Exception e) {} 
   } 
} 
}

et j'ai l'erreur suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
java.lang.NoClassDefFoundError: java/sql/Savepoint 
   at org.postgresql.Driver.connect(Driver.java:235) 
   at java.sql.DriverManager.getConnection(DriverManager.java:543) 
   at java.sql.DriverManager.getConnection(DriverManager.java:194) 
   at JdbcTest.JdbcTestPostgres.main(JdbcTestPostgres.java:34) 
Exception in thread "main"



Merci