1 String url = "jdbc:mysql://localhost:3306/student?Unicode=true&characterEncoding=utf-8";
 2             Properties info = new Properties();
 3             info.put("user", "canon");
 4             info.put("password", "123456");
 5             
 6             /**
 7              * 三种方式加载驱动建立连接
 8              */
 9             //方式1
10             Driver driver = new com.mysql.jdbc.Driver();
11             Connection connection = driver.connect(url, info);
12             
13             /*
14             //方式2
15             Driver driver = DriverManager.getDriver(url);
16             connection = driver.connect(url, info);
17             
18             //方式3
19             Class.forName(url);
20             conn = DriverManager.getConnection(url, info);
21             */

 

相关文章:

  • 2022-01-15
  • 2022-01-19
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-11
  • 2022-01-14
猜你喜欢
  • 2022-12-23
  • 2021-08-10
  • 2021-11-20
  • 2022-12-23
  • 2021-11-18
  • 2021-11-20
相关资源
相似解决方案