[求助]java连接mysql出错
大家帮忙看一下这个程序有什么错误,谢谢import java.sql.*;
public class test{
public static void main(String args[]) {
Statement stmt= null;
ResultSet rs = null;
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/yqfang","root","");
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from test");
rs.first();
System.out.println(rs.getString("ID"));
System.out.println(rs.getString("NAME"));
System.out.println(rs.getString("CALL"));
System.out.println(rs.getString("Address"));
conn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
以下是它报错的信息:
java.lang.ClassNotFoundException: com.mysql.jdbc.driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at test.main(test.java:8)