pb classpath ojdbc

pb classpath ojdbc - Java - Programmation

Marsh Posté le 03-02-2008 à 14:15:15    

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:

Reply

Marsh Posté le 03-02-2008 à 14:15:15   

Reply

Marsh Posté le 04-02-2008 à 09:40:39    

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
Reply

Marsh Posté le 04-02-2008 à 10:12:43    

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?

Reply

Marsh Posté le 04-02-2008 à 12:25:26    

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
Reply

Marsh Posté le 05-02-2008 à 10:36:47    

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

Reply

Marsh Posté le 05-02-2008 à 13:01:35    

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
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed