问题
I am working on a android project with eclipse, I have a ClassNotFoundException error on:
Class.forName("com.mysql.jdbc.Driver");
I imported the jar file mysql-connector as is shown in the picture at the link: https://dl.dropboxusercontent.com/u/17360312/Untitled.png
I already put the jar file into libs folder but doesn't work.
Here is the code of the import and package statement of the java file
package com.example.appcani;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.mysql.jdbc.*;
import prog.doc.prog.io.*;
import prog.io.ConsoleOutputManager;
import prog.io.FileInputManager;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.os.Build;
回答1:
It seems you are not included jar file for mysql connectivity. you have to do this to include it
Right Click the project -- > build path -- > configure build path
In Libraries Tab press Add External Jar and Select your jar.
You can find zip for mysql here
http://dev.mysql.com/downloads/connector/j/5.0.html
来源:https://stackoverflow.com/questions/22991050/classnotfoundexception-on-class-fornamecom-mysql-jdbc-driver