标签:pwd file intel ext idea time har for title
<%@ page import="java.sql.Connection" %> <%@ page import="java.sql.DriverManager" %> <%@ page import="java.sql.SQLException" %>
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2019/8/14 Time: 11:25 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>测试</title> </head> <body> <% try { String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver"; String DB_URL = "jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC"; Class.forName(JDBC_DRIVER); String userName="root"; String userPwd="123456"; Connection conn= DriverManager.getConnection(DB_URL,userName,userPwd); if(conn!=null){ out.println("数据库连接成功!"); conn.close(); }else { out.println("数据库连接失败!"); } }catch (ClassNotFoundException e){ e.printStackTrace(); }catch (SQLException e) { e.printStackTrace(); } %> </body> </html>
标签:pwd file intel ext idea time har for title
原文地址:https://www.cnblogs.com/qc-wh/p/11352506.html