1 pièce(s) jointe(s)
Erreur org.sqlite.JDBC ClassNotFoundException
Bonjour,
Je souhaite développer une application java Android sous Netbeans utilisant une base SQLITE existante.
J’utilise Netbeans : 8.0.2
Mon projet est de type : Android Projet
Dans >Projet Propertie Categories -> JAR Libtrairies j’ai mis le jar sqlite-jdbc-3.8.7.jar
Pièce jointe 165106
Comme lu dans les différents forum, j’ai écrit un code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| public void connect() {
String Flag_connexion;
String NOM_BDD = " /sdcard/SQLiteMagic/Ma_Base.db");
mFile = new File(NOM_BDD);
boolean f_existe = mFile.exists();
long f_taille = mFile.length();
try {
Class.forName("org.sqlite.JDBC");
this.connection = DriverManager.getConnection("jdbc:sqlite:" + NOM_BDD);
Flag_connexion = "Connexion OK";
System.setProperty("F_CONNEXION", "1");
System.setProperty("EXP_CONNEXION", "Neant");
} catch (SQLException ex) {
this.connection = null;
Flag_connexion = "KO-1" + ex.getMessage();
System.setProperty("F_CONNEXION", "0");
System.setProperty("EXP_CONNEXION", ex.toString());
} catch (ClassNotFoundException ex) {
this.connection = null;
Flag_connexion = "KO-2 :" + ex.getMessage();
System.setProperty("F_CONNEXION", "0");
System.setProperty("EXP_CONNEXION", ex.toString());
}
System.setProperty("CONNEXION", Flag_connexion);
} |
A l’appel de ce code, Class.forName("org.sqlite.JDBC") part en ClassNotFoundException
Avec ex.getMessage() = "org.sqlite.JDBC" et ex.toString() = "java.lang.ClassNotFoundException"
La base existe bien, le debuger me donne : f_ existe = true et f_taille = 2149352.
Quelqu'un peut il me guider ?
Merci d'avance
Erreur org.sqlite.JDBC ClassNotFoundException
bonjour,
Et tout d'abord mes meilleurs vœux pour 2015.
J'ai suivi tes conseils, j'ai positionné le fichier sqlite-jdbc-3.8.7.jar dans libs de mon projet.
- Class.forName("org.sqlite.JDBC"); ne part plus en exception, c'est OK.
- mais la ligne suivante this.connection = DriverManager.getConnection("jdbc:sqlite:" + NOM_BDD); plante et génère l’exception (dans Throwable.java) :
Citation:
Couldn't load sqlitejdbc from loader dalvik.system.PathClassLoader[dexPath=/data/app/GConfAndroid.conf-64.apk,libraryPath=/data/app-lib/GConfAndroid.conf-64]: findLibrary returned null
et là je suis completement perdu ...
Pour info, j'utilise un samsung S5 mini pour le debug.