zoukankan      html  css  js  c++  java
  • java中myeclipse连接mysql问题(java.lang.ClassNotFoundException: com.mysql.jdbc.Driver)

    java中myeclipse连接mysql问题(java.lang.ClassNotFoundException: com.mysql.jdbc.Driver)
    1、往项目中添加mysql-connector-java-5.0.8-bin.jar。驱动jar包;(右击项目buildpath——》add)
    2、 String driver = "com.mysql.jdbc.Driver";
    // URL指向要访问的数据库名
    String url = "jdbc:mysql://127.0.0.1:3306/sxu_art_group";
    String user = "root";
    String password = "";
    Class.forName(driver);
    try {
    // 加载驱动程序
    Class.forName(driver);
    // 连续数据库
    Connection conn = DriverManager.getConnection(url, user, password);
    if(!conn.isClosed()){
    System.out.println("Succeeded connecting to the Database!");
    }
    // statement用来执行SQL语句
    Statement statement = conn.createStatement();
    // 要执行的SQL语句
    String sql = "select * from student";
    }catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
  • 相关阅读:
    英语语法
    elk笔记2.0
    zabbix4.0-centos6 报错坑,是因为有3.0的包
    jenkins 用户授权
    python随记
    jenkins
    zabbix3.0、4.0 agent安装配置
    常用
    document.createElement()方法
    581. Shortest Unsorted Continuous Subarray(LeetCode)
  • 原文地址:https://www.cnblogs.com/RuMengkai/p/6230977.html
Copyright © 2011-2022 走看看