日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

mysql驱动profilesql_java连接mysql的驱动配置问题

發布時間:2024/9/27 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql驱动profilesql_java连接mysql的驱动配置问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

想用java訪問mysql數據庫,下載了一個驅動,然后根據網上說的,配置了classpath,結果失敗,原因是ClassNotFoundException,然后繼續往上搜索,最后將該驅動放置到jdk\lib\ext目錄下,...

想用java訪問mysql數據庫,下載了一個驅動,然后根據網上說的,配置了classpath,結果失敗,原因是ClassNotFoundException,然后繼續往上搜索,最后將該驅動放置到jdk\lib\ext目錄下,還是老毛病,總是失敗,忙活半晚上依然是同一個問題。不知道誰能給個痛快點的解決辦法。20分送上。

程序如下:

import java.sql.*;

class ConMysql

{

public static void main(String[] args) throws SQLException

{

//show details

//1.load the driver

Class.forName("com.mysql.jdbc.Driver");

//2.use DriverManager to get the connection with the mysql database

Connection conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/twq","root","220323");

//3.use Connection to create a Statement object

Statement stmt=conn.createStatement();

//4.execute sql sentences

ResultSet rs=stmt.executeQuery("select * from student");

//5.show the result

while(rs.next())

{

System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getString(3));

}

//6.release all the resources

if(rs != null)

{

rs.close();

}

if(stmt != null)

{

stmt.close();

}

if(conn != null)

{

conn.close();

}

}

}

我用的是jcreator和eclipse,配置了環境變量classpath,均不能成功編譯,原因均是java.lang.ClassNotFoundException。在eclipse導入了那個jar包,仍然失敗。

展開

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的mysql驱动profilesql_java连接mysql的驱动配置问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。