下载mysql-installer-community-5.7.44.0。
jdbc驱动要是用8.3版本。mysql-connector-j-8.3.0
参考菜鸟教程,将jdbc放入tomcat的lib文件夹。
写一个验证程序。
<%@ page language="java" import="java.util.*,java.sql.DriverManager" pageEncoding="utf-8"%> <%@ page import="java.sql.Connection" %> <% System.out.println("Hello, World!"); try { Class.forName("com.mysql.cj.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } Connection con = null; con=DriverManager.getConnection("jdbc:mysql://localhost:3306/jiazheng","abc","123456"); System.out.println("连接成功"); if (con != null){ System.out.println("数据库连接成功"); }else{ System.out.println("数据库连接失败"); } %> </html>View Code
标签:8.3,jdbc,新写,之二,jsp,mysql From: https://www.cnblogs.com/vactor/p/18104694