Class.forName(“ com.mysql.jdbc.Driver”)上的ClassNotFoundException; [英] ClassNotFoundException on Class.forName("com.mysql.jdbc.Driver");

查看:139
本文介绍了Class.forName(“ com.mysql.jdbc.Driver”)上的ClassNotFoundException;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipse开发一个android项目,我在以下位置遇到ClassNotFoundException错误:

I am working on a android project with eclipse, I have a ClassNotFoundException error on:

Class.forName("com.mysql.jdbc.Driver");

我导入了jar文件mysql-connector,如链接中的图片所示:
https://dl.dropboxusercontent.com/u/17360312/Untitled.png

I imported the jar file mysql-connector as is shown in the picture at the link: https://dl.dropboxusercontent.com/u/17360312/Untitled.png

我已经将jar文件放到libs文件夹中,但是不起作用。

I already put the jar file into libs folder but doesn't work.

这是代码java文件的导入和打包语句

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;


推荐答案

似乎您的MySQL连接不包含jar文件。您必须执行此操作以包含它

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

在库选项卡中,按添加外部Jar,然后选择您的jar。

In Libraries Tab press Add External Jar and Select your jar.

您可以在此处找到mysql的zip

You can find zip for mysql here

http://dev.mysql.com/downloads/connector/j/5.0 .html

这篇关于Class.forName(“ com.mysql.jdbc.Driver”)上的ClassNotFoundException;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆