setting中的javac改为eclipse 报错 :找不到主类的错误
ClassPath : ,;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
JAVA_HOME : E:\JAVA\JDK8
Path : E:\JAVA\JDK8\bin
import java.sql.*;
public class JdbcDemo {
public static void main(String[] args) throws Exception {
// 1.注册驱动
// Class.forName("com.mysql.jdbc.Driver");
Class.forName("com.mysql.cj.jdbc.Driver");
// 2.获取连接
String url=" jdbc:mysql:/bc?useSLL=false&characterEncoding=UTF-8;";
// String url= "jdbc:mysql://localhost:3306bc?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT";
String username="root" ;
String password="123333";
Connection conn = DriverManager.getConnection(url,username,password) ;
// 3.定义SQL语句
String sql = "update student set age = age + 10 where name = '张三' ;" ;
// 4.执行Sql
Statement st = conn.createStatement();
// 5.处理结果
int s = st.executeUpdate(sql); // 几行代码受影响,就返回几
System.out.println(s);
// 6.释放资源
st.close();
conn.close();
}
}
图三module 把你的项目加上 version选8
你看你的MySQL和你的jar版本合适不