精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • Java連接MySQL有錯(cuò)誤Sorry,can`t find the Driver!,請(qǐng)各位看一下

    Java連接MySQL有錯(cuò)誤Sorry,can`t find the Driver!,請(qǐng)各位看一下
    這是提示的錯(cuò)誤
    Sorry,can`t find the Driver!
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at JDBCTest.main(JDBCTest.java:11)
    下面是Java代碼
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class JDBCTest {
    public static void main(String[] args){
    try {
    // 加載驅(qū)動(dòng)程序
    Class.forName("com.mysql.jdbc.Driver");
    // URL指向要訪問的數(shù)據(jù)庫(kù)名test
    String url = "jdbc:mysql://127.0.0.1:3306/test";
    // MySQL配置時(shí)的用戶名
    String user = "root";
    // MySQL配置時(shí)的密碼
    String password = "123456";
    // 連續(xù)數(shù)據(jù)庫(kù)
    Connection connection = DriverManager.getConnection(url, user, password);
    if(!connection.isClosed())
    System.out.println("Succeeded connecting to the Database!");
    // statement用來執(zhí)行SQL語句
    Statement statement = connection.createStatement();
    // 要執(zhí)行的SQL語句
    String sql = "select * from student";
    // 執(zhí)行SQL語句并返回結(jié)果集
    ResultSet rs = statement.executeQuery(sql);
    System.out.println(" 學(xué)號(hào)" + "\t" + " 姓名");
    String name = null;
    while(rs.next()) {
    // 選擇sname這列數(shù)據(jù)
    name = rs.getString("sname");
    // 輸出結(jié)果
    System.out.println(rs.getString("sno") + "\t" + name);
    }
    // 關(guān)閉結(jié)果集
    rs.close();
    // 關(guān)閉連接
    connection.close();
    } catch(ClassNotFoundException e) {
    System.out.println("Sorry,can`t find the Driver!");
    e.printStackTrace();
    } catch(SQLException e) {
    e.printStackTrace();
    } catch(Exception e) {
    e.printStackTrace();
    }
    }
    }
    其他人氣:473 ℃時(shí)間:2020-05-27 03:11:39
    優(yōu)質(zhì)解答
    將你的驅(qū)動(dòng)jar包拖到WEN_INF/lib里面試試看怎么操作啊,我不會(huì)弄,能具體點(diǎn)嗎??jī)煞N方法:
    1 項(xiàng)目上右擊--》Build Path--》Configure Build Path,默認(rèn)應(yīng)該是在Libraries那個(gè)Tab,然后點(diǎn)Add External Jars,找到你的驅(qū)動(dòng)Jar.
    2 直接將你的Jar復(fù)制粘貼到項(xiàng)目WEN_INF/lib目錄下
    我來回答
    類似推薦
    請(qǐng)使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版