直接上代码`
public class SQLTest {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
//注册驱动,将JDBC驱动装进JAVA虚拟机中
Class.forName("com.mysql.jdbc.Driver");
//获取路径
String url = "jdbc:mysql://127.0.0.1:3306/java14_0308_test?useSSL=false&characterEncoding=utf8";
//设置用户名和密码
String username = "root";
String password = "";
//获取Connection(数据库)连接
Connection connection = DriverManager.getConnection(url,username,password);
Scanner sc = new Scanner(System.in);
String sql = sc.nextLine();</