源码:(用的eclipse)
package com.renyi.demo;public class JDBCDemo { public static void main(String[] args) throws ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
}}
编译时不出错,执行后报错:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
com.mysql.jdbc.Driver cannot be resolved to a variable at com.renyi.demo.JDBCDemo.main(JDBCDemo.java:7)
驱动包我也导入了,
package com.renyi.demo;public class JDBCDemo { public static void main(String[] args) throws ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
}}
编译时不出错,执行后报错:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
com.mysql.jdbc.Driver cannot be resolved to a variable at com.renyi.demo.JDBCDemo.main(JDBCDemo.java:7)
驱动包我也导入了,
右键项目,Build Path,
Configure Build Path,
Libraries
Add External jars
找到connector,重新运行就好了吧