資源簡介
基于JDBC的學生信息管理系統,有簡單的圖形界面實現,數據庫使用MySQL,實現了學生信息的增刪改查,課程信息的增刪改查,學生成績統計,排序等功能

代碼片段和文件信息
package?main;
import?java.sql.Connection;
import?java.sql.DriverManager;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.sql.Statement;
public?class?Main?{
public?static?void?main(String[]?args)?{?//?主方法
//?聲明Connection對象
Connection?con;
//?驅動程序名
String?driver?=?“com.mysql.cj.jdbc.Driver“;
//?URL指向要訪問的數據庫名mydata
String?url?=?“jdbc:mysql://localhost:3306/csedb_u201716989?serverTimezone=UTC“;
//?MySQL配置時的用戶名
String?user?=?“root“;
//?MySQL配置時的密碼
String?password?=?“123456“;
//?遍歷查詢結果集
try?{
//?加載驅動程序
Class.forName(driver);
//?1.getConnection()方法,連接MySQL數據庫!!
con?=?DriverManager.getConnection(url?user?password);
if?(!con.isClosed())
System.out.println(“Succeeded?connecting?to?the?Database!“);
//?2.創建statement類對象,用來執行SQL語句!!
Statement?statement?=?con.createStatement();
//?要執行的SQL語句
String?sql?=?“select?*?from?student“;
//?3.ResultSet類,用來存放獲取的結果集!!
ResultSet?rs?=?statement.executeQuery(sql);
String?job?=?null;
String?id?=?null;
while?(rs.next())?{
//?獲取stuname這列數據
job?=?rs.getString(“sno“);
//?獲取stuid這列數據
id?=?rs.getString(“sname“);
//?輸出結果
System.out.println(id?+?“\t“?+?job);
}
rs.close();
con.close();
}?catch?(ClassNotFoundException?e)?{
//?數據庫驅動類異常處理
System.out.println(“Sorrycan‘t?find?the?Driver!“);
e.printStackTrace();
}?catch?(SQLException?e)?{
//?數據庫連接失敗異常處理
e.printStackTrace();
}?catch?(Exception?e)?{
//?TODO:?handle?exception
e.printStackTrace();
}?finally?{
System.out.println(“數據庫數據成功獲取!!“);
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-10-25?22:01??MySQL_Test\
?????文件?????????406??2019-10-25?22:02??MySQL_Test\.classpath
?????文件?????????386??2019-10-25?21:46??MySQL_Test\.project
?????目錄???????????0??2019-10-25?21:46??MySQL_Test\.settings\
?????文件?????????598??2019-10-25?21:46??MySQL_Test\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2019-11-14?16:06??MySQL_Test\bin\
?????目錄???????????0??2019-11-14?16:06??MySQL_Test\bin\main\
?????文件????????2653??2019-11-14?15:36??MySQL_Test\bin\main\Main.class
?????文件????????2180??2019-12-03?10:43??MySQL_Test\bin\main\MySql.class
?????目錄???????????0??2019-12-17?11:18??MySQL_Test\bin\view\
?????文件?????????665??2019-12-17?11:18??MySQL_Test\bin\view\CInfoPanel$1.class
?????文件?????????665??2019-12-17?11:18??MySQL_Test\bin\view\CInfoPanel$2.class
?????文件?????????918??2019-12-17?11:18??MySQL_Test\bin\view\CInfoPanel$3.class
?????文件????????3341??2019-12-17?11:18??MySQL_Test\bin\view\CInfoPanel$4.class
?????文件????????8736??2019-12-17?11:18??MySQL_Test\bin\view\CInfoPanel.class
?????文件?????????665??2019-12-17?10:19??MySQL_Test\bin\view\GInfoPanel$1.class
?????文件?????????665??2019-12-17?10:19??MySQL_Test\bin\view\GInfoPanel$2.class
?????文件?????????665??2019-12-17?10:19??MySQL_Test\bin\view\GInfoPanel$3.class
?????文件?????????665??2019-12-17?10:19??MySQL_Test\bin\view\GInfoPanel$4.class
?????文件?????????824??2019-12-17?10:19??MySQL_Test\bin\view\GInfoPanel$5.class
?????文件???????13795??2019-12-17?10:19??MySQL_Test\bin\view\GInfoPanel.class
?????文件?????????961??2020-01-09?20:12??MySQL_Test\bin\view\MainWindow$1.class
?????文件?????????961??2020-01-09?20:12??MySQL_Test\bin\view\MainWindow$2.class
?????文件?????????961??2020-01-09?20:12??MySQL_Test\bin\view\MainWindow$3.class
?????文件????????2871??2020-01-09?20:12??MySQL_Test\bin\view\MainWindow.class
?????文件?????????665??2019-12-17?10:19??MySQL_Test\bin\view\SInfoPanel$1.class
?????文件?????????665??2019-12-17?10:19??MySQL_Test\bin\view\SInfoPanel$2.class
?????文件????????3551??2019-12-17?10:19??MySQL_Test\bin\view\SInfoPanel$3.class
?????文件????????9568??2019-12-17?10:19??MySQL_Test\bin\view\SInfoPanel.class
?????目錄???????????0??2019-10-25?22:01??MySQL_Test\lib\
?????文件?????2293144??2019-10-25?21:48??MySQL_Test\lib\mysql-connector-java-8.0.16.jar
............此處省略9個文件信息
- 上一篇:vc+sql教材發放管理系統
- 下一篇:SQLServer詳解
評論
共有 條評論