Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1602 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  pb classpath ojdbc

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

pb classpath ojdbc

n°1681061
xhak
I RoX, that's all folks
Posté le 03-02-2008 à 14:15:15  profilanswer
 

Bonjour a tous,
 
Apres qlq heures de tirages de cheveux, j'en viens a vous parceque la je vois pas du tout :\
 
Alors voila, j'ai commence un programme (DatabaseAnalyser) tout con, qui utilise deux librairies: CLI & OJDBC
 
La structure de mon repertoire est ainsi:
 

DatabaseAnalyser:
bin
lib
src
 
DatabaseAnalyser/bin:
DatabaseAnalyser.class
 
DatabaseAnalyser/lib:
commons-cli-1.1.jar
ojdbc14.jar
 
DatabaseAnalyser/src:
DatabaseAnalyser.java


 
Donc rien de bien folichon... mais lorsque je le lance voila ce que j'ai:
 

C:\Documents and Settings\senx01\My Documents\My Projects\eclipse_workspace\DatabaseAnalyser>java -cp ./bin/;./lib/ojdbc14.jar;./lib/commons-cli-1.1.jar DatabaseAnalyser [args]
[...]
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@[...]
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at DatabaseAnalyser.main(DatabaseAnalyser.java:37)


 
Bref j'ai la mechante impression qu'il ne regarde pas trop dans mon ojdbc14.jar ...
 
J'utilise eclipse, et j'ai la meme erreur que lorsque j'essaye de le lancer depuis une console
 
Je suis sous winXP avec un JDK v 1.6.0_03
 
Dans DatabaseAnalyser.java, voila comment j'ouvre la connexion:

Code :
  1. databaseConnection = DriverManager.getConnection("jdbc:oracle:thin:@" + serverAddress + ":" + serverPort + ":"+ oracleSID, user, password);


 
Help  :jap:  :cry:

mood
Publicité
Posté le 03-02-2008 à 14:15:15  profilanswer
 

n°1681262
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 04-02-2008 à 09:40:39  profilanswer
 

Il te manque la ligne suivante avant la connexion:

Code :
  1. Class.forName("oracle.jdbc.driver.OracleDriver" );

Message cité 1 fois
Message édité par Harkonnen le 04-02-2008 à 09:41:12
n°1681265
xhak
I RoX, that's all folks
Posté le 04-02-2008 à 10:12:43  profilanswer
 

ah ouais ca marche, chapeau... parceque j'ai un autre programme ou je l'ai pas non plus et lui il marche. Ca sert a quoi en fait?

n°1681356
charly007
Posté le 04-02-2008 à 12:25:26  profilanswer
 

Harkonnen a écrit :

Il te manque la ligne suivante avant la connexion:

Code :
  1. Class.forName("oracle.jdbc.driver.OracleDriver" );



Je voulais faire la même réponse que toi, mais je me suis retenu après avoir lu ça :
http://java.sun.com/javase/6/docs/ [...] nager.html

Citation :


As part of its initialization, the DriverManager class will attempt to load the driver classes referenced in the "jdbc.drivers" system property. This allows a user to customize the JDBC Drivers used by their applications. For example in your ~/.hotjava/properties file you might specify:  
 
 jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver
 The DriverManager methods getConnection and getDrivers have been enhanced to support the Java Standard Edition Service Provider mechanism. JDBC 4.0 Drivers must include the file META-INF/services/java.sql.Driver. This file contains the name of the JDBC drivers implementation of java.sql.Driver. For example, to load the my.sql.Driver class, the META-INF/services/java.sql.Driver file would contain the entry:  
 
 my.sql.Driver
 Applications no longer need to explictly load JDBC drivers using Class.forName(). Existing programs which currently load JDBC drivers using Class.forName() will continue to work without modification.  


[:spamafote]
(J'ai bien lu que Class.forName continuait à fonctionner.)
 

xhak a écrit :

ojdbc14.jar
...
Je suis sous winXP avec un JDK v 1.6.0_03


J'ai un doute quant au driver que tu utilises, par rapport à ton jdk (ou vice-versa :D ) :
 
http://www.oracle.com/technology/s [...] 10201.html

Citation :

ojdbc14.jar (1,545,954 bytes) - classes for use with JDK 1.4 and 1.5


http://www.oracle.com/technology/s [...] 01040.html

Citation :

ojdbc14.jar (1,378,346 bytes) - classes for use with JDK 1.4


http://www.oracle.com/technology/s [...] 11060.html

Citation :

ojdbc6.jar (1,977,267 bytes) - Classes for use with JDK 1.6.


Message édité par charly007 le 04-02-2008 à 12:30:21
n°1681818
xhak
I RoX, that's all folks
Posté le 05-02-2008 à 10:36:47  profilanswer
 

bah mon ojdbc14.jar marche tres bien jusqu'a maintenant avec mon jdk1.6... mais je vais essayer le ojdbc6.jar pr voir :)
 
merki!

n°1681933
charly007
Posté le 05-02-2008 à 13:01:35  profilanswer
 

xhak a écrit :

bah mon ojdbc14.jar marche tres bien jusqu'a maintenant avec mon jdk1.6... mais je vais essayer le ojdbc6.jar pr voir :)
 
merki!


Mais ojdbc6.jar correspond à Oracle 11g.


Message édité par charly007 le 05-02-2008 à 13:02:03

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  pb classpath ojdbc

 

Sujets relatifs
Classpath EclipseLancement d'une JVM distante, problème de séparateur dans le classpath
[Résolu] dynamic classpath et pluginsJ2EE, WebSphere, J2C et classpath
classpath sur websphereeclipse projet classpath
Jar Classpath et ManifestTruc con mais très important avec un .classpath
Questions : Classpath et Jar executable[JAVA] CLASSPATH != cp - %CLASSPATH%
Plus de sujets relatifs à : pb classpath ojdbc


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR