Précédent   Forum des professionnels en informatique > Java > Général Java > JDBC
JDBC Forum d'entraide sur l'API JDBC (Java Database Connectivity) et l'accès aux bases de données. Avant de poster -> FAQ JDBC
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 23/01/2012, 15h13   #1
Futur Membre du Club
 
Inscription : octobre 2007
Messages : 66
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 66
Points : 16
Points : 16
Par défaut Erreur "Cannot create JDBC driver of class '' for connect URL 'null' [] No suitable driver"

Bonjour,

Alors j'ai un souci de connexion JDBC. J'ai pourtant suivi les doc tomcat, épluché les forums ... rien n'y fait : je bloque.

Mon environnement :

tomcat 6.0.35
jdk 1.5
eclipse
oracle 9i


Ci-dessous mon dev :

[CATALINA_HOME]/conf/context.xml
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
 
<Context>
 
    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
 
    <!-- Specify a JDBC datasource -->
    <Resource name="myDB" auth="Container" type="javax.sql.DataSource"
                    driverClassName="oracle.jdbc.OracleDriver"
                    url="jdbc:oracle:thin:@machine:port:sid" 
                    username="user" password="mdp"
                    maxActive="20" maxIdle="10" maxWait="-1" />
</Context>
WEB-INF/web.xml
Code :
1
2
3
4
5
6
7
8
9
10
11
 
<web-app ...>
...
    <!-- Connection BDD -->
    <resource-ref>
        <description>Oracle Datasource</description>
        <res-ref-name>myDB</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>
BDManager.java
Code :
1
2
3
4
5
6
7
 
...
    try {
        Context ctx = ctx = new InitialContext();
        Context envCtx  = (Context)ctx.lookup("java:/comp/env/");
        DataSource dataSource = (DataSource) envCtx.lookup("myDB");
...
Ci-dessous mon erreur :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Exception Chainée : org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
Cannot create JDBC driver of class '' for connect URL 'null'Pile d'appel de l'exception chainée : org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
	at com.bouygtel.esav.util.db.BDManager.getConnection(BDManager.java:159)
	at com.bouygtel.esav.util.db.DBControler.pexecute(DBControler.java:88)
	at com.bouygtel.esav.util.db.DBControler.execute(DBControler.java:149)
	at com.bouygtel.esav.util.db.AbstractDAO.execute(AbstractDAO.java:99)
...
Caused by: java.sql.SQLException: No suitable driver
	at java.sql.DriverManager.getDriver(DriverManager.java:243)
	at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
	... 32 more
Explication :
Quand je déploie mon appli, mon datasource est initialisé n'est pas renseigné avec les valeurs du context.xml.
L'erreur intervient lors d'une tentative de connection.

J'ai tenté de rajouter "jdbc/" dans le dataSourceName => même erreur.
J'ai tenté de faire la config dans server.xml puis de faire un resourceLink dans context.xml => même erreur.
J'ai tenté de mettre "oracle.jdbc.driver.OracleDriver" dans le driverClassName => même erreur.
Par contre, cela marche quand je met le context.xml dans META-INF (ce que je ne veux pas)

Pour précision, j'ai bien mis le jar ojdbc5.jar dans le répertoire [CATALINA_HOME]/lib.

Quelqu'un aurait-il une idée ?

Merci
gdev7 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/01/2012, 16h07   #2
Futur Membre du Club
 
Homme
Consultant informatique
Inscription : janvier 2012
Messages : 22
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Consultant informatique
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : janvier 2012
Messages : 22
Points : 19
Points : 19
Salut gdev7

une petite visite sur cette page:

http://tomcat.apache.org/tomcat-5.5-...g/context.html


Citation:
Context elements may be explicitly defined:

- In the $CATALINA_HOME/conf/context.xml file: the Context element information will be loaded by all webapps.
- In the $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host.
- In individual files (with a ".xml" extension) in the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml) extension will be used as the context path. Multi-level context paths may be defined using #, e.g. foo#bar.xml for a context path of /foo/bar. The default web application may be defined by using a file called ROOT.xml.
- Only if a context file does not exist for the application in the $CATALINA_HOME/conf/[enginename]/[hostname]/; in an individual file at /META-INF/context.xml inside the application files. If the web application is packaged as a WAR then /META-INF/context.xml will be copied to $CATALINA_HOME/conf/[enginename]/[hostname]/ and renamed to match the application's context path. Once this file exists, it will not be replaced if a new WAR with a newer /META-INF/context.xml is placed in the host's appBase.
- inside a Host element in the main conf/server.xml
celestin62 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/01/2012, 11h54   #3
Futur Membre du Club
 
Inscription : octobre 2007
Messages : 66
Détails du profil
Informations forums :
Inscription : octobre 2007
Messages : 66
Points : 16
Points : 16
Merci pour ton retour celestin mais rien de tout cela ne marchait et pour cause ... j'utilise le plugin WTP qui met en fait les fichiers de conf tomcat dans un autre répertoire.
Du coup, mes modifs n'étaient pas prises en compte.

J'ai donc reporté celles-ci dans le context.xml concerné ... it's work !!!

Youpiyou, tant de temps perdu pour ça, un peu rageant mais soulagé !

J'espère que ce topic aidera quand même des gens,

Bonne journée
gdev7 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h11.


 
 
 
 
Partenaires

Hébergement Web