JNDI sous Tomcat, class not found exception
Bonjour,
J'essaie de recupérer une source de données avec JNDI sous tomcat 5.5.
Tout se passe bien, jusqu'a la connection, Je recois une class not fuund exception Cannot load JDBC driver class 'com.mysql.jdbc.Driver'.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/Persons");
//ici je recois un class not found exception
// Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
Connection con = ds.getConnection();
//alors que ce bout de code marche parfaitement bien
//Class.forName("com.mysql.jdbc.Driver");
//Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/person", "user", "pass");
Statement st = con.createStatement();
ResultSet res = st.executeQuery("select * from person"); |
pourtant le fichier jar du driver est au bon endroit, la preuve, quand je recupère la connection de la facon habituelle, cela marche parfaitement bien.
comprends pô...