zoukankan      html  css  js  c++  java
  • java MySQl数据库连接

    <%@ 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?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>
  • 相关阅读:
    python函数
    文件操作
    python列表,元组,字典,集合简介
    python字符串(str)
    python数字类型 or 进制转换
    流程控制
    Python入门
    Python垃圾回收机制
    python简介&下载&安装
    DAY11
  • 原文地址:https://www.cnblogs.com/qc-wh/p/11352506.html
Copyright © 2011-2022 走看看