Sun.jdbc.odbc.JdbcOdbcDriver => ClassNotFoundException

Résolu
alonsyl Messages postés 348 Date d'inscription mardi 6 avril 2004 Statut Membre Dernière intervention 6 novembre 2008 - 8 mars 2006 à 11:40
 zahra93 - 20 mars 2013 à 21:12
bonjour,

afin d'interroger une BDD access dans une de mes applets, j'utilise la commande "Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();". tout fonctionne normalement dans eclipse (les drivers sont trouve et ma BDD est interrogee) mais ca plante lorsque je mets mon "*.class" a la racine de ma page web et que je tente charger mon applet (j'ai egalement essaye avec une archive jar).

j'ai verifie et le prog plante sur Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();.
le msg d'erreur est : ClassNotFoundException

que ce passe passe t'il ? pourquoi eclipse ne joint pas les drivers odbc a mon jar ? comment corriger ce probleme ?

(j'ai de deja joints java.sql.* a mon jar en le dezipant et apres avoir transforme tous les *.java en *.class mais ca n'a rien resolu ...)

merci a vous,

alonsyl
A voir également:

14 réponses

Twinuts Messages postés 5374 Date d'inscription dimanche 4 mai 2003 Statut Modérateur Dernière intervention 3 mars 2023 111
10 mars 2006 à 16:12
Salut,



ralala fais un effort :)



apres un copier collé de

java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc

dans la zone de recherche de google je suis tombé sur cette page java.lang.RuntimePermission+accessClassInPackage.sun.jdbc.odbc&start=0&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official ici

et le premier lien de cette courte recherche me dirige sur le site de sun ici ensuite feignasse comme je suis je fais Ctrl+f dans mon firefox et dans la zone de recherche je colle

java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc

et la je tombe sur ce petit paragraphe




Reading a Stack Trace:
If the DbaOdbAppl.java applet
is launched without a policy file, the following stack trace
is generated when the end user clicks the
Click Me

button.



java.security.AccessControlException: access denied
(java.lang.RuntimePermission
accessClassInPackage.sun.jdbc.odbc )




The first line in the above stack trace tells you access is denied.
This means this stack trace was generated because the applet tried to
access a system resource without the proper permission. The second
line means you need a
RuntimePermission
that gives
the applet access to the
sun.jdbc.odbc
package.
This package provides the JDBC-ODBC bridge functionality to the
Java1 virtual machine (VM).




You can use Policy tool to create the policy file you need,
or you can create it with an ASCII editor. Here is the policy
file with the permission indicated by the stack trace:



grant {
permission java.lang.RuntimePermission
"accessClassInPackage.sun.jdbc.odbc";
};




Run the applet again, this time with a policy file named
DbaOdbPol
that has the above permission in it:



appletviewer -J-Djava.security.policy =DbaOdbPol
DbaOdb.html




You get a stack trace again, but this time it is a different
error condition.



java.security.AccessControlException:
access denied (java.lang.RuntimePermission
file.encoding read)




The stack trace means the applet needs read permission to the encoded
(binary) file.
Here is the
DbaOdbPol
policy file with the permission
indicated by the stack trace added to it:



<!-- BEGIN VCD7 CODE SAMPLE COMPONENT -->
grant {
permission java.lang.RuntimePermission
"accessClassInPackage.sun.jdbc.odbc";
permission java.util.PropertyPermission
"file.encoding", "read";
};





<!-- END VCD7 CODE SAMPLE COMPONENT -->

Run the applet again. If you use the above policy file
with the Runtime and Property permissions indicated, it
works just fine.



appletviewer -J-Djava.security.policy=DbaOdbPol
DbaOdb.html








Vive google c'est un ami très fidèle







WORA
3