Bonjour,

Sous JDev j'ai crée un programme qui permet l'affichage d'une table.

Voici mon programme :
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
package sr.model;
import java.sql.*;
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
 
public class Class1
{
    public Class1() throws NamingException, ClassNotFoundException {
        try
        {
            Context ic = new InitialContext();
            DataSource ds = (DataSource)ic.lookup("jdbc/srconnDS");
            Connection c = ds.getConnection();
            Statement st=c.createStatement();
            ResultSet rs=st.executeQuery("select * from users " );
            while(rs.next())
            {
                System.out.println(rs.getString(2));
            }
            c.close();
        }
        catch (SQLException sqle)
        {
            System.out.println("Erreur sql:"+sqle);
        }
    }
 
    public static void main(String [] args) throws NamingException,    ClassNotFoundException {
        Class1 test = new Class1();
    }
}
Au niveau de la compilation : pas de problème
Au moment de l'exécution, il m'affiche le message suivant :
Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
merci de votre aide