java.net.URLClassLoader.findClass(未知来源)

时间:2017-09-01 10:44:10

标签: java mysql jdbc datasource

我有这个代码,我用eclipse编译它

import java.sql.*;


 public class ConnectSQL {

  private static String Connect() {
   // TODO Auto-generated constructor stub
 Connection connection = null;
  String ok;
  // TODO Auto-generated method stub
  try {

Class.forName("org.mariadb.jdbc.Driver");
    connection = DriverManager.getConnection("jdbc:mariadb://192.168.0.10:3306/basededatos", "root", "passwd");
    ok ="Connection succed";
}
   catch (Exception e){
    e.printStackTrace();
 ok= "not ok";
}
 return ok;
 }

public static void main(String[] args) {
 String mensage;
    mensage = Connect(); 
  System.out.println(mensage);
 }

 }    

` 当我执行此操作时,它会给我一个错误

  

java.lang.ClassNotFoundException:org.mariadb.jdbc.Driver不行   java.net.URLClassLoader.findClass(未知来源)at   java.lang.ClassLoader.loadClass(未知来源)at   sun.misc.Launcher $ AppClassLoader.loadClass(未知来源)at   java.lang.ClassLoader.loadClass(未知来源)at   java.lang.Class.forName0(Native Method)at   java.lang.Class.forName(未知来源)at   lib.ConnectSQL.Connect(ConnectSQL.java:14)at   lib.ConnectSQL.main(ConnectSQL.java:27)

enter image description here 怎么了?

THX 此致

0 个答案:

没有答案