新聞中心
隨著互聯(lián)網(wǎng)技術(shù)的發(fā)展和應用領(lǐng)域的不斷擴展,越來越多的數(shù)據(jù)需要整合和管理。對于學生管理系統(tǒng)而言,基于數(shù)據(jù)庫的管理方式已經(jīng)成為了當前最為常見和有效的方法之一。在Java編程語言的基礎(chǔ)上,應用數(shù)據(jù)庫技術(shù)進行學生管理系統(tǒng)的開發(fā),不僅具有管理便捷、效率高、安全可靠等優(yōu)勢,同時也是一種技術(shù)逐步發(fā)展和完善的表現(xiàn)。

成都創(chuàng)新互聯(lián)公司成立于2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務公司,擁有項目成都網(wǎng)站制作、網(wǎng)站設(shè)計網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元佳木斯做網(wǎng)站,已為上家服務,為佳木斯各地企業(yè)和個人服務,聯(lián)系電話:028-86922220
一、Java學生管理系統(tǒng)的基本構(gòu)成
Java學生管理系統(tǒng)的基本構(gòu)成框架主要包括:基礎(chǔ)框架設(shè)計、用戶登錄注冊、學生信息錄入、管理查詢與增刪改查等。
在基礎(chǔ)框架設(shè)計中,根據(jù)學生管理系統(tǒng)實現(xiàn)的要求和業(yè)務流程,進行系統(tǒng)整體架構(gòu)和關(guān)鍵細節(jié)的設(shè)計。這里需要考慮到用戶界面的友好性和操作的便捷性,同時也需要注意到系統(tǒng)的穩(wěn)定性和安全性。一般而言,這一環(huán)節(jié)可以通過前期需求分析、系統(tǒng)架構(gòu)設(shè)計以及用戶訪談等方式來確立。
在用戶登錄注冊中,主要是對用戶身份的驗證和管理。使用Java提供的身份驗證機制、Cookie技術(shù)或者Token驗證等方式,實現(xiàn)用戶信息的查找、注冊與登錄,并統(tǒng)一能夠接入第三方登錄API接口,方便用戶快速登錄管理系統(tǒng)。
在學生信息錄入環(huán)節(jié)中,可以通過Java開發(fā)框架中提供的ORM技術(shù)(如Hibernate,MyBatis等),連接數(shù)據(jù)庫并實現(xiàn)對學生信息的錄入和維護,包括學生基本信息、成績信息、考勤信息、課程安排和選修情況等。
在管理查詢與增刪改查環(huán)節(jié)中,管理員可以通過學生管理系統(tǒng)的管理界面對學生信息進行查找、修改、刪除和添加等操作,將學生個人信息唯一化地存儲、進行數(shù)據(jù)分析和處理。
以上環(huán)節(jié)只是Java學生管理系統(tǒng)的基本框架,而其中協(xié)同作用最重要的方法之一,就是基于數(shù)據(jù)庫的數(shù)據(jù)管理。
二、Java學生管理系統(tǒng)中的數(shù)據(jù)管理
在Java學生管理系統(tǒng)的基本框架之上,數(shù)據(jù)庫作為系統(tǒng)的數(shù)據(jù)存儲和管理平臺,是其最為重要的技術(shù)之一。使用Java作為系統(tǒng)編程語言,常用的數(shù)據(jù)庫管理方式包括MySQL、Oracle、SQL Server、PostgreSQL等。這里,以MySQL數(shù)據(jù)庫管理平臺為例,闡述Java學生管理系統(tǒng)的數(shù)據(jù)庫管理技術(shù)。
1. 數(shù)據(jù)庫建庫和設(shè)計
在MySQL數(shù)據(jù)庫管理平臺中,首先需要將基礎(chǔ)框架設(shè)計中的概念和要求轉(zhuǎn)換為具體的數(shù)據(jù)庫架構(gòu)和數(shù)據(jù)庫設(shè)計。在建庫和設(shè)計過程中,需要考慮到數(shù)據(jù)庫表之間的邏輯關(guān)系、數(shù)據(jù)的讀取和修改效率,以及數(shù)據(jù)安全和防護需求等。一般而言,可以采用ER圖或者UML建模工具對數(shù)據(jù)庫架構(gòu)進行設(shè)計,完成后進行數(shù)據(jù)庫正式建庫。
2. 數(shù)據(jù)庫連接
在Java中,采用JDBC或者ORM框架可以連接MySQL數(shù)據(jù)庫。在JDBC方式中,由Java API通過JDBC Driver連接到MySQL服務端上,使用sql語句實現(xiàn)對MySQL數(shù)據(jù)庫的操作;而在ORM框架中,則可以直接將Java對象映射為數(shù)據(jù)庫中的表,通過對象實例對象化的方式進行數(shù)據(jù)管理。
3. 數(shù)據(jù)庫增刪改查
在連接MySQL數(shù)據(jù)庫之后,Java學生管理系統(tǒng)就可以進行各種數(shù)據(jù)管理操作,例如插入、刪除、更新和查詢等。具體操作可以通過Sql語句實現(xiàn),也可以通過ORM框架直接操作Java對象。為了提高數(shù)據(jù)的操作效率和數(shù)據(jù)存儲安全性,可以采用批量插入和批量更新的操作方法,同時也需要注意到數(shù)據(jù)庫的鎖定,盡可能減少死鎖的發(fā)生。
三、Java學生管理系統(tǒng)的數(shù)據(jù)加強方案
數(shù)據(jù)庫管理平臺在Java學生管理系統(tǒng)中的使用,可以有效提升學生管理系統(tǒng)的數(shù)據(jù)安全性和效率。然而,僅僅是使用數(shù)據(jù)庫仍然可能存在一些問題和短處,如數(shù)據(jù)加密、數(shù)據(jù)備份和數(shù)據(jù)恢復等。因此,開發(fā)者需要對Java學生管理系統(tǒng)的數(shù)據(jù)方案進行加強,以提高數(shù)據(jù)的安全保障和數(shù)據(jù)存儲的穩(wěn)定性。
1. 數(shù)據(jù)庫備份
數(shù)據(jù)備份是Java學生管理系統(tǒng)中數(shù)據(jù)方案加強的重要一環(huán)。針對數(shù)據(jù)備份策略,可以根據(jù)項目具體需求制定不同的計劃,例如全排、增量備份和時間周期備份等。對于大通量數(shù)據(jù)的管理,可以采用分庫分表的方式來提高操作性能和數(shù)據(jù)庫的穩(wěn)定性。
2. 數(shù)據(jù)加密
數(shù)據(jù)加密的目的是提高數(shù)據(jù)的安全性,防止數(shù)據(jù)泄漏和被破解。針對Java學生管理系統(tǒng)的數(shù)據(jù)加密,可以使用對稱加密算法、非對稱加密算法或者哈希算法等現(xiàn)代加密技術(shù)來保證數(shù)據(jù)可控性和安全性。
3. 數(shù)據(jù)恢復
Java學生管理系統(tǒng)中的數(shù)據(jù)恢復也是非常重要的。數(shù)據(jù)恢復需要針對數(shù)據(jù)丟失、數(shù)據(jù)完整性和數(shù)據(jù)恢復成本進行綜合考慮,制定最合理的恢復方案。除此之外,也可以進行數(shù)據(jù)壓縮和索引優(yōu)化,以提高數(shù)據(jù)訪問效率和減少數(shù)據(jù)存儲空間。
四、結(jié)語
Java學生管理系統(tǒng)的數(shù)據(jù)庫加強方案,是提高學生管理系統(tǒng)數(shù)據(jù)安全和穩(wěn)定性的有效手段。通過對數(shù)據(jù)庫的備份、加密和恢復等技術(shù)實現(xiàn)及時保護學生信息,增強學生管理系統(tǒng)的數(shù)據(jù)可控性與數(shù)據(jù)存儲效率,為數(shù)據(jù)安全保障提供了強有力的技術(shù)支持。未來將有更多技術(shù)及發(fā)展空間用于完善學生管理系統(tǒng)中的數(shù)據(jù)管理。
相關(guān)問題拓展閱讀:
- (高分)急求連接數(shù)據(jù)庫的JAVA學生信息管理系統(tǒng)源代碼
- 急求一個Java編寫的學生成績管理系統(tǒng),數(shù)據(jù)庫更好能是SqlServer。先在這兒謝謝大家啦!
(高分)急求連接數(shù)據(jù)庫的JAVA學生信息管理系統(tǒng)源代碼
書店有的很好的例子,自己去書店看看,我看過。
數(shù)據(jù)庫連接(Connection)者首
數(shù)據(jù)庫連接
獲取數(shù)據(jù)庫連接有兩種方法,一種是通過驅(qū)動程序管理器DriverManager類,另一種則是使用DataSource接口。這兩種方法都提供了了一個getConnection方法,用戶可以在程序中對它們進行相應處理后調(diào)用這個方猜山法來返回數(shù)據(jù)庫連接。
? DriverManager類
? DataSource接口
? Connection接口
? JDBC URL
jdbc::
?穗嫌中 驅(qū)動程序注冊方法
(1)調(diào)用Class.forName方法
(2)設(shè)置jdbc.drivers系統(tǒng)屬性
? DriverManager方法
DriverManager類中的所有方法都是靜態(tài)方法,所以使用DriverManager類的方法時,不必生成實例。
DriverManager
? getConnection方法
作用是用于獲取數(shù)據(jù)庫連接,原型如下:
public static Connection getConnection(String url)
throws SQLException;
public static Connection getConnection(String url, String user, String password)
throws SQLException;
public static Connection getConnection(String url, Properties info)
throws SQLException;
? 使用DriverManager的getConnetion方法
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
Connection conn = DriverManager.getConnection
(“jdbc:odbc:sqlserver”, “sa”, “sa”);
? 使用設(shè)置jdbc.drivers系統(tǒng)屬性的方法
java -Djdbc.drivers=sun.jdbc.odbc.JdbcOdbcDriver test.java
DataSource 接口
……
//從上下文中查找數(shù)據(jù)源,并獲取數(shù)據(jù)庫連接
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup(“sqlserver”);
Connection conn = ds.getConnection();
//查詢數(shù)據(jù)庫中所有記錄
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(“SELECT * FROM student”);
……
Connection 接口
Connection接口代表了已經(jīng)建立的數(shù)據(jù)庫連接,它是整個JDBC的核心內(nèi)容。Connnection接口中的方法按照它們所實現(xiàn)的功能,可以分為三類:
? 生成數(shù)據(jù)庫語句
? 管理數(shù)據(jù)庫事務
? 獲取數(shù)據(jù)庫信息
生成數(shù)據(jù)庫語句
JDBC將數(shù)據(jù)庫語句分成三種類型 :
? 生成Statement 語句 :
Connection.createStatement()
? 生成PreparedStatement 語句 :
Connection. prepareStatement()
? 生成CallableStatement 語句 :
Connection. prepareCall ()
管理數(shù)據(jù)庫事務
? 默認情況下,JDBC將一條數(shù)據(jù)庫語句視為一個完整的事務??梢躁P(guān)掉默認事務管理:
public void setAutoCommit(Boolean autoCommit) throws SQLException;
將autoCommit的值設(shè)置為false,就關(guān)掉了自動事務管理模式
? 在執(zhí)行完事務后,應提交事務:
public void commit() throws SQLException;
? 可以取消事務:
public void rollback() throws SQLException;
第二講 第四部分
數(shù)據(jù)庫語句
數(shù)據(jù)庫語句
JDBC數(shù)據(jù)庫語句共有三種類型:
? Statement:
Statement語句主要用于嵌入一般的SQL語句,包括查詢、更新、插入和刪除等等。
? PreparedStatement:
PreparedStatement語句稱為準備語句,它是將SQL語句中的某些參數(shù)暫不指定,而等到執(zhí)行時在統(tǒng)一指定。
? CallableStatement:
CallableStatement用于執(zhí)行數(shù)據(jù)庫的存儲過程。
Statement 語句
? executeQuery方法
? executeUpdate方法
? execute方法
? close方法
executeQuery方法
? executeQuery方法主要用于執(zhí)行產(chǎn)生單個結(jié)果集的SQL查詢語句(QL),即SELECT語句。executeQuery方法的原型如下所示:
? public ResultSet executeQuery(String sql) throws SQLException;
executeUpdate方法
? executeUpdate方法主要用于執(zhí)行 INSERT、UPDATE、DELETE語句,即SQL的數(shù)據(jù)操作語句(DML)
? executeUpdate方法也可以執(zhí)行類似于CREATE TABLE和DROP TABLE語句的SQL數(shù)據(jù)定義語言(DDL)語句
? executeUpdate方法的返回值是一個整數(shù),指示受影響的行數(shù)(即更新計數(shù))。而對于CREATE TABLE 或 DROP TABLE等并不操作特定行的語句,executeUpdate的返回值總為零。
execute方法
execute方法用于執(zhí)行:
? 返回多個結(jié)果集
? 多個更新計數(shù)
? 或二者組合的語句
execute方法
? 返回多個結(jié)果集:首先要調(diào)用getResultSet方法獲得之一個結(jié)果集,然后調(diào)用適當?shù)膅etter方法獲取其中的值。要獲得第二個結(jié)果集,需要先調(diào)用getMoreResults方法,然后再調(diào)用getResultSet方法。
? 返回多個更新計數(shù):首先要調(diào)用getUpdateCount方法獲得之一更新計數(shù)。然后調(diào)用getMoreResults,并再次調(diào)用getUpdateCount獲得后面的更新計數(shù)。
? 不知道返回內(nèi)容:如果結(jié)果是ResultSet對象,則execute方法返回true;如果結(jié)果是int類型,則意味著結(jié)果是更新計數(shù)或執(zhí)行的語句是DDL命令。
execute方法
為了說明如果處理execute方法返回的結(jié)果,下面舉一個代碼例子:
stmt.execute(query);
while (true) {
int row = stmt.getUpdateCount();
//如果是更新計數(shù)
if (row > 0) {
System.out.println(“更新的行數(shù)是:” + row);
stmt.getMoreResults();
continue;
}
execute方法
//如果是DDL命令或0個更新
if (row == 0) {
System.out.println(“沒有更新,或SQL語句是一條DDL語句!”);
stmt.getMoreResults();
continue;
}
//如果是一個結(jié)果集
ResultSet rs = stmt.getResultSet;
if (rs != null) {
while (rs.next()) {
// 處理結(jié)果集
. . .
}
stmt.getMoreResults();
continue;
}
break;
}
PreparedStatement 語句
登錄一個網(wǎng)站或BBS時 :
? 使用Statement語句
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery
(“SELECT password FROM userinfo
WHERE id=userId”);
? 使用PreparedStatement語句
PreparedStatement pstmt=conn.prepareStatement
(“SELECT password FROM userinfo
WHERE id=?”);
pstmt.setString(1, userId);
PreparedStatement語句
? 常用的setter方法
public void setBoolean(int parameterIndex, boolean x) throws SQLException;
public void setByte(int parameterIndex, byte x) throws SQLException;
public void setShort(int parameterIndex, short x) throws SQLException;
public void setInt(int parameterIndex,int x) throws SQLException;
public void setLong(int parameterIndex, long x) throws SQLException;
public void setFloat(int parameterIndex, float x) throws SQLException;
public void setDouble(int parameterIndex, double x) throws SQLException;
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException;
public void setString(int parameterIndex, String x) throws SQLException;
public void setBytes(int parameterIndex, byte x) throws SQLException;
public void setDate(int parameterIndex, Date x) throws SQLException;
public void setTime(int parameterIndex, Time x) hrows SQLException;
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException;
PreparedStatement語句
? PreparedStatement接口是由Statement接口擴展而來的,重寫了executeQuery方法、executeUpdate方法和execute 方法
? public ResultSet executeQuery() throws SQLException
? public int executeUpdate() throws SQLException
? public boolean execute() throws SQLException
CallableStatement語句
? CallableStatement語句是由Connection接口的prepareCall方法創(chuàng)建的,創(chuàng)建時需要傳入字符串參數(shù),參數(shù)的形式為:
? {call procedure_name}
? {? = call procedure_name}
? {call procedure_name}
CallableStatement語句
? 其中的問號是參數(shù)占位符,參數(shù)共有兩種:
? IN參數(shù)
? OUT參數(shù)
? IN參數(shù)使用setter方法來設(shè)置
? OUT參數(shù)則使用registerOutParameter方法來設(shè)置
CallableStatement 語句
CallableStatement cstmt = con.prepareCall
(“{call getTestData(?, ?)}”);
cstmt.registerOutParameter
(1, java.sql.Types.TINYINT);
cstmt.registerOutParameter
(2, java.sql.Types.DECIMAL, 3);
cstmt.executeQuery();
byte x = cstmt.getByte(1);
java.math.BigDecimal n =
cstmt.getBigDecimal(2, 3);
第二講 第五部分
結(jié) 果 集
結(jié)果集
? JDBC為了方便處理查詢結(jié)果,又專門定義了一個接口,這個接口就是ResultSet接口。ResultSet接口提供了可以訪問數(shù)據(jù)庫查詢結(jié)果的方法,通常稱這個接口所指向的對象為結(jié)果集。
? 有兩種方法得到結(jié)果集,一種是直接執(zhí)行查詢語句,將結(jié)果存儲在結(jié)果集對象上;另一種是不存儲返回結(jié)果,而在需要時調(diào)用數(shù)據(jù)庫語句的getResultSet方法來返回結(jié)果集
結(jié)果集
? 結(jié)果集指針
由于返回的結(jié)果集可能包含多條數(shù)據(jù)記錄,因此ResultSet 接口提供了對結(jié)果集的所有數(shù)據(jù)記錄輪詢的方法。結(jié)果集自動維護了一個指向當前數(shù)據(jù)記錄的指針,初始時這個指針是指向之一行的前一個位置。 next 方法就是用于向前移動指針的
結(jié)果集
? 結(jié)果集屬性
默認情況下,結(jié)果集是一個不可更新集,并且結(jié)果集的指針也只能向前移動。也就是說,在得到了一個結(jié)果集之后,用戶只能按照從之一條記錄到最后一條記錄的順序依次向后讀取,而不能跳到任意條記錄上,也不能返回到前面的記錄。不僅如此,結(jié)果集的這種輪詢只能進行一次,而不能再將指針重置到初始位置進行多次輪詢
結(jié)果集
? 結(jié)果集屬性
類型
并發(fā)性
有效性
? 屬性的設(shè)置是在生成數(shù)據(jù)庫語句時通過向生成方法傳入相應的參數(shù)設(shè)定的,而當結(jié)果集已經(jīng)返回時就不能夠再改變它的屬性了。
結(jié)果集生成Statement語句共有三種方法
public Statement createStatement() throws SQLException;
public Statement createStatement
(int resultSetType, int resultSetConcurrency)
throws SQLException;
public Statement createStatement
(int resultSetType, int resultSetConcurrency,
int resultSetHoldability)
throws SQLException;
結(jié)果集
? 生成PreparedStatement語句共有六種方法
public PreparedStatement prepareStatement(String sql) throws SQLException;
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException;
public PreparedStatement prepareStatement(String sql, int columnIndexes)
throws SQLException;
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException;
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException;
public PreparedStatement prepareStatement(String sql. String columnNames)
throws SQLException;
結(jié)果集
? 生成CallableStatement語句共有三種方法
public CallableStatement prepareCall(String sql)
throws SQLException;
public CallableStatement prepareCall
(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException;
public CallableStatement prepareCall
(String sql, int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException;
結(jié)果集
結(jié)果集類型
? 結(jié)果集的類型共有三種,TYPE_FORWARD_ON類型的結(jié)果集只能向前移動指針,而TYPE_SCROLL_INSENSITIVE類型和TYPE_SCROLL_SENSITIVE類型的結(jié)果集則可以任意移動指針。后兩種類型的區(qū)別在于,前者對來自其它處的修改不敏感(靜態(tài)),而后者則對于別人的修改敏感(動態(tài)視圖)。
結(jié)果集
結(jié)果集類型
? 對于可以任意移動指針的結(jié)果集,可以用來移動指針的方法包括:
? next 和previous :
? absolute 和relative :參數(shù)可正可負
? afterLast 、beforeFirst 、last 和first :
結(jié)果集
結(jié)果集并發(fā)性
? 結(jié)果集的并發(fā)性共有兩種,CONCUR_READ_ON的結(jié)果集是只讀而不可更新的;而CONCUR_UPDATABLE的結(jié)果集則是可以通過update方法進行更新的。
? ResultSet接口提供了一組update方法,用于更新結(jié)果集中的數(shù)據(jù)。這些方法與PreparedStatement接口中定義的setter方法一樣,也是與類型相對應的。所有的update方法都以update開頭 。
? 所有的update方法都有兩個參數(shù),之一個參數(shù)用于指定更新的列,它可以是列名稱也可以是列的序號;第二個參數(shù)則表示將要更新列的值。
結(jié)果集
結(jié)果集并發(fā)性
? Statement stmt = conn.createStatement
?(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
?ResultSet rs = stmt.executeQuery(“SELECT * FROM student ” +
?”WHERE grade=2 AND math>60 AND physics>60 AND ” +
?”chemistry>60 AND english>60 AND chinese>60″);
?while(rs.next()){
?rs.updateString(“grade”, “3”);
?rs.updateRow();
?}
結(jié)果集
結(jié)果集有效性
? 結(jié)果集的有效性是指在調(diào)用了Connection 接口的commit 方法后,結(jié)果集是否自動關(guān)閉。所以它只有兩個可選值,即HOLD_CURSORS_OVER_COMMIT 和CLOSE_CURSORS_AT_COMMIT 。前者表示調(diào)用commit 方法之后,結(jié)果集不關(guān)閉;而后者則表示關(guān)閉結(jié)果集。
結(jié)果結(jié)果集
? 結(jié)果集的getter方法
ResultSet接口還提供了一組getter方法,用于返回當前記錄的屬性值。它們都是以get開頭的,后接數(shù)據(jù)類型。比如,如果要返回一個float類型的列值,則應調(diào)用getFloat方法。每一種類型的getter方法都有兩種形式,它們的名稱相同而參數(shù)不同。這兩種形式的getter方法都只有一個參數(shù),之一種形式的getter方法參數(shù)是String類型的,用于指定列的名稱;另外一種形式的getter方法參數(shù)則是int類型的,用于指定列的序號。
你要連的數(shù)據(jù)庫是SQL 還是ORACLE
但是代碼都查不多
下面的是連接SQL數(shù)據(jù)庫的代碼
你需要先創(chuàng)建個數(shù)據(jù)庫,還有表,表的字段是登陸名和密碼
下面的”SA” 是登陸名 “111111” 是密碼
ORACLE 和這個查不多
import java.sql.*;//做數(shù)據(jù)庫時候必須要引入的包
import com.microsoft.jdbc.sqlserver.SQLServerDriver;
public class DBFactory {
Connection Conn=null;
PreparedStatement Stmt=null;
ResultSet Rs=null;
String driverName=”com.microsoft.jdbc.sqlserver.SQLServerDriver”;
String OracleUserName=”sa”;
String OracleUserPwd=”111111″;
String ConnUrl=”jdbc:
public Connection getConnection()
{
try {
Class.forName(driverName);
} catch (ClassNotFoundException ex) {
System.out.println(“加載驅(qū)動程序有錯誤”);
}
try {
Conn = DriverManager.getConnection(ConnUrl, OracleUserName,OracleUserPwd);
} catch (SQLException ex1) {
System.out.print(“取得仿陸連接的時候有錯誤,請核對用戶名和密碼”);
}
return Conn;
}
這個是連接ORACLE數(shù)據(jù)庫代碼
import java.sql.*;
import oracle.jdbc.driver.OracleDriver;
public class DBFactory {
Connection Conn=null;
PreparedStatement Stmt=null;
ResultSet Rs=null;
String driverName=”oracle.jdbc.driver.OracleDriver”;
String OracleUserName=”scott”;
String OracleUserPwd=”tiger”;
String ConnUr1=”jdbc:oracle:thin:@locahost:1521:Ora”;
public Connection getConnection()
{
try {
Class.forName(driverName);
} catch (ClassNotFoundException ex) {
System.out.println(“加載驅(qū)動程序有錯誤”);
}
try {
Conn = DriverManager.getConnection(ConnUr1, OracleUserName,OracleUserPwd);
} catch (SQLException ex1) {
System.out.print(“取得連接時有錯誤,備啟頃旁核請核對用戶名和密碼”);
}
return Conn;
}
急求一個Java編寫的學生成績管理系統(tǒng),數(shù)據(jù)庫更好能是SqlServer。先在這兒謝謝大家啦!
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
public class Students extends Applet implements ActionListener
{
Vector StuInf=new Vector();
StudentInf SI;
String xm;
String bj;
int i,j,xh,cj;
static int mid;
Label prompt1=new Label(“學生成績管理系統(tǒng)”);
Label prompt2=new Label(” 用戶:”);
Label prompt3=new Label(” 密碼:”);
Label prompt4=new Label(” 班級:”);
Label prompt5=new Label(” 成績:”);
TextField input1=new TextField(8);
TextField input2=new TextField(8);
TextField input3=new TextField(8);
TextField input4=new TextField(8);
Button btn1=new Button(“登錄”);
Button btn2=new Button(“增加”);
Button btn3=new Button(“修改”);
Button btn4=new Button(“刪除”);
public void init()
{
setLayout(new GridLayout(6,3));
add(new Label());
add(prompt1);
add(new Label());
add(prompt2);
add(input1);
add(new Label());
add(prompt3);
add(input2);
add(btn1);
add(prompt4);
add(input3);
add(new Label());
add(prompt5);
add(input4);
add(new Label());
add(btn2);
add(btn3);
add(btn4);
prompt4.setVisible(false);
prompt5.setVisible(false);
input3.setVisible(false);
input4.setVisible(false);
btn2.setVisible(false);
btn3.setVisible(false);
btn4.setVisible(false);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()==”登錄”明慎)
{
String a,b;
a=input1.getText();
b=input2.getText();
input1.setText(“”);
if((a.equals(“12”)==true)&&(b.equals(“12”)==true))
{
prompt2.setText(” 姓名:”);
prompt3.setText(“升槐者 學吵薯號:”);
prompt4.setVisible(true);
prompt5.setVisible(true);
input3.setVisible(true);
input4.setVisible(true);
btn2.setVisible(true);
btn3.setVisible(true);
btn4.setVisible(true);
btn3.setEnabled(false);
btn4.setEnabled(false);
btn1.setLabel(“查詢”);
input1.setText(“登錄成功”);
input1.selectAll();
}
else
input2.setText(“用戶名或密碼錯”);
}
if(e.getActionCommand()==”增加”)
{
boolean scucss=true;
try
{
XingMing();
}
catch(EmptyException as)
{
input1.setText(“姓名不能為空”);
scucss=false;
}
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText(“學號為空或格式錯”);
scucss=false;
}
bj=input3.getText();
try
{
ChengJi();
}
catch(EmptyException as)
{
cj=-1;
}
catch(OverException dd)
{
input4.setText(“應在0-100間”);
scucss=false;
}
catch(NumberFormatException cm)
{
input4.setText(“成績應為數(shù)據(jù)”);
scucss=false;
}
if(scucss==true)
{
SI=new StudentInf(xm,xh,bj,cj);
Insert(SI);
}
}
if(e.getActionCommand()==”修改”)
{
xm=input1.getText();
xh=Integer.parseInt(input2.getText());
bj=input3.getText();
cj=Integer.parseInt(input4.getText());
SI=new StudentInf(xm,xh,bj,cj);
StuInf.setElementAt(SI, mid);
btn3.setEnabled(false);
}
if(e.getActionCommand()==”刪除”)
{
StuInf.removeElementAt(mid);
btn4.setEnabled(false);
input1.setText(“刪除成功”);
input2.setText(“”);
input3.setText(“”);
input4.setText(“”);
}
if(e.getActionCommand()==”查詢”)
{
boolean right=true;
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText(“學號為空或格式錯”);
right=false;
}
if(right==true)
{
search(xh);
btn3.setEnabled(true);
btn4.setEnabled(true);
}
}
}
//查找方法
public void search(int k)
{
boolean exist=false;
int low=0;
int high=StuInf.size()-1;
while(low100)
throw (new OverException());
}
//學生信息類
public class StudentInf
{
private String name;
private int StuNo;
private String ClassNo;
private int Level;
StudentInf(String xingming,int xuehao,String banji,int chengji)
{
name=xingming;
StuNo=xuehao;
ClassNo=banji;
Level=chengji;
}
public int getStuNo()
{
return StuNo;
}
public String getname()
{
return name;
}
public String getClassNo()
{
return ClassNo;
}
public int getLevel()
{
return Level;
}
}
}
java學生管理系統(tǒng)加數(shù)據(jù)庫的介紹就聊到這里吧,感謝你花時間閱讀本站內(nèi)容,更多關(guān)于java學生管理系統(tǒng)加數(shù)據(jù)庫,Java學生管理系統(tǒng):數(shù)據(jù)庫加強版,(高分)急求連接數(shù)據(jù)庫的JAVA學生信息管理系統(tǒng)源代碼,急求一個Java編寫的學生成績管理系統(tǒng),數(shù)據(jù)庫更好能是SqlServer。先在這兒謝謝大家啦!的信息別忘了在本站進行查找喔。
創(chuàng)新互聯(lián)服務器托管擁有成都T3+級標準機房資源,具備完善的安防設(shè)施、三線及BGP網(wǎng)絡(luò)接入帶寬達10T,機柜接入千兆交換機,能夠有效保證服務器托管業(yè)務安全、可靠、穩(wěn)定、高效運行;創(chuàng)新互聯(lián)專注于成都服務器托管租用十余年,得到成都等地區(qū)行業(yè)客戶的一致認可。
標題名稱:Java學生管理系統(tǒng):數(shù)據(jù)庫加強版(java學生管理系統(tǒng)加數(shù)據(jù)庫)
當前URL:http://www.dlmjj.cn/article/cocopse.html


咨詢
建站咨詢
