- 论坛徽章:
- 0
|
mysql 用jdbc在windows下能用,而在linux下就报错了,请问各位大侠能帮小弟看看嘛?
import java.sql.*;
class Mysql {
public static void main (String args []) throws SQLException {
DriverManager.registerDriver (new com.mysql.jdbc.Driver());
Connection conn = DriverManager.getConnection (
"jdbc:mysql://localhost:3306/ld", "root", "root" ;
DatabaseMetaData meta = conn.getMetaData();
System.out.println (meta.getDatabaseProductName());
System.out.println ("Connected!" ;
}
}
运行之后提示异常 如下
Exception1 :
org.gjt.mm.mysql.Driver
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at conn.<init>;(test.java:15)
at test.main(test.java:56)
Exception3 :
null
java.lang.NullPointerException
at conn.executeQuery(test.java:30)
at test.main(test.java:57)
这在windows下能运行,而在linux下也能编译通过,但运行类时就抛了异常。请各位办忙看看。先谢谢了
我认?是java或jdbc的问题 求for linux的mysql的jdbc
顺便谁说说 java连接mysql怎么配置 |
|